How to insert a picture on canvas using OpenGL (Java, JOGL)? Well, or at least not in Java ...
1 answer
Well, or at least not in Java.
But at least on OpenGL? ) The general idea is:
- Upload the image as an array of pixels. It strongly depends on the format in which you have the image. But, a suitable library can always be found ( Slick2D is suitable for Java).
Create texture in video memory.
glGenTextures(...);Bind these pictures to the texture.
glBindTexture(...); glTexImage2D(...);Draw a quad using the prepared texture.
glBegin(GL_QUADS); glVertex2d(0,0); glTexCoord2f(0, 0); glVertex2d(100,0); glTexCoord2f(1, 0); glVertex2d(100,100); glTexCoord2f(1, 1); glVertex2d(0,100); glTexCoord2f(0, 1); glEnd();
Shl. To find out what's what in OpenGL, I recommend a series of articles from NeHe .
|