Library/OpenGL
From Athile
< Library
Contents |
GLSL Notes
- Unused uniforms will be eliminated from the linked program; getUniformLocation on such a uniform should return -1.
Migrating to OpenGL 3.2 Core
GL_QUADS has been removed. What do I do?
Rumor is that the driver (i.e. software) converts all quad data to triangle data before it is uploaded to the card.
Therefore, if that is in fact true, doing the conversion from quads to triangles yourself in software before the glBindBuffer calls should be equivalent.
GL_ALPHA_TEST and glAlphaFunc() are gone. What do I do?
It's trivial to reimplement this in the shader:
if (uniform_my_alpha_test && color.a < uniform_my_threshold) discard;
How do I...
Read back a texture?
Snippet from debug code for reading back a DDS (note: it doesn't matter what the internal format is) and saving to disk using LxEngine's save_png:
static void _dumpTextureToDisk(GLuint id) { #ifdef _DEBUG static int count = 0; int w, h; glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); glgeom::image3f image(w, h); glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT, image.ptr()); lx0::save_png(image, boost::str( boost::format("dds_texture_%04d.png") % (count++) ).c_str()); #endif }
...pass per-primitive data to a GLSL geometry shader?
- Example: pass flags on a face to indicate whether the face should be flat-shaded or smooth-shaded
See gl_PrimitiveIDIn g.