Direct Draw Create Surface

Epo
03-22-2002, 04:52 PM
is there a way to create a surface without loading a picture on? (i.e. just the colour black)

the tutorial I'm looking at gives me the line:


Set MainSurf = DD.CreateSurfaceFromFile


and so on ......but....a solid black bmp is half a meg....pretty large for just a background... so is there a way I can just assign the colour black to the background? thanks :)

AndreRyan
03-23-2002, 01:32 AM
Dim PrimaryDESC as DDSURFACEDESC2
Dim Primary as DirectDrawSurface7

PrimaryDESC.lFlags = dds_caps
PrimaryDESC.ddscaps.lCaps = DDSCAPS_PRIMARYSURFACE

Set Primary = DirectDrawVariable.CreateSurface(PrimaryDESC)

This creates an empty Primary surface in directdraw(for Normal Mode)

Epo
03-23-2002, 08:34 AM
I've got the creating of the surface done...Here's My code:


Sub InitSurfaces()
Set MainSurf = Nothing

With DDSD2
.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
.lWidth = DDSD3.lWidth
.lHeight = DDSD3.lHeight
End With

Set MainSurf = DD.CreateSurfaceFromFile(App.Path & "\Picture.bmp")
End Sub



but instead of the last line loading in a picture, I want it to just load a solid colour (without having to make a 1280x1024 bmp load on to the background)

Squirm
03-23-2002, 09:59 AM
Did you try AndreRyan's code? Note that he does not use CreateSurfaceFromFile. You need to use the CreateSurface method instead. Put the serface information such as height, width, and flag settings into the DDSURFACEDESC2 object which you pass to the method.

If you think back to your setting up DD routine, you will have a line like this:

ddsd.lFlags = DDSD_BACKBUFFERCOUNT Or DDSD_CAPS
ddsd.ddsCaps.lCaps = DDSCAPS_COMPLEX Or DDSCAPS_FLIP Or DDSCAPS_3DDEVICE Or DDSCAPS_PRIMARYSURFACE
Set Primary = DD.CreateSurface(ddsd)

As you can see, the answer lies under your nose there with the CreateSurface call. Obviously you would want to use different flags to those you used to create the Primary. DDSCAPS_OFFSCREENPLAIN springs to mind:

With ddsd
.lWidth = iWidth
.lHeight = iHeight
.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
.ddsCaps.lCaps2 = 0
.lTextureStage = 0
End With

Set objSurface = DD.CreateSurface(ddsd)

Or something like that......

Epo
03-23-2002, 04:35 PM
Thanks :) That helped :)

I have just one more question (I'm following a tutorial)

I set up my Primary Surface (I know what that does)

I set up my BackBuffer (Dido)

But there's a third surface (Mainsurf) and I have only one backbuffer....can anyone tell me why that is there or why it might be used? thanks :)

Squirm
03-23-2002, 04:46 PM
Without seeing some code its impossible to tell. I would have thought MainSurf would be holding some kind of background picture.

Hard to say.

Iceplug
03-24-2002, 12:21 PM
Mainsurf may just be a BehindTheScenes surface that contains a picture to blt.

Epo
03-24-2002, 02:36 PM
Thanks for the help :) (But I'm going back to D3D)

I'm scraping the DirectDraw :)

I'm making a 2D game and though DD would be easier, but D3D is a lot easier for me and if I DO want to go 3D it will take less programming changes :)

Thanks for the help though :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum