Sign in to follow this  
ed209

pixel

Recommended Posts

1. Define a vertex format
2. Create a vertex and vertex buffer
3. In your render loop, set the vertex buffer appropriately
4. In DrawUserPrimitive(), set the primitive type to D3DPT_POINTLIST

Share this post


Link to post
Share on other sites
Quote:
Original post by ed209
how do I draw a single pixel onto the screen?
By issuing a series of commands to the graphics API.

A more serious answer would be:
What language? What DirectX version? What API (D3D or DDraw)? Why do you want to draw a single pixel? Do you want to draw it once, or every frame? Do you want to only ever draw 1 pixel, or will you want to call your DrawPixel() function several times per frame? Are you sure you want to draw a pixel and not a more complex shape like a textured triangles?

Share this post


Link to post
Share on other sites
I'm using managed directx for vb and I want to eventually be able to make a chip-8 emulator with it, so I will probably have to know how to draw pixels to the screen.

Share this post


Link to post
Share on other sites
For my emulators, I have a 32-bit texture made to the resolution of the screen and an equally sized 2D array or integers. When the system draws something it sets the array. For each frame I just lock the texture, write the whole array to it and the draw the whole texture across the screen.

Quote:
Original post by u235
1. Define a vertex format
2. Create a vertex and vertex buffer
3. In your render loop, set the vertex buffer appropriately
4. In DrawUserPrimitive(), set the primitive type to D3DPT_POINTLIST


Quote:
Original post by ed209
Couldn't I just make a sprite of size 1x1 and change the color when necessary or would that be stupid?


Both of these would be so slow, you'd fall asleep at the keyboard.

Share this post


Link to post
Share on other sites
Why use DirectX for something so simple? A DIB and BitBlt would more than suffice for what you are doing. Just make sure it's double-buffered to avoid flicker. You won't be able to sync to the vertical retrace, so you may get some shear, but I don't imagine that having any great effect on the type of display you're going to have.

Share this post


Link to post
Share on other sites
I'd go GDI+ only if you're going to keep it in windowed mode. If you want to be able to switch between fullscreen and windowed then I'd use DirectX.

In either situation the high performance method is to create a bitmap/texture, lock/unlock it once per frame, and write pixels to it as if it were an integer array using pointer access (not sure what VB supports as far as that goes but C++ and C# will let you do extremely high speed access in this manner).

Share this post


Link to post
Share on other sites
Quote:
Original post by ravyne2001
Why use DirectX for something so simple? A DIB and BitBlt would more than suffice for what you are doing. Just make sure it's double-buffered to avoid flicker. You won't be able to sync to the vertical retrace, so you may get some shear, but I don't imagine that having any great effect on the type of display you're going to have.


Yea, bitblt would have way too much tear.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this