Archived

This topic is now archived and is closed to further replies.

passing surfacename in function

This topic is 5986 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am developing a crude graphics engine in VB. I am currently writing code to load and display bitmaps. However, I am having troubles passing the name of a new surface to a function. Check out the code below: ---------- Sub Game_Loop() Call Load_Bitmap(16, 16, Tile_Dirt, "/tile1.bmp") Call Draw_Bitmap(100, 100, Tile_Dirt) End Sub Sub Load_Bitmap(Width As Integer, Height As Integer, Bitmap_Surface_Name As DirectDrawSurface7, Bitmap_Path As String) Dim Bitmap_Surface_Name As DirectDrawSurface7 Set Bitmap_Surface_Name = Nothing ddsd2.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH 'default flags ddsd2.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN ddsd2.lWidth = Width ddsd2.lHeight = Height 'this is where the surface is created. You use the DDraw object to create a 'surface from the specified file name using the above description. Set Bitmap_Surface_Name = dd.CreateSurfaceFromFile(App.Path & Bitmap_Path, ddsd2) End Sub Sub Draw_Bitmap(X_Coor As Integer, Y_Coor As Integer, Surface_Name As DirectDrawSurface7) Dim ddrval As Long rBack.Bottom = ddsd3.lHeight rBack.Right = ddsd3.lWidth ddrval = backbuffer.BltFast(X_Coor, Y_Coor, Surface_Name, rBack, DDBLTFAST_WAIT) End Sub ---------- When the application launches I receive an error message saying "Variable not decfined" referring to Tile_Dirt from these lines of code: Call Load_Bitmap(16, 16, Tile_Dirt, "/tile1.bmp") Call Draw_Bitmap(100, 100, Tile_Dirt) This is probably just a basic programming question, but I need to know how to pass the surface name to these functions. Thanks a lot! Alexander Edited by - alex mcandrew on July 28, 2001 6:17:19 PM

Share this post


Link to post
Share on other sites