Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

aewarnick

Moving image around screen using glDrawPixels

This topic is 5381 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

How do I move an image around on the screen in the location of the mouse as the upper left corner. No need to go into getting mouse movement or coordinates. I just can''t figure out how to draw an image in a certain spot.

Share this post


Link to post
Share on other sites
Advertisement
First of all you probably shouldn't be using glDrawPixels because it is slow. Instead try using a textured quad and an orthographic projection (google glOrtho). If you don't know about textures then try the NeHe tutorials. Note that each side of a texture must be a power of two* (i.e. 256 by 32 is valid, 65 by 91 isn't). If your image is not a power of two on each side then pad it until it is and modify the texture coordinates to only display the part of the texture that contains your image.

Enigma

*except if you use one of the texture rectangle or non-power-of-two extensions.

EDIT: forgot my *.

[edited by - Enigma on February 7, 2004 11:47:58 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks for clarifying that drawpixels is slow. I thought it was while testing but now I know for sure.

Share this post


Link to post
Share on other sites
"modify the texture coordinates to only display the part of the texture that contains your image"

How do I do that when all I have to work with is 0.0 to 1.0?

[edited by - aewarnick on February 17, 2004 3:08:47 PM]

Share this post


Link to post
Share on other sites
I didn''t find anything I didn''t already know. They didn''t go into using images with erradicate sizes.

What is this about,
"*except if you use one of the texture rectangle or non-power-of-two extensions."?

Share this post


Link to post
Share on other sites
Nevermind, I found that someone else posted about this same kind of topic. He had a good point, if I pad the image it may take up 3 times as much space.

I guess I could split the image into many many textures but will there be a drawing speed hit because of looping?

Share this post


Link to post
Share on other sites
i have a question:

isn''t there any ability in opengl to draw something in 2d ? Like overlaying the output buffer. It seems to me that drawing something in 3d which will look like 2d is wasting resources.

Share this post


Link to post
Share on other sites
switch to ortho mode and draw like it is 2d, the added bonus is that this goes via the hardware 3d route and thus gets better accelration (same way DX does DirectDraw now i belive)

Share this post


Link to post
Share on other sites
Does looping through an image that is split into many textures slow down speen compared to drawing the whole image with one texture?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!