OpenGL FAQ & common errors by Martin "xarragon" Persson Version 1.00, published 2006-03-29 Q: When I use lighting in my program, the light levels change drastically as I look around in the scene. What is wrong? A: You are probably setting the lights positions before the modelview matrix has been properly set up. The light's position coordinates are transformed as any other geometric primitive. What many new programmers do is to specify the lights parameters before the "camera transformation" is applied. This error is pretty common since many games use two main functions, "update" and "draw", and the light properties are typically set in "update()", and then the camera transformation is applied after, in the "draw()" function. The consequences are either the weird, shifting lighting mentioned above (the light coordinates are transformed using the default identity matrix, since the user reset this matrix for the new frame), or a more subtle error, where the lighting calculations are based on the previous frame's modelview matrix. Q: How are the texture parameters related to the texture objects? Do I set them once for all textures, or are they applied for each texture individually? A: The texture parameters are bound to the texture you specify at this ID, (it's referred to as a 'texture object'). This means that you can have different parameters for different textures, which leads us to the next question in this FAQ... Q: I get thin outlines and lines on my textures, it looks ugly on my HUD/ sprites/2D graphics! What is this!? A: This error is common when you use interpolating filtering (anything but GL_NEAREST) and mip-mapping in combination with repeating wrapping mode. Is commonly seen with HUD graphics and texture-based fonts. The error stems from the fact that the filtering process used by OpenGL creates a value for a pixel based on an averaged sample of the closest pixels on the texture. If repeating wrapping mode is used (GL_REPEAT), the result of the filtering process will be based on the texels on the opposite side of the texture, since this is how wrapping works. The solution is to only use wrapping where necessery, typically NOT for HUD graphics (there are exceptions of course). Mipmapping shouldn't really be used here either. Use GL_CLAMP or GL_CLAMP_TO_EDGE for these textures.