Jump to content
  • Advertisement
Sign in to follow this  
saman_artorious

bind a bitmap raw data as texture to gl

This topic is 2074 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 am receiving a bitmap of size 800 by 600 with RGB 24 bits. When I receive this bitmap from the other machine, I need to bind it to gl widget.
what crossed my mind is to do the following, however I am not quite sure if it is correct:

    initializeGLFunctions();

    GLuint vboId;

    glBindBuffer(GL_ARRAY_BUFFER, vboId);

    glBufferSubData(GL_ARRAY_BUFFER, 0, 800 * 600 * 3 * sizeof(int), &buffer[0]);

    glBindBuffer(GL_ARRAY_BUFFER, 0);

is this the right way to bind bitmap to gl?
I would also thank if you mention how to declare the vboId in the second line.

Share this post


Link to post
Share on other sites
Advertisement

is this the right way to bind bitmap to gl?

Nope. You're creating a vertex buffer with that but want to create a texture. Try out "tutorial opengl texture mapping" in your favorite search engine.

 

The terms of interest are: glGenTexture, glBindTexture, glTexParameter, glTexImage2D, and companions. However, You need some geometry (a rectangle would be sufficient in your case) to map the texture onto the screen, for which purpose a vertex buffer can (better: should, nowadays) be used.

Edited by haegarr

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!