Docsity

OpenGL Programming II: Working with Toolkits and Drawing into a Window, Slides of Computer Graphics

Partial preview of the text

Download OpenGL Programming II: Working with Toolkits and Drawing into a Window and more Slides Computer Graphics in PDF only on Docsity!

OpenGL Programming II

Today

  • Review a bit from last time
  • Work through some demos
  • Introduce/demo windowing toolkits
    • GLUT
    • FLTK

Clearing the Screen

glClearColor(0.0, 0.0, 0.0, 0.0) glClearDepth(1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

To Clear The On-Screen Image And The Z-Buffer:

Our First OpenGL Code

... glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glOrtho(-1.0, 1.0, - 1.0, 1.0, - 1.0, 1.0); glBegin(GL_POLYGON); glVertex2f(-0.5, - 0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, - 0.5); glEnd(); glFlush(); ...

UI Toolkits

  • There are a lot of options to choose from:
    • GLUT
    • FLTK
    • QT
    • wxWindows
    • Cocoa
    • etc.
  • I’m going to demonstrate GLUT today

GLUT

  • OpenGL Utility Toolkit
  • Cross-Platform C++ Drawing/UI Toolkit
  • Provides functions to make starting up and drawing fast and easy
  • Supports only limited user interfaces

Using GLUT

  • Only need to include glut.h
    • #include <GL\glut.h>
      • Automatically includes gl.h and glu.h
  • Lighthouse3D has a good GLUT tutorial
    • http://www.lighthouse3d.com/opengl/glut/inde x.php?

FLTK

  • Fast Light Toolkit
  • Cross-Platform C++ GUI Toolkit
  • Provides more full-featured UI functionality than GLUT - Also supports GLUT code through emulation
  • Download from http://www.fltk.org