Sign in to follow this  

about 2d in OpenGL and Direct3D9

This topic is 3497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a windowed app and I have to draw into it using Direct3D9 or OpenGL. I don't have to draw 3d meshes, just 2d images. Anyway I have to be sure that i can draw things in pixel boundaries. I don't want to use float coordinates, just integer coordinates that specify pixels in the client area of the window. What I have to do is to emulate what GDI does but using these 2 APIs. I don't want to use blitting operations on surfaces (like glCopyPixels or d3ddev->UpdateSurface ecc.) because they are slow. I'd like to use geometry and textures. Is there a way to realize that? Thanks!

Share this post


Link to post
Share on other sites
In D3D you can use ID3DXSprite which should make things relatively easy for you. It basically allows you to specify a texture and a screen-space position and it will draw it for you. It can also handle things like rotation and scaling if you need it as well.

Share this post


Link to post
Share on other sites
for mjp:
I know about the D3DXSprite interface...but it takes a D3DXVECTOR3 structure to represent the position of the sprite. It is the defined with 3 floats representing the x, y and z coordinates. Can I be sure that specific pixels can be selected using floats?

for fpsgamer:
How can I provide integer coordinates in Direct3D9 and OpenGL?

Thanks!

Share this post


Link to post
Share on other sites
Quote:
Original post by ZeroMemory
How can I provide integer coordinates in Direct3D9 and OpenGL?


You don't have to do anything special to supply integer coordinates.

In OpenGL, using any of the immediate mode functions will produce the exact same effect:

glVertex2i(2, 3);
glVertex2s(2, 3);
glVertex2f(2.0f, 3.0f);
glVertex2d(2.0, 3.0);
etc.

What is important is that you create your projection and view port appropriately such that 1 unit will map to 1 pixel on the screen.

Share this post


Link to post
Share on other sites

This topic is 3497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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