Hello everyone, I've done some research on DirectX, and basically this is how I understand what I found:

1. The CreateDirectDrawEx API returns a pointer to an 'Interface'. This interface is a 'COM object' whose first element is a pointer to a 'vtbl'.
2. This 'vtbl' is a table of pointers to different functions for DirectDraw.
3. Therefore, CreateDirectDrawEx returns a pointer, to a pointer ('Interface'), to a table of function pointers ('vtbl').
4. The ordering of the functions in the table, as well as their required arguments, can be seen in any asm DirectX include file. In fact there are macros built called STD_METHOD which parallel a typedef in C++?

Please tell me if my understanding of these are correct.

Also, I've also found some references to 'OpenGL', which, I believe, is a 3d graphics library. I've found some references which say that DirectX is more difficult than OpenGL, however I also read some pages that say that as of DirectX 7, DirectX is as easy as/almost as easy as/easier than OpenGL.

Since as I understand it, OpenGL is limited to 3d graphics only, if I wanted to have an easier time developing a game's other features (input, multiplayer games) I may as well stick to DirectX since it supports such features via DirectInput and DirectPlay. I wonder if it is at all practical/possible to use OpenGL for graphics and DirectX for other things?

I'm also wondering what vertices are? Are they a point in 3d space?

Also, what components of DirectX are needed? I have found a site on MSDN that has components of DirectX, I wonder which components I would need for DirectX asm programming?

Do I need the 'SDK components' http://msdn.microsoft.com/downloads/sample.asp?url=/MSDN-FILES/027/001/770/msdncompositedoc.xml
or will the SDK download suffice?
http://msdn.microsoft.com/downloads/sample.asp?url=/MSDN-FILES/027/001/771/msdncompositedoc.xml
Posted on 2002-12-09 19:53:49 by AmkG
I haven't looked at that api but you get a pointer to the vtable which is the interface. The vtable contains the pointers to the functions, implementations, of that interface. The first 3 entries of the vtable are queryinterface, AddRef and the other one (I forgot).

If you look in the .h files for C++ you'll find the struc's for the vtables. The functions are in the order of the vtable starting with QueryInterface. You might find yours in d3d8.h I think.

OpenGL vs DirectX has been open to argument lately. OpenGL is a helluva lot easier than DirectX but I feel DirectX is closer to the hardware, almost like asm. But the arguments over which runs faster. I hear it doesn't matter and you can see most games use both. But you can't do pixelshaders in OpenGL (can you?). DirectX is easier to program than it used to be but not as easy as OpenGL.

