Jump to content
  • Advertisement
Sign in to follow this  
Kwizatz

OpenGL Defining an blank texture

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

Is there a way in OpenGL to define a blank texture without having to create garbage data? In other words, is there an alternative to:
  unsigned char *data=new unsigned char[width*height*3];
  glTexImage2D(GL_TEXTURE_2D, 
	       0, 
	       3,
	       width,
	       height,
	       0,
	       GL_RGB, 
	       GL_UNSIGNED_BYTE,
	       data);
  delete [] data;

In order to then use glTexSubImage2D? Thanks in advance. [smile]

Share this post


Link to post
Share on other sites
Advertisement
The texture with id 0 should be blank (all white) by default. And your code would be a texture with garbage, not blank.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
The texture with id 0 should be blank (all white) by default. And your code would be a texture with garbage, not blank.


Yeah, I dont think you understood my question, what I need is to create a texture to which I can render (a video) over, I doubt I could call glTexSubImage2D on texture 0.

Share this post


Link to post
Share on other sites
While I dont see any backing for it in the specifications, I have seen people use 0 for their source data

glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);

not sure if this is very trustworthy tho, can anyone comfirm?

Share this post


Link to post
Share on other sites
yes, it is, supplying a NULL or zero value to the address tells the driver "make this texture object, I'll give it data later", which you can then do via either another glTexImage() call or via one of the other texture update functions (or even render to texture via FBO)

Share this post


Link to post
Share on other sites
Alright, Thanks, that makes sence, but didnt see it documented,I didnt wanted unexpected behaviour to pop up.

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!