Mirage Source http://web.miragesource.net/forums/ |
|
Blt to another window http://web.miragesource.net/forums/viewtopic.php?f=201&t=1221 |
Page 1 of 20 |
Author: | Tosuxo [ Tue Jan 23, 2007 7:02 pm ] |
Post subject: | Blt to another window |
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. |
Author: | Robin [ Tue Jan 23, 2007 8:58 pm ] |
Post subject: | |
Have fun having 2 backbuffers. Become a real man and only use one form. |
Author: | Misunderstood [ Tue Jan 23, 2007 9:51 pm ] |
Post subject: | |
You can use blttohdc from a surface. Or create a new clip like what MS does for the main pic box. |
Author: | Robin [ Tue Jan 23, 2007 10:10 pm ] |
Post subject: | |
Won't that blt the same thing? He wants to blt two different things. |
Author: | Tosuxo [ Tue Jan 23, 2007 11:36 pm ] |
Post subject: | |
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 |
Author: | Tosuxo [ Wed Jan 24, 2007 1:31 pm ] |
Post subject: | |
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: 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 |
Author: | Tosuxo [ Wed Jan 24, 2007 2:37 pm ] |
Post subject: | |
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] |
Author: | Tosuxo [ Thu Feb 01, 2007 9:10 pm ] |
Post subject: | |
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 |
Author: | Tosuxo [ Sun Feb 04, 2007 6:21 pm ] |
Post subject: | |
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? |
Author: | wanai [ Fri May 13, 2022 8:06 am ] |
Post subject: | Re: Blt to another window |
Vass |
Author: | wanai [ Fri May 13, 2022 8:07 am ] |
Post subject: | Re: Blt to another window |
293.5 |
Author: | wanai [ Fri May 13, 2022 8:08 am ] |
Post subject: | Re: Blt to another window |
Duke |
Author: | wanai [ Fri May 13, 2022 8:09 am ] |
Post subject: | Re: Blt to another window |
Repr |
Author: | wanai [ Fri May 13, 2022 8:11 am ] |
Post subject: | Re: Blt to another window |
Sanz |
Author: | wanai [ Fri May 13, 2022 8:12 am ] |
Post subject: | Re: Blt to another window |
Mika |
Author: | wanai [ Fri May 13, 2022 8:13 am ] |
Post subject: | Re: Blt to another window |
Pons |
Author: | wanai [ Fri May 13, 2022 8:14 am ] |
Post subject: | Re: Blt to another window |
Mich |
Author: | wanai [ Fri May 13, 2022 8:15 am ] |
Post subject: | Re: Blt to another window |
Rajn |
Author: | wanai [ Fri May 13, 2022 8:16 am ] |
Post subject: | Re: Blt to another window |
Bert |
Author: | wanai [ Fri May 13, 2022 8:17 am ] |
Post subject: | Re: Blt to another window |
Harr |
Author: | wanai [ Fri May 13, 2022 8:18 am ] |
Post subject: | Re: Blt to another window |
Zyli |
Author: | wanai [ Fri May 13, 2022 8:19 am ] |
Post subject: | Re: Blt to another window |
Sidn |
Page 1 of 20 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |