how to see the 3d image in an opengl output [closed]
i was reading opengl superbible, they were telling i can use the arrow keys to rotate the output and get a 3d view of the whole image but i dont seem to get it........ Any new functions needed to be invoked? Thanks in advance
First of all you have to understand the difference between the windowing library and the opengl context. In short, here is an overall summary.
OpenGL can be split in 2 parts:
- The client
- The driver
The client library is just a bunch of headers that you have to install. The driver is shipped with your graphic card.
The only thing that you can do is to manipulate an OpenGL context, that is, a set of buffers (frame buffers: color, depth, stencil, accumulation...) and states.
The context itself has no notion of "window" or "key". All it does is take some inputs, let it go through its pipeline, and save the output in frame buffers.
Next, there is the windowing system ( native ones: Win32, Cocoa, ..., or libraries built on top of it: Qt, GLFW, SDL, SFML, ... ) that provides windows, user input, drawings, etc... It is the windowing library that knows how to read OpenGL buffers and display them on screen.
So basically, all you have to do is to choose a windowing library, set up an OpenGL context, feed it with some inputs, and ask the window library to display the content on a canvas-like widget.
Give some more informations on what you're trying to do if you want more information.
Sides notes:
- http://www.songho.ca/opengl/gl_pipeline.html for a description of the OpenGL rendering pipeline
- http://www.opengl.org/sdk/docs/man/ for the OpenGL 2 reference manual
- Look at these simple windowing libraries:
- http://www.libsdl.org/ : SDL
- http://www.sfml-dev.org/index.php : SFML
- http://glfw.sourceforge.net/ : GLFW
- http://www.opengl.org/resources/libraries/glut/ : GLUT
The OpenGL SuperBible doesn't bother including the entire program in the text of the book, just the pertenate code snippets that illuminate the topic at hand. Just download the complete source code at www.opengl.org/supperbible. Running these programs will give you the complete functionality described in the text of the book.
The OpenGL graphics library does not include user interaction functions such as moving the model with arrow keys. Another library or custom code is required to supply that functionality. The OpenGL SuperBible's sample programs use the GLUT library to supply user interaction functionality. The OpenGL SuperBible covers GLUT in addition to OpenGL, see chapter 2 for enough information on GLUT to understand the example programs.
精彩评论