Results 1 to 5 of 5

Thread: DirectX

  1. #1

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310

    Question DirectX

    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?

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    1) Your direct draw object, declared somewhere like this:
    Code:
    Dim DDraw as DirectDraw7
    Note that you need to initialize it first:
    Code:
    Set DDraw = DirectX.DirectDrawCreate("")

    2) Your surface like declared like this:
    Code:
    Dim Surface As DirectDrawSurface7
    To see how to load the surface you can review this function:

    Code:
    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

  3. #3
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    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/
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  4. #4

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310
    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

  5. #5
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    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...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width