Direct X 9.0 Interfaces

Started by
5 comments, last by Guimo 19 years, 6 months ago
I have been working on a breakout game with the ID3DXSPRITE interface of Direct X 9.0 Has anyone had any luck with the ID3DXLINE interface or just has any ideas on how to draw a single pixel on the screen? The SPRITE interface let's you put entire bitmaps on the screen, and that's great, I love it! But I don't want to make pixel sized bitmaps and load them in... I've read a lot of Andre LaMothe's books, but Direct X 9, can you still access the Video Memory directly and write and erase pixels? Like you could in Direct X 7 ?? I've got a working demo of my program that works on your machine if you've got Direct X 9 and a 3D Video Card. I'm looking to add a cool Title Screen, but I need to draw simple lines and individual pixels to the Video Memory Buffers. I'm also learning to work with Assembly Language with C++ environment using the inline assembler for Visual C++.NET Any help would be appreciated, thanks in advance! Jeff the mad programming man.
Jeff Cummings
Advertisement
You can directly access a back buffer in DirectX9, but doing so incurs a major performance hit.

Basically, you first have to set a couple of field in your D3DPRESENT_PARAMETERS structure, which you used when you created your IDirect3DDevice9 interface. The fields to set are:

D3DPRESENT_PARAMETERS d3dpp;d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;d3dpp.BackBufferCount = 1;... Other setup ...CreateDevice(...);


Then you will have to get the back buffer using your IDirect3DDevice9 interface, calling the GetBackBuffer(...) function. This will return a pointer to an IDirect3DSurface9 which you can then edit individual pixels on. As far as I remember, www.32bits.co.uk has some tutorials on doing this.

Like I said though, this will massively lower performance, slowing your game down significantly.

A much better way would be to learn about rendering vertices, 3D style. If you look in the DirectX SDK, there are some tutorials showing you how to render a triangle using transformed (2D) vertices. If you change the D3DPT_TRIANGLELIST to D3DPT_POINTLIST (in the DrawPrimitive() function), you will get just pixels on the screen, or using D3DPT_LINELIST will give you lines. This is a whole lot better than manually writing pixels, even if it may be harder to get to grips with.
Life is all about expression, so express yourself.
Thank you, I'm sure that site will be very helpful. I will have a look at that, the guy who put it up, seems like my kind of programmer!!!

Anyways, also I tried using the ID3DXLINE interface, and it locked up my computer, just in the initialization of the interface, so code inside the init and shutdown using it, have you tried using that interface? Just curious.

Also, I would probably prefer to use transformed vertices and use the POINT_LIST type that you suggested. I will work on this for the next week or so...I code at work and at home in my spare time.

I'll let you know how I progress, and put up some code that I manage to get working.

Later,

Jeff
Jeff Cummings
To be honest, I hadn't even heard of ID3DXLINE before you mentioned it! If you post the bit of code your using to initialise the interface, myself or someone might be able to help. At a guess, assuming your using D3DXCreateLine(), either the device your passing to the function isn't initialised, or your not passing the LPD3DXLINE interface properly.

It could be something else, but as i said I have never used it before.
Life is all about expression, so express yourself.
I have and it is flakey - I stopped using it and rolled my own eventually - too buggy. Of course it may have been fixed in 9.0c
------------------------See my games programming site at: www.toymaker.info
Trip99, did you actually get the interface methods to work? I've got the program to compile, and set things up, but none of the methods will work, and when I execute my code, the computer locks up and connects to microsoft to report the error...

I've given up hope for the ID3DXLine interface, and am moving on to the dreaded transformed vertices, my goal is to output lines and points of any color, without the 3D transform.

Anyways, if you got the ID3DXLine interface to work, would you mind sharing your code?

Thanks,

Jeff
Jeff Cummings
Read this article, it has the basics about sprite rendering.
http://www.mvps.org/directx/articles/blit3d.htm

After you read it, you will understand how Transformed Lit vertices work.

Finally, create many TL vertices in an array render them as POINT_LIST (not as QUADS)

Luck!
Guimo

This topic is closed to new replies.

Advertisement