-
[RESOLVED][VB]Some directdraw questions
ok, some of these may sound n00bish, I am new to directX, so here goes:
after I have started the fullscreen mode, created the primary and backbuffer surfaces, how would I display buttons on the screen? do they need to be defined as their own surfaces, or just as RECTs? would I need to create a flipping chain just for these buttons? or is there a way I could just leave the primary surfaces up there? (and is it recommended I do so?)
Thanks in advance.
-
Re: Some directdraw questions
What version of DX are you using, and what language. prior to DX9 it is pretty differnt on how to do it compared to DX9.
ØØ
-
Re: Some directdraw questions
didnt directdraw only come with DX 7? didnt it change after that?
-
Re: Some directdraw questions
DDraw does not come as a part of DX8, but in DX 9 it is back...;)...but DDraw is the same in both versions, but how to make a GUI is pretty different....;)
ØØ
-
Re: Some directdraw questions
well, i have the latest version of directx on my sytem, 9.2 b or something. but my project is using directx 7 (at least, thats what it is linked to)
-
Re: Some directdraw questions
I didnt actually know that thanks noteme :)
-
Re: Some directdraw questions
If I remember irght in my old days, there was no simple way to use Win GUI in DX7. And DX7 had no classes on it's own for drawing a GUI. I remember seein Arbiter (was it him) that made his own chatt app in a game of his where he made the textbox ++ him self from scratch.
And that is probably the easiest way to do it.
And old friend of ours here on the forum (long time no see M) wrote a couple of tutorials on the topic. You can find them here:
http://rookscape.com/vbgaming/tutBW.php
http://rookscape.com/vbgaming/tutBX.php
Then again, I am not sure if you are using VB at all, since you never told us, so if you are using C++ then you have a tutorial here:
http://www.gamedev.net/reference/art...article994.asp
But then again, if you are using C++, then you could just have used DX9 and used the GUI classes there to save you some trouble. So thats why I am guessing you are using VB.
PS:DX9.0b is not the newest one. DX9.0c is.
ØØ
-
Re: Some directdraw questions
Quote:
Originally Posted by Pino
I didnt actually know that thanks noteme :)
NP...just happy to spread around some knowledge...:)
ØØ
-
Re: Some directdraw questions
yea, i am using VB, and the last time i updated directx that was the newest one ;)
I looked at those pages, and they dont really show me what i need to know. I have looked at other code, and tried to duplicate it for my own uses, but it doesnt work. I am not trying to make my own window and such, i have a fullscreen game i am trying to make and JUST need to blt pictures to the screen. lol.
-
Re: Some directdraw questions
Well if you are just trying to Blt pictures to the screen, then do it as you do with all the other pictures you have on the screen. (Hopefully, ifyou have any)
So just load them the normal way to a surface, and Blt them as usual.
Do you have anything on your screeen at all?
PS: Example code of what has been done after reading Machairaas tutorials.
http://visualbasicforum.com/attachme...achmentid=8010
ØØ
-
Re: Some directdraw questions
well, thats just it, i am a little confused about the theory, say i wanted to make my button go to the screen, would i load the bmp of the button into a surface, and then blt the surface to the backbuffer? or somehow load it into a RECT and then blt that to the backbuffer or what?
-
Re: Some directdraw questions
I am a bit confused about your term rect here. If you are talking about the RECT struct then that is not a conatiner for a picture. It stores information about the size of something (like a picture), if you mean something else, please elaborate.
But what you should do is to load it to the surface, as you said, and then Blt it to the backbuffer, before you flip it to the screen.Thats correct.
ØØ
-
Re: [VB]Some directdraw questions
Like NoteMe said, all RECT stores is the size of the picture, not the picture itself.
-
Re: [VB]Some directdraw questions
ah... I think i see why i cant get anything on the screen.
So i would load a picture to the surface, then i would create a RECT that has the dimensions of the picture, and then blt it onto the backbuffer, then flip the backbuffer. correct?
-
Re: [VB]Some directdraw questions
Yeah, that is exactly the way to go. The reason why you have the RECT there, is so you can choose to only Blt a small part of the picture, like for a helth bar, or if you have batched more then one picture into one surface, you can choose what picture from the surface you want to Blt.
ØØ
-
Re: [VB]Some directdraw questions
right, so in this peice of code:
BltFast(dx As Long, dy As Long, ddS As DirectDrawSurface7, srcRect As RECT, trans As CONST_DDBLTFASTFLAGS) As Long
dx and dy would be?
-
Re: [VB]Some directdraw questions
If you have the DX SDK installed, you probably have the docs installed too. If not, it is higly recomended that you install it. It says there what all the parameters is.
But if I remeber right, it is the X coordiante and the Y coordinate where you want to draw the sprite.
And you can see that the rect for BltFast is the source rect. So you can't stretch and other things, but you can leave out a part of the source image if you want that.
Hope that helps.
ØØ
-
Re: [VB]Some directdraw questions
I already have the SDK, but it doesnt help much, most of it is for c++, and the managed languages section has some stuff, but under the directdraw section it has this
Note: This documentation is preliminary and is subject to change.
Warning: Microsoft® DirectDraw® has been deprecated. Deprecated components of Microsoft DirectX® 9.0 for Managed Code are considered obsolete. While these components are still supported in this release of DirectX 9.0 for Managed Code, they may be removed in the future. When writing new applications, you should avoid using these deprecated components. When modifying existing applications, you are strongly encouraged to remove any dependency on these components.
The DirectDraw application programming interface (API) is the component of DirectX that enables you to directly manipulate display memory, the hardware blitter, hardware overlay support, and flipping surface support. For more information, see the Microsoft.DirectX.DirectDraw managed code reference documentation.
So i go to the microsoft.directX.directdraw managed code refrerence documentation, and all of it gives me the same "deprecated" message.
furthermore, i have attempted to load surfaces from files, and it doesnt want to work for me, the pictures are bmps. and I get an error on this part of the code:
retval = dd.CreateSurfaceFromFile(path, ddsdf)
retval is an integer, dd is my directdraw object, path is a string that is the path to the bmp, and ddsdf is a DDSURFACEDESC2 (with it's height set at 49, and its width set at 200) (the size of my picture) and some other things for ddsdf: ddsdf.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
ddsdf.DDSCAPS.lCaps = DDSCAPS_OFFSCREENPLAIN And DDSCAPS_VIDEOMEMORY
so when i run it I get an error that says: method or data member not found. and it highlights .CreateSurfaceFromFile
I am beginning to think direct3D would be easier to work with... it isn't "deprecated"
-
Re: [VB]Some directdraw questions
Hi.
Your CreateSurfaceFromFile method is used to set a surface.
For example:
VB Code:
Dim mySurface As DirectDrawSurface7
Dim ddsdf As DDSURFACEDESC2
ddsdf.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT
ddsdf.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY
ddsdf.lWidth = lWidth
ddsdf.lHeight = lHeight
Set mySurface = DD.CreateSurfaceFromFile(Path, ddsdf)
Hope that helps
-
Re: [VB]Some directdraw questions
thanks noi_max! but now i get errors when I try to blt to the backbuffer:
retval = backbuffer.BltFast(200, 200, startgame1, REC(1, 200, 1, 49), DDBLTFAST_WAIT)
it says: runtime error 91, object variable or with block variable not set
got any ideas as to what is causing that?
-
Re: [VB]Some directdraw questions
I guess REC is supposed to be RECT???
ØØ
-
Re: [VB]Some directdraw questions
Quote:
retval = backbuffer.BltFast(200, 200, startgame1, REC(1, 200, 1, 49), DDBLTFAST_WAIT)
What is this:
REC(1, 200 1, 49)
Some kinda function?
Anyhow, did you not set your surface (I'm guessing it's startgame) or your backbuffer? Is this fullscreen?
Assuming you're working in fullscreen mode:
* Create complex primary surface.
* Create and attach backbuffer
* Create your other surfaces
* Blit surfaces onto backbuffer
* Flip backbuffer onto primary.
This is of course after you do your DirectX initialization. Looks like you've got some tutorial links in the thread to check out too.
As complex as this all seems to you now.. believe me.. Direct3D is not easier.
Here's some of my basic Initialization code.. if you're interested.
VB Code:
Public Sub InitDirectDrawFullScreen(frm As Form, ByVal lWidth As Long, _
ByVal lHeight As Long, ByVal bpp As Long)
Set DX = New DirectX7
Set DD = DX.DirectDrawCreate("")
DD.SetCooperativeLevel frm.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE
DD.SetDisplayMode lWidth, lHeight, bpp, 0, DDSDM_DEFAULT
Dim ddsd As DDSURFACEDESC2
ddsd.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
ddsd.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_COMPLEX Or _
DDSCAPS_FLIP
ddsd.lBackBufferCount = 1
Set Primary = DD.CreateSurface(ddsd)
Dim caps As DDSCAPS2
caps.lCaps = DDSCAPS_BACKBUFFER
Set BackBuffer = Primary.GetAttachedSurface(caps)
'Call sub to Init other surfaces
InitSurfaces
End Sub
-
Re: [VB]Some directdraw questions
well, i checked my code, re-wrote a few things, ect, but i still get the same error when I try to blt to the backbuffer.
Here is the REC code:
VB Code:
Function REC(left As Integer, right As Integer, bottom As Integer, top As Integer) As RECT
REC.left = left
REC.right = right
REC.bottom = bottom
REC.top = top
End Function
I have tried my code with a normal RECT and using just this code above...
-
Re: [VB]Some directdraw questions
How did you set up the backbuffer, and how did you set up startgame1?
ØØ
-
Re: [VB]Some directdraw questions
heres how i set up startgame1
VB Code:
Public startgame1 As DirectDrawSurface7
dim buttondesc as ddsurfacedesc2
buttondesc.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
buttondesc.DDSCAPS.lCaps = DDSCAPS_OFFSCREENPLAIN
buttondesc.lWidth = 200
buttondesc.lHeight = 49
Set startgame1 = dd.CreateSurfaceFromFile("startgame1.bmp", buttondesc)
'and the backbuffer settings:
Set dd = dx.DirectDrawCreate("") 'create the DirectDraw interface
dd.SetCooperativeLevel frmgame.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE
'initialize directdraw interface
dd.SetDisplayMode 640, 480, 32, 0, DDSDM_DEFAULT
'primary
ddsd.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
ddsd.DDSCAPS.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
ddsd.lBackBufferCount = 1
Set primary = dd.CreateSurface(ddsd)
'backbuffer
Dim DDSCAPS As DDSCAPS2
ddsd2.DDSCAPS.lCaps = DDSCAPS_BACKBUFFER
Set backbuffer = primary.GetAttachedSurface(ddsd2.DDSCAPS)
-
1 Attachment(s)
Re: [VB]Some directdraw questions
i decided to start from scratch. I actually got something to happen this time, i can display the picture "startgame1" on the screen, the only thing is, when i start it I get that picture, and the rest of the background is a flickering mass of pixels that at one point could have been part of the last image my computer displayed before starting my app.
Then i go back into developement and i get an automation error on the backbuffer.flip line
I have included the code. could someone please take a look and tell me what I am doing wrong???
-
Re: [VB]Some directdraw questions
-
1 Attachment(s)
Re: [VB]Some directdraw questions
Hi!
Couple of things you needed:
1) A means of exiting the game. For testing I just put your terminate sub into the Form_Click event
2) A seperate sub to initialize your offscreen surfaces, so if you've lost them you can call the sub to re-load them.
You don't need to do this for the Primary or attached backbuffer, that's why i seperated it from your Init DX code.
Here are the changes :)
-
Re: [VB]Some directdraw questions
thanks noi.
after hours of doing this myself I found that the error is caused when i exit the app and it tries to flip a surface that isnt there.
but I didnt know if that was a problem with my code, or if I left something out... I guess I forgot to terminate, lol
thanks for you're help guys!
-
Re: [VB]Some directdraw questions
When a thread is resolved. Please add the green check mark to the first post in the thread by editing it. I did it for you this time.
Thanks
ØØ