1 / 21

OpenGL & GLUT Basics

OpenGL & GLUT Basics. Window reshaping, Keyboard interaction, Camera, Drawing objects. George Georgiev. Telerik Corporation. www.telerik.com. Table of Contents. Project using OpenGL & FreeGLUT in MSVC++ Window reshaping Keyboard Interaction Camera Positioning, orientation

baris
Download Presentation

OpenGL & GLUT Basics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OpenGL & GLUT Basics Window reshaping, Keyboard interaction, Camera, Drawing objects George Georgiev Telerik Corporation www.telerik.com

  2. Table of Contents • Project using OpenGL & FreeGLUT in MSVC++ • Window reshaping • Keyboard Interaction • Camera • Positioning, orientation • Drawing objects • Coloring • Positioning, orientation • Basic Lighting

  3. Project using OpenGL & FreeGLut A reminder…

  4. OpenGL & FreeGLUT Project • Step 1 – Creating the project • Setup OpenGL & FreeGLUT (done only once) • Open Visual Studio, Choose C++ as a language • Create a Win32 Console application • Tick “Empty project” • Add a new .cpp file • #include <gl\glew.h> • #include <gl\freeglut.h> • int main(intargc, char ** argv)

  5. OpenGL & FreeGLUT Project (2) • Step 2 - Linking • Go to Project > [YourProjectName] Properties • From the side menu choose Configuration properties > Linker > Input • In the Additional Dependencies type in:glew32.libfreeglut.lib • Do this for both Debug and Release configurations (upper left corner in the window) • Close the properties window, you’re ready to go

  6. OpenGL & FreeGLUT Project (2) • Tip – the faster way to link to the libraries • Skip the entire Step 2 • In the .cpp file write: • #pragma comment (lib, “glew32.lib”)#pragma comment (lib, “freeglut.lib”)

  7. Window reshaping The Reshape function

  8. Window reshaping • Reshape function • Specified by glutReshapeFunc • Defines how your window reshapes • Write it once, remember it no more

  9. Window reshaping Live Demo

  10. Keyboard interaction The Keyboard monitoring functions

  11. Keyboard interaction • Keyboard monitoring functions • Specified by • glutKeyboardFunc • glutKeyboardUpFunc • Monitor key pressing and key releasing • Doesn’t receive device information • Receives translated windows messages

  12. Keyboard interaction Live Demo

  13. Camera control Orientation and positioning

  14. Camera control • ‘Moving the world’ method • Using the glTranslate* and glRotate* functions • You do the things the opposite way around • F. e., to move the camera forward, move the objects backward • Using the gluLookAt function • Specifies • camera location • Viewed location

  15. Drawing objects GLUT predefined objects, Coloring, Positioning

  16. Drawing objects • GLUT predefined functions • glutSolid* • glutWireframe* • Coloring • glColor* - defines the current drawing color • Positioning • glTranslate* - moves the renderer by a vector • glRotate* - rotates the renderer by an Euler angle

  17. Camera control & Drawing objects Live Demo

  18. Basic Lighting Enabling lighting

  19. Basic lighting • Enabling lighting • glEnable • Enabling ‘color material’

  20. Basic Lighting Live Demo

  21. OpenGL Basics ? ? Questions? ? ? ? ? ? ? ? ? ?

More Related