• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Anyone here familiar with DirectX?

Status
Not open for further replies.

RiZ III

Member
Are u using DirectDraw or D3D? Im good with DDraw and been messing around with D3D. The D3DX library is really nice.
 

Ecrofirt

Member
I figured I'd start with DirectDraw, since it's similiar to BitBlt which I'm used to.

I'm using it in Visual Basic, and I'm reading tutorials and stuff, but some of this is still over my head.
 

Ecrofirt

Member
Here's the thing that's really bugging me now.

Code:
Dim ddsd1 As DDSURFACEDESC2 [B]'this describes the primary surface[/B]
Dim ddsd2 As DDSURFACEDESC2 [B]'this describes the bitmap that we load[/B]
Dim ddsd3 As DDSURFACEDESC2 [B]'this describes the size of the screen[/B]
Those three are dimensioned, and then later on, this happens:
Code:
[B]'load the bitmap into a surface - backdrop.bmp[/B]
ddsd2.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH [B]'default flags[/B]
ddsd2.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
[B]'An offscreenplain means that
'the user never actually gets to see the surface - it is just an are in memory.[/B]

ddsd2.lWidth = ddsd3.lWidth [B]'the ddsd3 structure already holds the size
'of the screen. We could replace it with 640 and 480 - it would have the same effect[/B]

ddsd2.lHeight = ddsd3.lHeight
[B]'this is where the surface is created. You use the DDraw object to create a
'surface from the specified file name using the above description.[/B]
Where ddsd2 has values set to ddsd3's values. The problem is, before this, there is no mention of ddsd3 anywhere in the code. And the tutorial program (which this is copied from) works, which leaves me baffled.
 

RiZ III

Member
Arent all three defined up there as show? It has to be defined somewhere. Maybe in a header file or something.
 

aaaaa0

Member
Are you absolutely sure ddsd3 isn't getting passed into some API which is filling it out before this?

Where's the source for this sample?

Maybe is working because ddsd3 is uninitalized and just happens to be all zeros, and maybe zero just happens to mean "use default size".

???
 

Ecrofirt

Member
www.directx4vb.com article

the only other spot where I see ddsd3 before what I pasted is here:

Code:
[B]'get the screen surface and create a back buffer too[/B]
ddsd1.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
ddsd1.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
ddsd1.lBackBufferCount = 1
Set primary = dd.CreateSurface(ddsd1)

[B]'Get the backbuffer[/B]
Dim caps As DDSCAPS2
caps.lCaps = DDSCAPS_BACKBUFFER
Set backbuffer = primary.GetAttachedSurface(caps)
[I]backbuffer.GetSurfaceDesc ddsd3[/I]

Maybe that's it, and I just don't understand it enough. It lookes to me like it's getting the surface description from ddsd3, but ddsd3 hasn't had anything done to it yet.

this is at the beginning of the initialization of the program.
 

RiZ III

Member
Well actually since ddsd2 is the description for the bitmap you load, it doesnt really matter what you set its height/widht initially depending on how you do it. A lot of examples load the bitmap with the GDI functions, read the width and height from there and the description gets set from there when you do that.

Thats what might be happening in the example ur looking at.
 

aaaaa0

Member
Ecrofirt said:
www.directx4vb.com article

the only other spot where I see ddsd3 before what I pasted is here:

Code:
[I]backbuffer.GetSurfaceDesc ddsd3[/I]

Maybe that's it, and I just don't understand it enough. It lookes to me like it's getting the surface description from ddsd3, but ddsd3 hasn't had anything done to it yet.

this is at the beginning of the initialization of the program.

What that line of code is probably doing is telling the backbuffer to copy its parameters into ddsd3.

Look in the documentation for the parameters for the GetSurfaceDesc API to verify that's what it does.

(I don't use VB, everything I write is in C.)
 

aaaaa0

Member
Found it:

http://msdn.microsoft.com/archive/en-us/ddraw7/directdraw7/vbddref_77tu.asp?frame=true

DirectDraw 7.0
DirectDrawSurface7.GetSurfaceDesc

The DirectDrawSurface7.GetSurfaceDesc method retrieves a description of the surface in its current condition.

object.GetSurfaceDesc(surface As DDSURFACEDESC2)

Parameters

object - Object expression that resolves to a DirectDrawSurface7 object.
surface - DDSURFACEDESC2 type to be filled with the current description of this surface.

Error Codes

If the method fails, it raises an error, and Err.Number can be set to one of the following values:

DDERR_INVALIDOBJECT
DDERR_INVALIDPARAMS

BTW, I would seriously suggest you skip DX7.

The DX7 interfaces are totally obsolete now, you'd be much better off learning DX9 instead. Use VB.NET or C#.NET instead. (Or if you want to go older-school, plain old C :) ).
 

DaMan121

Member
Havent followed it much, but I dont think DirectDraw stuff has changed since 7, so if he is only screwin around with that, theres not much use for 9... until he starts on shaders that is :)
 

aaaaa0

Member
DaMan121 said:
Havent followed it much, but I dont think DirectDraw stuff has changed since 7, so if he is only screwin around with that, theres not much use for 9... until he starts on shaders that is :)

DirectDraw is obsolete. They stopped supporting it after DX7.

MS merged DirectDraw and D3D in DX8, it's just called DirectX Graphics now and handles both 2D and 3D.

So I think he might as well just skip to DX9.
 

maharg

idspispopd
DirectDraw has always been a bit lame. All it gives you, reliably, is a framebuffer. If the card could do any more high level processing (polygon drawing, certain kinds of hardware blting), it was pretty unlikely you'd ever get to use it.
 

aaaaa0

Member
maharg said:
DirectDraw has always been a bit lame. All it gives you, reliably, is a framebuffer. If the card could do any more high level processing (polygon drawing, certain kinds of hardware blting), it was pretty unlikely you'd ever get to use it.

Ya, it was (more or less) conceived of when all a video card could reliably do, was give you a framebuffer.

:)
 

Diffense

Member
Ecrofirt, directraw may very well be sufficient for what you are doing.

If all you're doing is a 2d game then all you need is access to the frame buffer and the ability to copy bits around. No need to burden yourself with 3d concepts in order to do simpe things.

If you need direct, unimpeded access to the frame buffer directdraw (of which 7 is the last version) is all you've got so I'd hardly call it obsolete.

Unfortunately, I can't help you directly with the VB stuff.
 

maharg

idspispopd
aaaaa0 said:
Ya, it was (more or less) conceived of when all a video card could reliably do, was give you a framebuffer.

:)

To be sure, but it's still really weird that no effort was ever put into making it more useful until they merged it with d3d, finally. I guess it just wasn't high priority enough.
 

aaaaa0

Member
Diffense said:
If you need direct, unimpeded access to the frame buffer directdraw (of which 7 is the last version) is all you've got so I'd hardly call it obsolete.

DirectDraw is obsolete. Everything that you can do with DirectDraw, you can pretty much do better with DX9.

If you just want CPU driven access to the frame buffer, just setup your swap chain, grab the back buffer from DX, LockRect(), and party on. (No you can't get access to the front buffer, but why would you want to? That would just cause flickering when you update anything.)

If you want to do something more sophisticated with sprites you can use ID3DXSprite if you want. It will handle all the state setting and stuff for you, and basically emulates 2D blits with 3D. As a side benefit, everything works much faster.

The only tradeoff is the code is a bit more complicated.

I still think he's better off just learning DX9.
 
Status
Not open for further replies.
Top Bottom