Introduction to OpenGL - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Introduction to OpenGL

Description:

Introduction to OpenGL – PowerPoint PPT presentation

Number of Views:156
Avg rating:3.0/5.0
Slides: 10
Provided by: hirosh4
Category:

less

Transcript and Presenter's Notes

Title: Introduction to OpenGL


1
Introduction to OpenGL
ECS175 Discussion Session
  • Hiroshi Akiba Jan 9, 2004

2
Outline
  • What is OpenGL?
  • Related Libraries
  • Sample Code
  • How to compile
  • Sample Makefile

3
What is OpenGL?
  • Low-level graphics library specification
  • Provides set of functions to draw small set of
    geometric primitives and to control rendering
    status
  • -designed for efficient processing of 3D
    applications
  • -hardware independent
  • -Language Independent

OpenGL, PHIGS, Direct3D, VRML, Java-3D
4
Related Libraries
  • OpenGL basic library(GL)
  • -device independent graphics functions for
    rendering only
  • OpenGL Utility(GLU)
  • - simple and complex 3D models
  • - Matrix Utilities (gluOrtho2D, gluLookAt,
    gluPerspective)
  • OpenGL Utility Toolkit(GLUT)
  • - One of the most popular window-system library
  • - functions for interacting with any
    screen-windowing system

GLUT
GLUT
5
Sample code
  • //include ltGL/gl.hgt
  • //include ltGL/glu.hgt
  • include ltGL/glut.hgt
  • void init(void)
  • glClearColor(1.0, 1.0, 1.0, 0.0)
  • glMatrixMode(GL_PROJECTION)
  • gluOrtho2D(0.0, 200.0, 0.0, 150.0)
  • void lineSegment(void)
  • glClear(GL_COLOR_BUFFER_BIT)
  • glColor3f(1.0, 0.0, 0.0)
  • glBegin(GL_LINES)
  • glVertex2i(180, 15)
  • glVertex2i(10, 145)
  • glEnd()

int main(int argc, char argv)
glutInit(argc, argv) glutInitDisplayMode(GLUT_
SINGLE GLUT_RGB) glutInitWindowPosition(50,
100) glutInitWindowSize(400, 300)
glutCreateWindow("An Example OpenGL Program")
init() glutDisplayFunc(lineSegment)
glutMainLoop() return 0
6
How to compile
  • Specify Header files and library location
  • EX -I/usr/include
  • -L/usr/X11R6/lib
  • Specify libraries to use
  • EX -lGL -lGLU -lglut -lXmu -lXi

7
Sample Makefile
setting build-in variables CXX g SHELLtcsh
necessary to use sed command CXXFLAGS -g
-Wall -I/usr/include library names and
location used when linking LDFLAGS -L/usr/lib
-L/usr/X11R6/lib -lGL -lGLU -lglut -lXmu -lXi
executable filename EXE sample source and
objects filename SRC sampleP80.cpp OBJ
(SRC.cpp.o) (EXE) (OBJ) (CXX)
(CXXFLAGS) (LDFLAGS) (OBJ) -o _at_
8
Sample Makefile (Cont)
  • clean
  • rm (EXE) (OBJ)
  • depend
  • sed '1,/ gtgtDO NOT DELETE THIS LINEltlt /\!d'
    Makefile gt Makefile.new
  • echo ' "make depend" was last run 'date gtgt
    Makefile.new
  • (CXX) -MM (CFLAGS) (SRC) gtgt Makefile.new
  • mv Makefile Makefile.bak
  • mv Makefile.new Makefile
  • gtgtDO NOT DELETE THIS LINEltlt
  • "make depend" was last run Wed Jan 7
    202214 PST 2004
  • sampleP80.o sampleP80.cpp

9
References
  • 1.Hearn baker, Computer Graphics width OpenGL,
    2004
  • 2.Edward Angel, Interactive Computer Graphics A
    Top-Down Approach with OpenGL, 2000
  • 3. http//www.opengl.org/
Write a Comment
User Comments (0)
About PowerShow.com