Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Blt to another window
#1
Ok, for my game, Monster Trainer, I'm changing from using picboxes to blting the monsters in the battle window... I've hit a snag... that I don't know how exactly to blt to another form's picbox haha

Could anyone give me any pointers?

I'm not very good with bitblt, if you didn't guess haha.

Cheers.
Reply
#2
Have fun having 2 backbuffers.

Become a real man and only use one form.
Reply
#3
You can use blttohdc from a surface. Or create a new clip like what MS does for the main pic box.
Reply
#4
Won't that blt the same thing?

He wants to blt two different things.
Reply
#5
my problem is i have a battle window already set up, i can't be arsed transfering it to mirage.frm 'cos it wouldn't look right

i'll try blttohdc... cheers for the replies Smile
Reply
#6
Ok, i'm really confused now haha, right.. so i'm using Bitblt to do it with, i'm using the following code:
Code:
Call BitBlt(frmBattleWindow.picScreen.hdc, M1X, M1Y, 127, 127, frmGFX.picMonsters.hdc, 0, 0, vbSrcCopy)

but this happens:
[Image: weirdgfx7wq.jpg]

it like... draws the map below...

anyone have any ideas? :S

Edit: sorted that

Now I have come accross the problem of that bitblt won't let me have black transparent... I need a specific colour to be transparent... can someone please give me pointers to a way I can blt stuff into a picbox... even if i need to make 2 backbuffers and stuff and make 1 backbuffer for the main game window, and the 2nd for the battle window

i hate blting lol

cheers Smile
Reply
#7
ok, this may help, here's the code I've used up to now (except the dims, saving time):

InitDirectX
Code:
Sub InitDirectX()

    ' Initialize direct draw
    Set DD = DX.DirectDrawCreate("")
    Set DD2 = DX.DirectDrawCreate("")
    frmMirage.Show
    
    ' Indicate windows mode application
    Call DD.SetCooperativeLevel(frmMirage.hWnd, DDSCL_NORMAL)
    Call DD2.SetCooperativeLevel(frmBattleWindow.hWnd, DDSCL_NORMAL)
    
    ' Init type and get the primary surface
    DDSD_Primary.lFlags = DDSD_CAPS
    DDSD_Primary.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
    Set DD_PrimarySurf = DD.CreateSurface(DDSD_Primary)
    
    'Monster One
    DDSD2_Primary.lFlags = DDSD_CAPS
    DDSD2_Primary.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
    Set DD2_PrimarySurf = DD2.CreateSurface(DDSD2_Primary)
    
    ' Create the clipper
    Set DD_Clip = DD.CreateClipper(0)
    Set DD2_Clip = DD2.CreateClipper(0)
    
    ' Associate the picture hwnd with the clipper
    DD_Clip.SetHWnd frmMirage.picScreen.hWnd
    DD2_Clip.SetHWnd frmBattleWindow.picScreen.hWnd
        
    ' Have the blits to the screen clipped to the picture box
    DD_PrimarySurf.SetClipper DD_Clip
    DD2_PrimarySurf.SetClipper DD2_Clip
        
    ' Initialize all surfaces
    Call InitSurfaces
    Call InitSurfaces2
End Sub


Initsurfaces2
Code:
Sub InitSurfaces2()
Dim Key As DDCOLORKEY
    If FileExist("/GFX/monsters/monsters.bmp") = False Then
        Call MsgBox("Your Monster graphics are not available, please download the game again.", vbCritical, "Graphics Error!")
        Call GameDestroy
    End If
    
    Key.low = 0
    Key.high = 0
    
    ' Initialize MONSTER back buffer
    DDSD2_BackBuffer.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
    DDSD2_BackBuffer.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
    DDSD2_BackBuffer.lWidth = frmbattlewindow.picscreen.width
    DDSD2_BackBuffer.lHeight = frmbattlewindow.picscreen.height
    Set DD2_BackBuffer = DD2.CreateSurface(DDSD2_BackBuffer)
    
    ' Init Monsters ddsd type and load the bitmap
    DDSD2_MONSTERS.lFlags = DDSD_CAPS
    DDSD2_MONSTERS.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
    Set DD2_MONSTERSsurf = DD2.CreateSurfaceFromFile(App.Path & "\GFX\monsters\monsters.bmp", DDSD2_MONSTERS)
    DD2_MONSTERSsurf.SetColorKey DDCKEY_SRCBLT, Key

End Sub

Now the jumbled up bit, a sub that's called when battle window is open, containing these things:
Code:
'Rec Place
        rec2.top = 0
        rec2.Bottom = 127
        rec2.Left = 0
        rec2.Right = 127
        
    M1X = 100
    M1Y = 100
    Call DD2_BackBuffer.BltFast(M1X, M1Y, DD2_MONSTERSsurf, rec2, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)

TexthDC = DD2_BackBuffer.GetDC
        rec2.top = 0
        rec2.Bottom = rec2.top + frmBattleWindow.picScreen.Height
        rec2.Left = 0
        rec2.Right = rec2.Right + frmBattleWindow.picScreen.Width
        ' Release DC
        Call DD2_BackBuffer.ReleaseDC(TexthDC)
              
        ' Get the rect to blit to
        Call DX2.GetWindowRect(frmBattleWindow.picScreen.hWnd, rec_pos2)
        rec_pos2.Bottom = rec_pos2.top + frmBattleWindow.picScreen.Height
        rec_pos2.Right = rec_pos2.Left + frmBattleWindow.picScreen.Width
      
        ' Blit the backbuffer
        Call DD2_PrimarySurf.Blt(rec_pos2, DD2_BackBuffer, rec2, DDBLT_WAIT)


Anyone see any problems? :S[/code]
Reply
#8
I still ain't got this to work, but in all honesty I haven't had much time, essay due in tomorrow and had 2 tests this week... been really busy

can anyone give me any pointers? cheers
Reply
#9
I've had a thought... would there be a way to use the bitblt sub to draw it but WITH transparent black?

I don't know much about bitblt so I can't really say I know how to, could anyone please give me some pointers?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)