Jump to content

  • Log In with Google      Sign In   
  • Create Account

bind a bitmap raw data as texture to gl


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 saman_artorious   Members   -  Reputation: 145

Like
0Likes
Like

Posted 12 November 2013 - 06:54 AM

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.

Sponsor:

#2 haegarr   Crossbones+   -  Reputation: 4311

Like
0Likes
Like

Posted 12 November 2013 - 06:59 AM


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, 12 November 2013 - 07:08 AM.


#3 N.I.B.   Members   -  Reputation: 1194

Like
1Likes
Like

Posted 12 November 2013 - 07:06 AM

There you go - http://ogldev.atspace.co.uk/www/tutorial16/tutorial16.html



#4 aqrit   Members   -  Reputation: 119

Like
0Likes
Like

Posted 12 November 2013 - 10:52 AM

I just started with OpenGL...

but I wrote this as a demonstration of uploading a image to a texture.

http://bitpatch.com/downloads/glTex_example.cpp



#5 saman_artorious   Members   -  Reputation: 145

Like
0Likes
Like

Posted 16 November 2013 - 12:01 AM

this shows how to bind an image to texture and not a bitmap.



#6 N.I.B.   Members   -  Reputation: 1194

Like
0Likes
Like

Posted 16 November 2013 - 01:15 AM

There you go - http://ogldev.atspace.co.uk/www/tutorial16/tutorial16.html

this shows how to bind an image to texture and not a bitmap.
The same, except he loads an image from disk and you already have it in memory.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS