Skip to main content
gamedev.net
🔒 Locked

Pixel question

Started by Eric Burnett Feb 18, 2005 at 1:09 AM 5 replies 1.1k views
Original Post
Eric Burnett
Eric Burnett
I have been learning directX 9 for a while, but I have come across a problem. I want to have an area of the screen that I can just draw the pixels, without needing a million verticies of different colors, or anything else. Either that or two triangles, that I can just mess with the texture dynamically. I am not sure how I should get this done. Should I be learning the directDraw 7 api and using it concurrently with dx9, or use it exclusively, or something else entirely? A little guideance would be appreciated.
--Eric Burnett I know I have mnemophobia, but I can't remember what it is.
Sneftel
Sneftel
The standard way to do this is to load the image as a texture and draw it on as a quad (or two triangles). IIRC, there's an ID3DXSprite class that'll do this stuff for you, but really it doesn't abstract much out (and many people have reported that it has suboptimal performance).

You should certainly *not* try to use DD7 concurrently with D3D9. It was tossed out (ahem, "deprecated") because 3D acceleration has superseded 2D acceleration, and isn't really appropriate for any but the most niche of applications.
Muhammad Haggag
Muhammad Haggag
Quote:
Original post by Sneftel
IIRC, there's an ID3DXSprite class that'll do this stuff for you, but really it doesn't abstract much out (and many people have reported that it has suboptimal performance).

IIRC, the performance complaints were about the DX8 version. The DX9 ID3DXSprite works pretty well.

Eric Burnett
Eric Burnett
Sneftel, Does the ID3DXSprite let you generate a texture dynamically? Because I thought with loading a texture onto a quad you had to have it already created, as a file or something.

What I'm trying to do is generate fractals, based on user data. As they change the input, the fractal should change accordingly. It would be nice to do it in a dx framework, but the easiest way to do it (blit to the screen or a texture) I cannot figure out how to do.
--Eric Burnett I know I have mnemophobia, but I can't remember what it is.
Agony
Agony
Given a texture object, the method is to call ->LockRect(...) on the texture. This gives you a pointer to the actual pixel memory (of the specified surface of the texture, if it is a mipmapped texture), as well as a pitch value (width in bytes of each scanline, to compensate for any padding at the end of each line). You can then edit these pixels to your heart's content, and then when you're done, call ->UnlockRect(). It helps performance if you create the texture using D3DUSAGE_DYNAMIC. It might be hard to get high frame rates if you're doing a lot of stuff all at the same time as this, but 3D hardware isn't explicitly designed for accelerating manual pixel drawing anyway.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas nly, and not for things themselves." - John Locke o
DrunkenHyena
DrunkenHyena
Quote:
Original post by Agony
It helps performance if you create the texture using D3DUSAGE_DYNAMIC.

Not all cards support DYNAMIC textures, if they aren't supported a normal texture in the Managed pool is quite usable.

I've done a number of old demo effects (fire, plasma, etc) in D3D9 and it works pretty well as long as your texture isn't too big. You can often get away with a significantly smaller texture and use bilinear filtering to stretch it to the needed size when you render it. It'd give you a nice smooth fractal, assuming that's acceptable for what you're doing.

Stay Casual,KenDrunken Hyena</FON
Eric Burnett
Eric Burnett
Thanks guys. That makes more sense now. I knew there had to be a way, but I just didn't know what it was. It will only need to be locked/unlocked when it is scrolled, zoomed, or modified in some way, so there should be no problem with speed. I'l let you know if there are any more problems ;).
--Eric Burnett I know I have mnemophobia, but I can't remember what it is.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.