PDA

Click to See Complete Forum and Search --> : DirectX


Dorothy
Jun 15th, 2001, 05:10 AM
CreateASurface(DirectdrawObject As DirectDraw7, DDSurface As DirectDrawSurface7, Width As Long, Height As Long, SourceFile As String)

What am I supposed to pass as the first and second parameter
for this function?

Fox
Jun 15th, 2001, 06:06 AM
1) Your direct draw object, declared somewhere like this:
Dim DDraw as DirectDraw7
Note that you need to initialize it first:
Set DDraw = DirectX.DirectDrawCreate("")


2) Your surface like declared like this:
Dim Surface As DirectDrawSurface7

To see how to load the surface you can review this function:


Public Function LoadTexture(iFileName As String, iMasked As Boolean) As DirectDrawSurface7
Dim A As Long
Dim Temp As Boolean

Dim Surface As DirectDrawSurface7
Dim SurfaceDesc As DDSURFACEDESC2

Dim Texture As Direct3DEnumPixelFormats

Dim ColorKey As DDCOLORKEY
Dim PixelFormat As DDPIXELFORMAT

If Dir(iFileName) = "" Then
'Error: File not found
Set Surface = DDraw.CreateSurface(SurfaceDesc)

Exit Function
End If

'Set flags
SurfaceDesc.lFlags = DDSD_CAPS Or DDSD_TEXTURESTAGE Or DDSD_PIXELFORMAT

'Check for 16-bit support
Set Texture = Device.GetTextureFormatsEnum

For A = 1 To Texture.GetCount()
Temp = True
Call Texture.GetItem(A, SurfaceDesc.ddpfPixelFormat)

'Check color depth
With SurfaceDesc.ddpfPixelFormat
If .lRGBBitCount <> 16 Then: Temp = False
End With

'Found
If Temp Then: Exit For
Next

If Not Temp Then
'No support for 16-bit textures
Set LoadTexture = Nothing

Exit Function
End If

'Set texture flags
If Device.GetDeviceGuid() = "IID_IDirect3DHALDevice" Then
SurfaceDesc.ddsCaps.lCaps = DDSCAPS_TEXTURE
SurfaceDesc.ddsCaps.lCaps2 = DDSCAPS2_TEXTUREMANAGE
SurfaceDesc.lTextureStage = 0
Else
SurfaceDesc.ddsCaps.lCaps = DDSCAPS_TEXTURE
SurfaceDesc.ddsCaps.lCaps2 = 0
SurfaceDesc.lTextureStage = 0
End If

'Load bitmap
Set Surface = DDraw.CreateSurfaceFromFile(iFileName, SurfaceDesc)

'Apply color key (white)
If iMasked Then
Surface.GetPixelFormat PixelFormat
ColorKey.low = PixelFormat.lRBitMask + PixelFormat.lGBitMask + PixelFormat.lBBitMask
ColorKey.high = ColorKey.low
Surface.SetColorKey DDCKEY_SRCBLT, ColorKey
End If

'Return surface
Set LoadTexture = Surface
End Function

PsychoMark
Jun 15th, 2001, 06:11 AM
If you're trying to use DirectX 7, but don't even know what the DirectDraw7 object is, I suggest reading some material first:

http://www.vbexplorer.com/directx4vb/

Dorothy
Jun 15th, 2001, 08:58 AM
Let me state it clearly. I want to place a large graphic file on a form. I tried:
Form1.picture="filename"
It worked, but had a flicker.

My friend suggested to use DirectX to solve this problem.

Am totally new to this technology.

Help me in painting a picture on a form without a flicker.

Thanks Fox for your explanation
Thanks PsychoMark for your advice

PsychoMark
Jun 15th, 2001, 09:05 AM
Form1.AutoRedraw=True
Form1.Picture=LoadPicture("C:\Bla.bmp")


Should work fine...

I don't think DirectX will make a difference if you're just painting a picture, it'll even be worse, since DirectX requires a lot more than just a bitmap...

So my second advise: don't use DirectX, it may even cause more flicker and a much slower program...