Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > DirectX > Error in code


Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2002, 09:14 PM
Epo Epo is offline
Junior Contributor
 
Join Date: Jan 2002
Location: Ontario, Canada
Posts: 332
Default Error in code


I know nothing is more of a pain than looking through someone's code and telling them where their mistake is.....so I'm going to try and make this as easy as possible for you

Code:
'In general
Dim DX As New DirectX7
Dim DD As DirectDraw7
Dim DDPS As DirectDrawSurface7
Dim DDBS As DirectDrawSurface7
Dim DDPSD As DDSURFACEDESC2
Dim DDBSD As DDSURFACEDESC2
Dim DDCaps As DDSCAPS2
Dim Running As Boolean

Private Sub Form_Load()
    Set DD = DX.DirectDrawCreate("")
    frmMain.Show
    
    Call DD.SetCooperativeLevel(frmMain.hWnd, DDSCL_EXCLUSIVE Or DDSCL_FULLSCREEN Or DDSCL_ALLOWMODEX)
    Call DD.SetDisplayMode(1280, 1024, 32, 0, DDSDM_DEFAULT)
    
    With DDPSD
        .lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
        .ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
        .lBackBufferCount = 1
    End With
    Set Primary = DD.CreateSurface(DDPSD)
    
    DDCaps.lCaps = DDSCAPS_BACKBUFFER
    Set Backbuffer = Primary.GetAttachedSurface(DDCaps)**
    Backbuffer.GetSurfaceDesc ddsd3
    
    frmMain.Show
    Running = True
    
    Do Until Running = False
        DoEvents
    Loop
End Sub
I get an error where the double stars are (they are not a part of the code) ....and the error says "Only user defined types in public modules can be coerced to or from a variant or passed to late bound functions"

And i really don't know what I'm doing wrong....andy ideas, suggestions or questions are welcome

Thanks
Reply With Quote
  #2  
Old 02-20-2002, 07:17 AM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

Did you declare primary and backbuffer as surfaces?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 02-20-2002, 01:31 PM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

Adding Option Explicit to the top of your code will help eradicate errors like these. You can make it automatic by going Tools -> Options -> Require Variable Declaration.

I concur with Iceplug that the error probably has something to do with the fact that Primary and Backbuffer have not been declared (or ddsd3 and ddsCaps for that matter).

ALWAYS DECLARE YOUR VARIABLES!
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #4  
Old 02-20-2002, 02:05 PM
Epo Epo is offline
Junior Contributor
 
Join Date: Jan 2002
Location: Ontario, Canada
Posts: 332
Default

There it is ....Yeah....I'm flipping between Squirm's Tutorial, a second tutorial, and my code (my code uses different variables though) so I got mixed up with Primary and BackBuffer (I thought they were "declarations" instead of calling variables)....although now that I look at it more carefully I don't get why I thought that

Thanks
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
 
 
-->