Jump to content
  • Advertisement
Sign in to follow this  
Floating

OpenGL How to display a picture without textures?

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

Hi, I'd like to display a flat picture in my opengl window (the picture won't get turned, it is facing you) without using textures if possible. The fact is that I have the picture stored like that: unsigned char* picture[320*200*3]; and the content is changing 10 times a second. How would you do that? Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
glDrawPixels may be what you're looking for. What keeps you from using a textured quad and pushing that to the screen? Are you dynamically updating the picture map? Is it possible for you to use a set of pre-computed textures to simulate the animation or is it unpredictable animation? glDrawPixels is probably the right solution, but you may run into performance problems (not likely with only 320x200)

Share this post


Link to post
Share on other sites
The quickest solution is still likely to be using a texture and updating it with glTexSubImage2D. I have a software renderer demo on my site which uses OpenGL simply to transfer the colour buffer to the screen, and I found this approach to be much faster than glDrawPixels on my hardware. The source is included if you want to experiment with it.

Share this post


Link to post
Share on other sites
If you really don't want a texture, you can create an array of points, and draw them on the screen using GL_POINTS.

Disclaimer: This is a joke, don't do it if you care for the performance.

Share this post


Link to post
Share on other sites
It is faster to update a texture and draw a quad with that texture, than to use DrawPixels. It sounds weird, but it's true.

Create a 512x256 texture, and use TexSubImage to load the lower-left corner of the texture with your data, and use the appropriate texture coordinates for your quad (0 - 320/512, 0 - 200 / 256).

Share this post


Link to post
Share on other sites
Thanks for all the replies :)

How come I can't find the command glTexSubImage2D in my documentation?

Would I use textures, don't I have to do following over and over?

Free the old texture
glGenTextures(1,&retVal);
glBindTexture(GL_TEXTURE_2D,retVal);
glTexImage2D(GL_TEXTURE_2D,0,3,sizeX,sizeY,0,GL_RGB GL_UNSIGNED_BYTE,image);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

Doesn't that take a lot of time?

Share this post


Link to post
Share on other sites
Quote:
Original post by Floating
Thanks for all the replies :)

How come I can't find the command glTexSubImage2D in my documentation?

Would I use textures, don't I have to do following over and over?

Free the old texture
glGenTextures(1,&retVal);
glBindTexture(GL_TEXTURE_2D,retVal);
glTexImage2D(GL_TEXTURE_2D,0,3,sizeX,sizeY,0,GL_RGB GL_UNSIGNED_BYTE,image);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

Doesn't that take a lot of time?


Thats the whole point of using glTexSubImage2D, so you dont have to recreate the texure each time.

Link 1

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!