OpenGL FAQ and Troubleshooting Guide

1 About the FAQ 13 Drawing Lines over Polygons and Using Polygon Offset
2 Getting Started 14 Rasterization and Operations on the Framebuffer
3 GLUT 15 Transparency, Translucency, and Blending
4 GLU 16 Display Lists and Vertex Arrays
5 Microsoft Windows Specifics 17 Using Fonts
6 Windows, Buffers, and Rendering Contexts 18 Lights and Shadows
7 Interacting with the Window System, Operating System, and Input Devices 19 Curves, Surfaces, and Using Evaluators
8 Using Viewing and Camera Transforms, and gluLookAt() 20 Picking and Using Selection
9 Transformations 21 Texture Mapping
10 Clipping, Culling, and Visibility Testing 22 Performance
11 Color 23 Extensions and Versions
12 The Depth Buffer 24 Miscellaneous

1 About the FAQ

1.010 Introduction

1.020 How to contribute, and the contributors

1.030 Download the entire FAQ as a Zip file

1.040 Change Log

2 Getting Started

2.005 Where can I find 3D graphics info?

2.010 Where can I find examples, tutorials, documentation, and other OpenGL information?

2.020 What OpenGL books are available?

2.030 What OpenGL chat rooms and newsgroups are available?

2.040 Are there OpenGL implementations that come with source code?

2.050 What compiler can I use to create OpenGL code?

2.060 What do I need to compile and run OpenGL programs?

2.070 Why am I getting compile, link, and runtime errors?

2.080 How do I initialize my windows, create contexts, etc.?

2.090 How do I create a full-screen window?

2.100 What is the general form of an OpenGL program?

2.110 My window is blank. What should I do?

2.120 My first frame renders correctly, but subsequent frames are incorrect or further away or I just get a blank screen. What's going on?

2.130 What is the AUX library?

2.140 What support for OpenGL does {Open,Net,Free}BSD or Linux provide?

2.150 Where is OpenGL 1.2?

3 GLUT

3.010 What is GLUT? How is it different from OpenGL?

3.020 Should I use GLUT?

3.030 I need to set up different tasks for left and right mouse button motion. However, I can only set one glutMotionFunc() callback, which doesn't pass the button as a parameter.

3.040 How does GLUT do…?

3.050 How can I perform animations with GLUT?

3.060 Is it possible to change a window's size *after* it's opened (i.e., after I call glutInitWindowSize(); and glutCreateWindow();)?

3.070 I have a GLUT program that allocates memory at startup. How do I deallocate this memory when the program exits?

3.080 How can I make my GLUT program detect that the user has closed the window?

3.090 How can I make glutMainLoop() return to my calling program?

3.100 How do I get rid of the console window in a Windows GLUT application?

3.110 My GLUT question isn't answered here. Where can I get more info?

4 GLU

4.010 What is GLU? How is it different from OpenGL?

4.020 How does GLU render sphere, cylinder, and disk primitives?

4.030 How does gluPickMatrix work?

4.040 How do I use GLU tessellation routines?

4.050 Why aren't my tessellation callback routines called?

4.060 How do I use GLU NURBS routines?

4.070 How do I use gluProject and gluUnProject?

5 Microsoft Windows Specifics

5.010 What's a good source for Win32 OpenGL programming information?

5.020 I'm looking for a Wintel OpenGL card in a specific price range, any suggestions?

5.030 How do I enable and disable hardware rendering on a Wintel card?

5.040 How do I know my program is using hardware acceleration on a Wintel card?

5.050 Where can I get the OpenGL ICD for a Wintel card?

5.060 I'm using a Wintel card and an OpenGL feature doesn't seem to work. What's going on?

5.070 Can I use OpenGL with DirectDraw?

5.080 Is it ok to use DirectDraw to change the screen resolution or desktop pixel depth?

5.090 My card supports OpenGL, but I don't get acceleration regardless of which pixel format I try.

5.100 How do I get hardware acceleration?

5.110 Why doesn't OpenGL hardware acceleration work with multiple monitors?

5.120 Why does my MFC window flash, even though I'm using double buffering?

5.130 What's the difference between opengl.dll and opengl32.dll?

5.140 Should I use Direct3D or OpenGL?

6 Windows, Buffers, and Rendering Contexts

6.010 How do I use overlay planes?

7 Interacting with the Window System, Operating System, and Input Devices

7.010 How do I obtain the window width and height or screen max width and height?

8 Using Viewing and Camera Transforms, and gluLookAt()

8.010 How does the camera work in OpenGL?

8.020 How can I move my eye, or camera, in my scene?

8.030 Where should my camera go, the ModelView or projection matrix?

8.040 How do I implement a zoom operation?

8.050 Given the current ModelView matrix, how can I determine the object-space location of the camera?

8.060 How do I make the camera "orbit" around a point in my scene?

8.070 How can I automatically calculate a view that displays my entire model? I know the bounding sphere and up vector.

8.080 Why doesn't gluLookAt work?

8.090 How do I get a specified point (XYZ) to appear at the center of the scene?

8.100 I put my gluLookAt() call on my Projection matrix and now fog, lighting, and texture mapping don't work correctly. What happened?

9 Transformations

9.001 I can't get transformations to work. Where can I learn more about matrices?

9.005 Are OpenGL matrices column-major or row-major?

9.010 What are OpenGL coordinate units?

9.020 How do I transform only one object in my scene or give each object its own transform?

9.030 How do I draw 2D controls over my 3D rendering?

9.040 How do I bypass OpenGL matrix transformations and send 2D coordinates directly for rasterization?

9.050 What are the pros and cons of using absolute versus relative coordinates?

9.060 How can I draw more than one view of the same scene?

9.070 How do I transform my objects around a fixed coordinate system rather than the object's local coordinate system?

9.080 What are the pros and cons of using glFrustum() versus gluPerspective()? Why would I want to use one over the other?

9.085 How can I make a call to glFrustum() that matches my call to gluPerspective()?

9.090 How do I draw a full-screen quad?

9.100 How can I find the screen coordinates for a given object-space coordinate?

9.110 How can I find the object-space coordinates for a pixel on the screen?

9.120 How do I find the coordinates of a vertex transformed only by the ModelView matrix?

9.130 How do I calculate the object-space distance from the viewer to a given point?

9.140 How do I keep my aspect ratio correct after a window resize?

9.150 Can I make OpenGL use a left-handed coordinate space?

9.160 How can I transform an object so that it points at or follows another object or point in my scene?

9.170 How can I render a mirror?

9.180 How can I do my own perspective scaling?

10 Clipping, Culling, and Visibility Testing

10.010 How do I tell if a vertex has been clipped or not?

10.020 How do I perform occlusion or visibility testing?

10.030 How do I render to a nonrectangular viewport?

10.040 When an OpenGL primitive moves placing one vertex outside the window, suddenly the color or texture mapping is incorrect. What's going on?

10.050 I know my geometry is inside the view volume. How can I turn off OpenGL's view-volume clipping to maximize performance?

10.060 When I move the viewpoint close to an object, it starts to disappear. How can I disable OpenGL's zNear clipping plane?

10.070 How do I draw glBitmap or glDrawPixels primitives that have an initial glRasterPos outside the window's left or bottom edge?

10.080 Why doesn't glClear work for areas outside the scissor rectangle?

10.090 How does face culling work? Why doesn't it use the surface normal?

11 Color

11.010 My texture map colors reverse blue and red, yellow and cyan, etc. What's going on?

11.020 How do I render a color index into an RGB window or vice versa?

11.030 The colors are almost entirely missing when I render in Microsoft Windows. What's happening?

11.040 How do I specify an exact color for a primitive?

11.050 How do I render each primitive in a unique color?

Удобный поиск авто с пробегом в автосалонах Москвы,стационарные офисные перегородки,Шкаф управления насосом,Каталог брюк, каталог красивых платьев - отто-онлайн.,Бильярдные столы,анатомия страсти,Быстрый поиск #авто с пробегом#

12 The Depth Buffer

12.010 How do I make depth buffering work?

12.020 Depth buffering doesn't work in my perspective rendering. What's going on?

12.030 How do I write a previously stored depth image to the depth buffer?

