Sign in to follow this  
Followers 0
saman_artorious

bind a bitmap raw data as texture to gl

5 posts in this topic

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.
0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

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  
Followers 0