OpenGL is an API. I don't think it's 3d only (and this coming from a former SGI employee :( )

Once you get the hang of DirectX you'd probably do OK but there is a learning curve.

Vertices is plural for vertex, a 3d point in space represented as xyz.

The SDK will suffice if you don't call Win APIs. But DirectX is part of Windows so.....
Posted on 2002-12-09 20:21:29 by drhowarddrfine
OpenGl is 3D API only.

You can mix DirectInput and DirectSound with OpenGl.

OpenGl has pixel and vertex shader (vertex programs and fragment programs).

And you don't need huge SDK.

Toni
Posted on 2002-12-10 00:31:18 by minimoog

Does OpenGL have the capability to render on a texture, which will then be used to render a scene (or on another texture)?
Posted on 2002-12-10 03:07:30 by Maverick


Does OpenGL have the capability to render on a texture, which will then be used to render a scene (or on another texture)?


Yes it has.

ARB_render_to_texture extension

http://oss.sgi.com/projects/ogl-sample/registry/ARB/wgl_render_texture.txt

and

ARB_pbuffer extension

http://oss.sgi.com/projects/ogl-sample/registry/ARB/wgl_pbuffer.txt
Posted on 2002-12-10 06:06:01 by minimoog

Yup but is this extension supported on ~all Win32 drivers?
Posted on 2002-12-10 06:08:02 by Maverick
Well, I don't know.:)

You can check if this extensions is supported with glGetString (GL_EXTENSIONS) or with wglGetExtensionsStringARB.

Toni
Posted on 2002-12-10 09:04:10 by minimoog
Here is a online database for gl extensions, yo can check what card/driver supports particular extension...

http://www.delphi3d.net/hardware/index.php

Toni
Posted on 2002-12-10 09:30:09 by minimoog
Thanks everyone.


OpenGl is 3D API only.


Ah I see...


You can mix DirectInput and DirectSound with OpenGl.

OpenGl has pixel and vertex shader (vertex programs and fragment programs).


Ah... so DirectX doesn't have those? (Okay I'll admit I haven't managed to understand what these are exactly... how are they different from Gouraud and Flat shading? Are Gouraud and Flat shading just two examples of shaders?)



And you don't need huge SDK.

Toni


Ah I see... so I don't need anything from MSDN other than a help file for DirectX, maybe? Gotta start looking at some nice sources from scrontsoft...
Posted on 2002-12-13 01:11:00 by AmkG

Thanks everyone.
Ah... so DirectX doesn't have those? (Okay I'll admit I haven't managed to understand what these are exactly... how are they different from Gouraud and Flat shading? Are Gouraud and Flat shading just two examples of shaders?)


No, DirectX has them also...Vertex and fragment programs are just, ahem, programs, written in some special kind of assembly language. For vertex programs, input is vertex, output is vertex, for fragment programs, input is fragment output is pixel. THey allow programmable 3d graphic pipeline. Brief explanation only...Before vertex and fragment programs 3d pipeline was fixed (vertex must be transformed by modelview matrix, then projection matrix e.t.c)...You can say that Gouraud and Flat shading is example of shaders...


Ah I see... so I don't need anything from MSDN other than a help file for DirectX, maybe? Gotta start looking at some nice sources from scrontsoft...


I don't know about this...
Posted on 2002-12-13 03:29:19 by minimoog
Afternoon, AmkG.

I only have examples on DX8/8.1 (and only on DirectX Graphics - not DInput/DAudio/etc).
Nothing on OpenGL.
Nothing on DDraw or < DX8 API.

Cheers,
Scronty
Posted on 2002-12-13 04:00:28 by Scronty
Flat shading is when the lighting for a surface plane is continuous, the same, across the plane's surface.

Gourard shading computes the lighting at the corners of the surface and interpolates them across the flat plane allowing a gradient change across it.

So if you look at a floor lit by a lamp at one end, the floor would have equal brightness all over. With Gourard the light would gradually taper off toward the far corners. Gourard and Phong shading are much more compute intensive.
Posted on 2002-12-13 08:08:57 by drhowarddrfine
Thanks again everyone,

I think I may have read about those shader thingies... those little bits of 'code' which aren't real programs, but are interpreted by DirectX?

What I'm wondering now is how to combine a bit of 2d graphics on Direct3D 8. It is my understanding that on DirectX 7, since you need DirectDraw to get Direct3D, you can render the Direct3D scene then use DirectDraw to overlay some 2d graphics. As far as I know on DirectX 8 it seems you no longer need DirectDraw? So how would I put 2d graphics? Would there be some way to get the DirectDraw object used by Direct3D so I can put 2d stuff?

Anyway I've found a dxfound.chm file over the 'net that contains info on DirectX 7... I wonder if there's a version for DirectX 8? Would it have the same filename or different? I found a file called 'directx8_c.chm' over the 'net that contains info on DirectX8.
Posted on 2002-12-13 23:03:09 by AmkG
Posted on 2002-12-14 02:20:57 by Maverick
I've been concentrating so much on 3d lately for a project I can't comment about any special 2d stuff. But remember that 2d is 3d minus one dimension. So you can draw a 2d line by just setting the z to 0.
Posted on 2002-12-14 16:49:47 by drhowarddrfine
Afternoon, AmkG.
What I'm wondering now is how to combine a bit of 2d graphics on Direct3D 8.


Have a look at Microsofts' Vertice example (it's their Tutorial #2).

What you do is:
Make a quad vertex buffer (four vertices with texture coords), and slap whatever 2d image you want over it.
To render this, you make each vertice the equivalent to a point on the screen.
i.e. if your window/screen is 800X600 then the vertices would be <0.0f, 0.0f, 0.0f>,<0.0f,600.0f, 0.0f>,<800.0f, 0.0f, 0.0f><800.0f, 600.0f, 0.0f>
Then just render as a triangle-strip.

Oh...
Obviously you'd want transparent areas within that texture overlay, so use a colour (probably 255,0,255) as the transparent colour, and enter that colour value for the "colorkey "when the texture is loaded in (see D3DXCreateTextureFromFileEx).

Cheers,
Scronty
Posted on 2002-12-14 18:24:01 by Scronty
So if, for instance, I want to overlay some little icons on the screen, I draw the icons into a bitmap, set the bitmap as a texture to a triangle-strip that's the size of my screen, then render?

Dang.... sounds simple... would DirectX be intelligent enough to know that when z=0 it doesn't have to do any potentially slow 3d graphics stuff? (yeah, probably, ne? I just wanna assure myself...)

Thanks Scronty.
Posted on 2002-12-14 18:38:53 by AmkG
Afternoon, AmkG.

...potentially slow 3d graphics stuff


ummm...
A slight bit of confusion seems to be here.

With modern vid cards, the 3d is accelerated (if used correctly).

The idea is to load a texture into vid mem (i.e. a texture you won't be modifying).

What I gave in my previous post, is what you'd do to display an image over the entire screen.
If you're wanting to just have "icons" displayed, then you do something similar to what's happening in the CD3DFont class (in the Microsoft "common" directory).
Each "icon" has its own vertexbuffer. That vertex buffer has texture coords offset into the texture (so you could have multiple icons inside the same 256x256 bitmap)

You can also do animations, by having an "icon"s vertex buffer cover multiple offsets into the image, and just iterate through them when rendering.

The idea is that, if you specify D3DFVF_XYZRHW for your CUSTOMVERTEX, then DX assumes that the vertices have already been transformed.

Cheers,
Scronty
Posted on 2002-12-14 20:07:24 by Scronty
would DirectX be intelligent enough to know that when z=0 it doesn't have to do any potentially slow 3d graphics stuff?


I still haven't taken the time to look at the docs to see about 2d but DirectX, generally, is executed in hardware. So setting z to 0 doesn't change how the api is executed. How the 2d apis and 3d apis, if there is such a thing, differ in speed, I don't know. But I'd bet there isn't a difference when drawing a line.
Posted on 2002-12-14 22:42:10 by drhowarddrfine
Actually I need some sort of control panel overlaid on a 3d scene, possibly with some little icons pointing to specific objects...

I would like to draw the control panel directly with my program, then put the panel on-screen somewhere. The contents of the panel would change as time passes, I'm wondering how to do this?



With modern vid cards, the 3d is accelerated (if used correctly).

Tee hee hee I gues I'm not thinking very modernly!!! :) :grin: :grin:


The idea is that, if you specify D3DFVF_XYZRHW for your CUSTOMVERTEX, then DX assumes that the vertices have already been transformed.



Okay... I did a (very) little bit of experimentation using XYZRHW... it *appears* that the Z is ignored... no matter how I change z nothing *seems* to happen, even though the documentation specifies that it should be within 0.0 to 1.0. I *think* the Z here would be used only for z-buffering? So if two things intersect the one with lower z gets drawn?

I presume, anyway, that I can use several different CUSTOMVERTEX formats? So maybe I can have DirectX perform the 3d stuff with a D3DFVF_XYZ CUSTOMVERTEX, then I can perform some 2d stuff with D3DFVF_XYZRHW?

Anyway through my ramblings in the documentation, I found something called 'Surfaces'... I wonder if I could render a 3d drawing after BeginScene, then GetBackBuffer (which returns me a IDirect3DSurface8), lock the surface and draw some 2d stuff, after which, I then 'Present' the back buffer. Would this be feasible? Efficient? Optimal?

Anyway thanks lots Scronty.
Posted on 2002-12-20 02:50:47 by AmkG