12.040 Depth buffering seems to work, but polygons seem to bleed through polygons that are in front of them. What's going on?

12.050 Why is my depth buffer precision so poor?

12.060 How do I turn off the zNear clipping plane?

12.070 Why is there more precision at the front of the depth buffer?

12.080 There is no way that a standard-sized depth buffer will have enough precision for my astronomically large scene. What are my options?

13 Drawing Lines over Polygons and Using Polygon Offset

13.010 What are the basics for using polygon offset?

13.020 What are the two parameters in a glPolygonOffset() call and what do they mean?

13.030 What's the difference between the OpenGL 1.0 polygon-offset extension and OpenGL 1.1 (and later) polygon-offset interfaces?

13.040 Why doesn't polygon offset work when I draw line primitives over filled primitives?

13.050 What other options do I have for drawing coplanar primitives when I don't want to use polygon offset?

14 Rasterization and Operations on the Framebuffer

14.010 How do I obtain the address of the OpenGL framebuffer, so that I might write directly to it?

14.015 How do I use glDrawPixels() and glReadPixels()?

14.020 How do I change between double- and single-buffered mode in an existing window?

14.030 How do I read back a single pixel?

14.040 How do I obtain the Z value for a rendered primitive?

14.050 How do I draw a pattern into the stencil buffer?

14.060 How do I copy from the front buffer to the back buffer and vice versa?

14.070 Why don't I get valid pixel data for an overlapped area, when I call glReadPixels where part of the window is overlapped by another window?

14.080 Why does the appearance of my smooth-shaded quad change when I view it with different transformations?

14.090 How do I obtain exact pixelization of lines?

14.100 How do I turn on wide-line endpoint capping or mitering?

14.110 How do I render rubber band lines?

14.120 If I draw a quad in fill mode and again in line mode, why don't the lines hit the same pixels as the filled quad?

14.130 How do I draw a full-screen quad?

14.140 How do I initialize or clear a buffer without calling glClear()?

14.150 How can I make line or polygon antialiasing work?

14.160 How do I achieve full-scene antialiasing?

15 Transparency, Translucency, and Using Blending

15.010 What is the difference between transparent, translucent, and blended primitives?

15.020 How can I achieve a transparent effect?

15.030 How can I create screen door transparency?

15.040 How can I render glass with OpenGL?

15.050 Do I need to render my primitives from back to front for correct rendering of translucent primitives to occur?

15.060 I want to use blending but can't get destination alpha to work. Can I blend or create a transparency effect without destination alpha?

15.070 If I draw a translucent primitive and draw another primitive behind it, I expect the second primitive to show through the first, but it's not there at all. Why not?

15.080 How can I make part of my texture maps transparent or translucent?

16 Display Lists and Vertex Arrays

16.010 Why does a display list take up so much memory?

16.020 How can I share display lists between different contexts?

16.030 How does display list nesting work? Is the called list copied into the calling list?

16.040 How can I do a particular function while a display list is called?

16.050 How can I change an OpenGL function call in a display list that contains many other OpenGL function calls?

16.060 How can I obtain a list of function calls and the OpenGL call parameters from a display list?

16.070 I've converted my program to use display lists, and it doesn't run any faster! Why not?

16.080 To save space, should I convert all my coordinates to short before storing them in a display list?

16.090 Will putting textures in a display list make them run faster?

16.100 Will putting vertex arrays in a display list make them run faster?

16.110 When sharing display lists between contexts, what happens when I delete a display list in one context? Do I have to delete it in all the contexts to make it really go away?

16.120 How many display lists can I create?

16.130 How much memory does a display list use?

16.140 How will I know if the memory a display list uses is freed?

17 Using Fonts

17.010 How can I add fonts to my OpenGL scene?

17.020 How can I use TrueType fonts in my OpenGL scene?

17.030 How can I make 3D letters that I can light, shade, and rotate?

18 Lights and Shadows

18.010 What should I know about lighting in general?

18.020 Why are my objects all one flat color and not shaded and illuminated?

18.030 How can I make OpenGL automatically calculate surface normals?

18.040 Why can I only get flat shading when I light my model?

18.050 How can I make my light move or not move and control the light position?

18.060 How can I make a spotlight work?

18.070 How can I create more lights than GL_MAX_LIGHTS?

18.080 Which is faster: making glMaterial*() calls or using glColorMaterial()?

18.090 Why is the lighting incorrect after I scale my scene to change its size?

18.100 After I turn on lighting, everything is lit. How can I light only some of the objects?

18.110 How can I use light maps (e.g., Quake-style) in OpenGL?

18.120 How can I achieve a refraction lighting effect?

18.130 How can I render caustics?

18.140 How can I add shadows to my scene?

19 Curves, Surfaces, and Using Evaluators

19.010 How can I use OpenGL evaluators to create a B-spline surface?

19.020 How can I retrieve the geometry values produced by evaluators?

20 Picking and Using Selection

20.010 How can I know which primitive a user has selected with the mouse?

20.020 What do I need to know to use selection?

20.030 Why doesn't selection work?

20.040 How can I debug my picking code?

20.050 How can I perform pick highlighting the way PHIGS and PEX provided?

21 Texture Mapping

21.010 What are the basic steps for performing texture mapping?

21.020 I'm trying to use texture mapping, but it doesn't work. What's wrong?

21.030 Why doesn't lighting work, when I turn on texture mapping?

21.040 Lighting and texture mapping work pretty well, but why don't I see specular highlighting?

21.050 How can I automatically generate texture coordinates?

21.060 Should I store texture maps in display lists?

21.070 How do texture objects work?

21.080 Can I share textures between different rendering contexts?

21.090 How can I apply multiple textures to a surface?

21.100 How can I perform light mapping?

21.110 How can I turn my files, such as GIF, JPG, BMP, etc. into a texture map?

21.120 How can I render into a texture map?

21.130 What's the maximum size texture map my device will render hardware accelerated?

21.140 How can I texture map a sphere, cylinder, or any other object with multiple facets?

22 Performance

22.010 What do I need to know about performance?

22.020 How can I measure my application's performance?

22.030 Which primitive type is the fastest?

22.040 What's the cost of redundant calls?

22.050 I have (n) lights on, and when I turned on (n+1), suddenly performance dramatically dropped. What happened?

22.060 I'm using (n) different texture maps and when I started using (n+1) instead, performance drastically dropped. What happened?

22.070 Why are glDrawPixels() and glReadPixels() so slow?

22.080 Is it faster to use absolute coordinates or to use relative coordinates?

22.090 Are display lists or vertex arrays faster?

23 Extensions and Versions

23.010 Where can I find information on different OpenGL extensions?

23.020 How will I know which OpenGL version my program is using?

23.030 What is the difference between OpenGL 1.0, 1.1, and 1.2?

23.040 How can I code for different versions of OpenGL?

23.050 How can I find which extensions are supported?

23.060 How can I code for extensions that may not exist on a target platform?

23.070 How can I call extension routines on Microsoft Windows?

23.080 How can I call extension routines on Linux?

23.090 Where can I find extension enumerants and function prototypes?

24 Miscellaneous

24.010 How can I render a wireframe scene with hidden lines removed?

24.020 How can I render rubber-band lines?

24.030 My init code calls glGetString() to find information about the OpenGL implementation, but why doesn't it return a string?

24.039 Where can I find 3D model files?

24.040 How can I load geometry files, such as 3DS, OBJ, DEM, etc. and render them with OpenGL?

24.050 How can I save my OpenGL rendering as an image file, such as GIF, TIF, JPG, BMP, etc.?

24.060 Can I use a BSP tree with OpenGL?

24.070 Can I use an octree with OpenGL?

24.080 Can I do radiosity with OpenGL?

24.090 Can I raytrace with OpenGL?

24.100 How can I perform CSG with OpenGL?

24.110 How can I perform collision detection with OpenGL?

24.120 I understand OpenGL might cache commands in an internal buffer. Can I perform an abort operation, so these buffers are simply emptied instead of executed?

24.130 What's the difference between glFlush() and glFinish() and why would I want to use these routines?

24.140 How can I print with OpenGL?

24.150 Can I capture or log the OpenGL calls an application makes?

24.160 How can I render red-blue stereo pairs?