JOGL image rendering
Thanks for reading my question.
The end goal is to be able to render images of arbitrary sizes in JOGL and
do it fast on basic graphic cards.
My initial attempt was to achieve this using textures. However, I ran into
problems on some graphics cards, (more precisely, virtual machine graphics
cards).
Some images exceed the GL_MAX_TEXTURE_SIZE and if the card does not
support textures which are not power of two (gl.isNPOTTextureAvailable())
I then followed several (1, 2) samples which used glDrawPixels to render
the image directly.
gl.glBlendFunc (GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glEnable (GL.GL_BLEND);
gl.glColor3f (0.0f, 0.0f, 0.0f);
gl.glRasterPos2i (10, 300);
gl.glDrawPixels (dukeWidth, dukeHeight,
gl.GL_RGBA, gl.GL_UNSIGNED_BYTE,
dukeRGBA);
This works fine, except when the raster position moves outside the
viewport. When part of the image (bottom left corner) goes outside the
viewport, the whole image is not displayed.
[1] https://today.java.net/pub/a/today/2003/09/11/jogl2d.html
[2]
http://www.java-tips.org/other-api-tips/jogl/drawing-pixels-and-showing-the-effect-of-gldrawpixels-glcopypixels-and-glpix.htm
I have managed to solve the image disappearing problem by replacing
glRasterPos2i with glWindowPos2d but again this lead to another problemn -
glWindowPos2d is only supported from openGL 1.4 and my virtual machines
only support 1.1.
What is wrong with my approach?
Should I be handing images which are non-power size by padding textures?
Should I split large images into many textures (like a quilt) so that
maximum texture size in not exceed? worried about performance in this
case.
Tried Mesa3D to ensure obtain a higher openGL version, but cannot make it
compile for windows. Any other software renderers recommended? (waiting on
Swiftshader support)
Any help greatly appreciated.
No comments:
Post a Comment