Computer Graphics I - evl · Computer Graphics I CS488 Fall 2005 OpenGL Programming Lab (Julian)...
Transcript of Computer Graphics I - evl · Computer Graphics I CS488 Fall 2005 OpenGL Programming Lab (Julian)...
Computer Graphics ICS488
Fall 2005OpenGL Programming Lab
(Julian) Yu-Chung ChenEmail: [email protected]
• 1st week, Aug-25 Thursday CG1 Lab
• How to get started
• What do I need to know to do program assignment 1
• What is OpenGL?
• What OpenGL can and cannot do
• OpenGL and related libraries
• HW/SW implementation
• GLUT
• Programming environment setup
• Platforms, makefile
What’s OpenGL?
• Interface to the graphics hardware
• Hardware independent standard
• Portable design
• Architecture Review Board
• Keep evolving...
• 2.0 GLSL - OpenGL Shading language
What OpenGL can do?
• Control graphics hardware
• Build objects with geometric primitives: points, lines and polygons
• 100+ API(commands)
• Give commands(prefixed ‘gl’)
What OpenGL cannot do?
• No commands for window, user I/O
• No high-level commands
• No models, scene graphs
Implementations
• Hardware
• Graphics card with drivers and libraries
• nVidia, ATI, 3DLabs...
• Software
• Mesa3D (`similar’ to OpenGL - licensing reasons)
• Performance drops dramatically
GL Utility Toolkit
• GLUT
• window definition, control
• system-level I/O
• GLUT is cross-platform
• Make your life easier
GLUT code skeletonSee the shell code
GLUT
• Define & implement callback functions
• Register callback functions to GLUT framework
• Start GLUT main event loop
• glutInit();
• glutInitDisplayMode();
• glutInitWindowSize();
• glutCreateWindow();
• glutDisplayFunc();
• glutKeyboardFunc();
• glutMainLoop();
• New student
• Find your CS account name outside SEO927 (I just got mine!)
• Required libraries
• Ask sysadm install a copy
• Build your own copy
• System setup(remote display?)
CS Department Systems
Install GLUT
• http://www.opengl.org/resources/libraries/glut.html
• ./mkmkfiles.imake; make
• Want shared library? See linux/README
Setup remote display
• X-Window server(with GLX)/client
• Server side:
• xhost + <client_ip>
• Client side:
• DISPLAY=<server_ip>:0
• SSH ForwardX11
• ssh -X <username>@server
Text
Platform dependent issues
• GNU/Linux
• Microsoft Windows
• MacOSX
GNU/Linux
• Use ‘Makefile’
• See Makefile example
• ‘make’ book resources
How to write a Makefile
• Variables
• Make rules and targets
• Remember `tab’ before commands
http://www.gnu.org/software/make/
MS-Windows
• http://www.evl.uic.edu/aej/488/visualc.html
• Make sure your project has a ‘Makfile’(gmake) and can be used directly in CS machines!
MacOSX
• Include three ‘frameworks’: Cocoa, OpenGL and GLUT in Xcode
• Make sure your project has a ‘Makfile’(gmake) and can be used directly in CS machines!
Let’s Get Back to the Shell Program
APIs
OpenGL Command Syntax
• Ex: glVertex3fv()
• 3 -> Number of arguments: 2, 3, or 4
• f -> Data types(i, f, d, b, s, ub, us, ui)
• v -> Formats: ‘v’ for vector format. no ‘v’ means scalar format
OpenGL Primitives
graphics from ref.2
• glClear();
• glColor3f();
• glBegin(); glEnd();
• glVertex2f();
Get more OpenGL example codes
• http://www.mesa3d.org/
• Mesa demos
Resources
1. ‘bluebook’: http://www.rush3d.com/reference/opengl-bluebook-1.0/
2. ‘redbook’: http://www.rush3d.com/reference/opengl-redbook-1.1/
3. ‘redbook’ sample programs: http://www.opengl.org/resources/code/basics/redbook/index.html
4. How to write a Makefile: http://vertigo.hsrl.rutgers.edu/ug/make_help.html