DirectX error
DirectX error
DirectX error
DirectX error
DirectX error
DirectX error DirectX error DirectX error DirectX error DirectX error DirectX error DirectX error DirectX error
DirectX error DirectX error
DirectX error
Go Back  Xtreme Visual Basic Talk > > > > DirectX error


Reply
 
Thread Tools Display Modes
  #1  
Old 11-28-2006, 03:45 AM
cfehunter cfehunter is offline
Newcomer
 
Join Date: Nov 2006
Posts: 4
Default DirectX error


Hi
this is my first attempt at using directX.

here's my code so far
Code:
Public Class Form1
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dx As New DirectX7
        Dim dd As DirectDraw7

        dd = dx.DirectDrawCreate("")
        Call dd.SetCooperativeLevel(Me.Handle, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE Or DDSCL_ALLOWREBOOT)
        Call dd.SetDisplayMode(640, 480, 16, 0, DDSDM_DEFAULT)
        Dim Primary As DirectDrawSurface7 'Primary surface
        Dim BackBuffer As DirectDrawSurface7 'Backbuffer surface
        Dim ddsdPrimary As DDSURFACEDESC2 'Primary surface description
        Dim caps As DDSCAPS2 'Capabilities description

        ddsdPrimary.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
        ddsdPrimary.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
        ddsdPrimary.lBackBufferCount = 1
        Primary = dd.CreateSurface(ddsdPrimary)
        caps.lCaps = DDSCAPS_BACKBUFFER
        BackBuffer = Primary.GetAttachedSurface(caps)

        Dim Hero As DirectDrawSurface7
        Dim ddsdNewSprite As DDSURFACEDESC2

        ddsdNewSprite.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT
        ddsdNewSprite.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
        ddsdNewSprite.lWidth = 16
        ddsdNewSprite.lHeight = 16
        Hero = dd.CreateSurfaceFromFile("HeroLeftMove.gif", ddsdNewSprite)

        Dim SrcRect As RECT
        Dim DestRect As RECT

        With SrcRect
            .Bottom = 16
            .Left = 0
            .Right = 16
            .Top = 0
        End With

        With DestRect
            .Bottom = 16
            .Left = 0
            .Right = 16
            .Top = 0
        End With

        BackBuffer.Blt(DestRect, Hero, SrcRect, DDBLT_WAIT)
        Primary.Flip(Nothing, DDFLIP_WAIT)
    End Sub
End Class
The File called "HeroLeftMove.gif" is in the same folder as the exe file, but i still get a file not found error with this code, can anybody help me please?
Reply With Quote
  #2  
Old 11-28-2006, 05:29 PM
beefmonky's Avatar
beefmonky beefmonky is offline
Regular
 
Join Date: Jun 2004
Posts: 66
Default

try:

Code:
Application.StartupPath & "\" & HeroLeftMove.gif

Quote:
Originally Posted by cfehunter
Hi
this is my first attempt at using directX.

here's my code so far
Code:
Public Class Form1
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dx As New DirectX7
        Dim dd As DirectDraw7

        dd = dx.DirectDrawCreate("")
        Call dd.SetCooperativeLevel(Me.Handle, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE Or DDSCL_ALLOWREBOOT)
        Call dd.SetDisplayMode(640, 480, 16, 0, DDSDM_DEFAULT)
        Dim Primary As DirectDrawSurface7 'Primary surface
        Dim BackBuffer As DirectDrawSurface7 'Backbuffer surface
        Dim ddsdPrimary As DDSURFACEDESC2 'Primary surface description
        Dim caps As DDSCAPS2 'Capabilities description

        ddsdPrimary.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
        ddsdPrimary.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
        ddsdPrimary.lBackBufferCount = 1
        Primary = dd.CreateSurface(ddsdPrimary)
        caps.lCaps = DDSCAPS_BACKBUFFER
        BackBuffer = Primary.GetAttachedSurface(caps)

        Dim Hero As DirectDrawSurface7
        Dim ddsdNewSprite As DDSURFACEDESC2

        ddsdNewSprite.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT
        ddsdNewSprite.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
        ddsdNewSprite.lWidth = 16
        ddsdNewSprite.lHeight = 16
        Hero = dd.CreateSurfaceFromFile("HeroLeftMove.gif", ddsdNewSprite)

        Dim SrcRect As RECT
        Dim DestRect As RECT

        With SrcRect
            .Bottom = 16
            .Left = 0
            .Right = 16
            .Top = 0
        End With

        With DestRect
            .Bottom = 16
            .Left = 0
            .Right = 16
            .Top = 0
        End With

        BackBuffer.Blt(DestRect, Hero, SrcRect, DDBLT_WAIT)
        Primary.Flip(Nothing, DDFLIP_WAIT)
    End Sub
End Class
The File called "HeroLeftMove.gif" is in the same folder as the exe file, but i still get a file not found error with this code, can anybody help me please?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
DirectX error
DirectX error
DirectX error DirectX error
DirectX error
DirectX error
DirectX error DirectX error DirectX error DirectX error DirectX error DirectX error DirectX error
DirectX error
DirectX error
 
DirectX error
DirectX error
 
-->