CSCI 420 Computer Graphics OpenGL Cheat Sheet Create a Window glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA); glutInitWindowSize(500, 500); glutInitWindowPosition (0, 0); glutCreateWindow (win_name); Clear a Window glClearColor (0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT);

Double Buffering glutInitDisplayMode (GLUT_DOUBLE | . . .); glutSwapBuffers( );

Depth Testing glutInitDisplayMode (GLUT_DEPTH | . . .); glEnable (GL_DEPTH_TEST); glClear (GL_DEPTH_BUFFER_BIT | . . .);

Establish a Viewport and a Clipping Region glViewport (0, 0, w, h); glMatrixMode (GL_PROJECTION); glLoadIdentity( ); glOrtho (-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW);

Projections and Locating the Camera glOrtho (-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); glFrustum ( left, right, bottom, top, near, far); gluPerspective(fovy, (GLfloat) w/(GLfloat) h, near, far); gluLookAt (eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz);

Callback and Related Functions glutReshapeFunc (myReshape); glutDisplayFunc (myDisplay); glutIdleFunc (spinDisplay); glutMouseFunc (mouse); glutKeyboardFunc (keyboard); glutMainLoop ( ); glutPostRedisplay ( );

Lighting and Materials glLightf (source, parameter, value); glLightfv (source, parameter, pointer to array); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);

Move Around glPushMatrix( ); glPopMatrix( ); glLoadIdentity ( ); glRotatef(spin, 0.0, 0.0, 1.0); glTranslatef(3.0, 2.0, 0.0); glScalef(1.0, 2.0, 1.0); Menus void color_menu(int id) { if(id == 1) {r = 1.0; g = 0.0; b = 0.0;}. . . c_menu = glutCreateMenu(color_menu); glutAddMenuEntry("Red",1); glutAttachMenu(GLUT_RIGHT_BUTTON); glutAddSubMenu("Colors", c_menu); Text glRasterPos2i(textX, textY); glutBitmapCharacter (GLUT_BITMAP_8_BY_13, ch); Functions to Draw glColor3f (red, green, blue); glBegin (GL_TRIANGLES); glVertex3f(3.0, 4.0, 0.0); glEnd(); // Alternatively glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer (3, GL_FLOAT, 0, vertices); glColorPointer (3, GL_FLOAT, 0, carray); glDrawElements (GL_QUADS, 24, GL_UNSIGNED_BYTE, cubeIndex);

glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);

Blending and Antialiasing glEnable(GL_BLEND); glBlendFunc (source_factor, destination_factor); glDepthMask (GL_FALSE); // sets the depth buffer to read // only glEnable (GL_POINT_SMOOTH); glEnable (GL_LINE_SMOOTH); glEnable (GL_SMOOTHING); Bezier Curves and Surfaces glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]); glEnable(GL_MAP1_VERTEX_3); glEvalCoord1f((GLfloat) i/30.0); glMapGrid1f (100, 0.0, 1.0); glEvalMesh1(GL_LINE, 0, 100); Textures glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, checkImageWidth, checkImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, &checkImage[0][0][0]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glEnable(GL_TEXTURE_2D); glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);

3D Transformations Translatef (xt, yt, zt)

Rotatef( , 0.0, 0.0, 1.0)

Scalef(sx, sy, sz)

1

0

0

xt

cos( )

-sin( )

0

0

sx

0

0

0

0

1

0

yt

sin( )

cos( )

0

0

0

sy

0

0

0

0

1

zt

0

0

1

0

0

0

sz

0

0

0

0

1

0

0

0

1

0

0

0

1

There are similar rotation matrices about the X and Y axes.

Projection Matrices Simple Orthogonal

Simple Perspective

1

0

0

0

1

0

0

0

0

1

0

0

0

1

0

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

1/d

0

Orthogonal Projection to Canonical View Volume 2/(Xmax-Xmin)

0

0

-(Xmax+Xmin)/(Xmax-Xmin)

0

2/(Ymax-Ymin)

0

-(Ymax+Ymin)/(Ymax-Ymin)

0

0

2/(Zmax-Zmin)

-(Zmax+Zmin)/(Zmax-Zmin)

0

0

0

1

Perspective Normalization Matrix (assumes right projection and fovy of 90 degrees) 1

0

0

0

0

1

0

0

α = (Zmax + Zmin)/(Zmax - Zmin)

0

0

α

β

β = (2*Zmax*Zmin)/(Zmax - Zmin)

0

0

-1

0

General Perspective Projection Matrix 2*Zmin /(Xmax-Xmin)

0

(Xmax+Xmin)/(Xmax-Xmin)

0

0

2*Zmin/ (Ymax-Ymin)

(Ymax+Ymin)/(Ymax-Ymin)

0

0

0

-(Zmax+Zmin)/(Zmax-Zmin)

-2*Zmax*Zmin/(Zmax-Zmin)

0

0

-1

0

CSCI 420 Computer Graphics OpenGL Cheat Sheet

CSCI 420. Computer Graphics. OpenGL Cheat Sheet .... Perspective Normalization Matrix (assumes right projection and fovy of 90 degrees). 1. 0. 0. 0. 0. 1. 0. 0.

72KB Sizes 69 Downloads 292 Views

Recommend Documents

git cheat sheet - Cheat-Sheets.org
git clone ssh://[email protected]/repo.git. Create a new local repository. $ git init. LOCAL CHANGES. Changed files in y our working directory. $ git status.

Computer Basics Quick Reference, Computer Basics Cheat Sheet
It calculates and processes information, and its speed ... RAM (random-access memory): Computer's main memory, which is used to ... Networks and the Internet.

Computer Basics Quick Reference, Computer Basics Cheat Sheet
which means unsaved data disappears when you shut off the computer. ROM (read-only memory): Computer's ... Terabyte (TB):. 1,099, 511,627,776 bytes.

CSS3 Cheat Sheet - GitHub
Border Radius vendor prefix required for iOS

HTML5 Canvas Cheat Sheet [.pdf] - Cheat-Sheets.org
HTML5 Canvas Cheat Sheet v1.1. Page 2. Colors, styles and shadows. Attributes. Name. Type. Default. strokeStyle any black. fillStyle any black. shadowOffsetX.

gitchangelog Cheat Sheet - GitHub
new: test: added a bunch of test around user usability of feature X. fix: typo in spelling my name in comment. !minor. By Delqvs cheatography.com/delqvs/. Published 14th August, 2017. Last updated 14th August, 2017. Page 1 of 1. Sponsored by ApolloPa

Cheat sheet Services
Create a Version of your current container, and test it out on your live site by using Preview or Debug mode. Navigate around your site and see if the rules and tags are acting the way you expect. Migrate by removing hard-coded tags: You're almost re

Meterpreter Cheat Sheet - SCADAhacker
Page 1 ... Displays network interfaces information meterpreter> route. View and modify networking routing table meterpreter> portfwd. Establish port forwarding.

Reschedule Cheat Sheet
desire to meet with. • You've realized that your account has a meeting scheduled more than once with the same company. • You have reached your outstanding ...

jQuery Cheat Sheet
6. Traversing. 7. Events. 8. Effects. 10. AJAX. 11. Core. 12 of 2 13 ... DOM Insertion, Inside .append() .appendTo() .html() .prepend() .prependTo() .text().

TOP 150 CHEAT SHEET
2 Ezekiel Elliott. DAL. 8. RB. 52 Lamar Miller. HOU. 10. RB ... 62 Dion Lewis. TEN. 8. RB PPR. 112 Kenny Stills .... Ezekiel Elliott. DAL. 3. 7. A.J. Green. CIN. 4. 11.

Machine Learning Cheat Sheet - GitHub
get lost in the middle way of the derivation process. This cheat sheet ... 3. 2.2. A brief review of probability theory . . . . 3. 2.2.1. Basic concepts . . . . . . . . . . . . . . 3 ...... pdf of standard normal π ... call it classifier) or a decis

Cheat Sheet Subnetting.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Cheat Sheet Subnetting.pdf. Cheat Sheet Subnetting.pdf. Open. Extract. Open with. Sign In. Details. Comments

vi / vim graphical cheat sheet
F "back" fwd. G eof/ goto ln Hscreen top. J join lines. K help. L screen bottom ... version at http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html.

CSS3 Cheat Sheet - Smashing Magazine
display none | inline | block | inline- block | list-item | run-in | compact | table | inline- table | table-row-group | table-header-group | table- footer-group | table-row |.Missing:

R Markdown : : CHEAT SHEET - GitHub
Word, or RTF documents; html or pdf based slides ... stop render when errors occur (FALSE) (default = FALSE) .... colortheme. Beamer color theme to use. X css.

Google+ Cheat Sheet - G Suite
3 Find or follow people. 4 Follow or create collections, which group posts around a topic. Learning Center gsuite.google.com/learning-center.

Overtone Cheat Sheet 0.9.1 - WordPress.com
graphviz. Show PDF show-graphviz-synth ... Generate Buffer Data data->wavetable create-buffer-data ... LINEAR LIN EXPONENTIAL EXP. Onset Analysis.

RTOS Threading Cheat Sheet - GitHub
If the UART is enabled, it causes a data frame to start transmitting with the parameters indicated in the. UARTLCRH register. Data continues to be transmitted ...

Pokemon Go Cheat Sheet 619 ^% Pokemon Go Cheat Codes Ios
Free Pokemon Go hacks and cheats online for Android and iOS devices, which ... 6 Code Generator Pokemon Go Cheats For Ios 10 Live Free Game Generator.

[Cheat Sheet] 15 Credit & Balance Sheet Ratios.pdf
Page 1 of 1. Cheat Sheet: Balance Sheet Ratios. Ratios to evaluate credit health and management's operating capital efficiency. Interest Coverage Ratios Calculation Healthy. Ratios that specifically measure a business's ability to make interest payme

Groups Cheat Sheet - G Suite
1 Access your groups, or create new ones. Switch from public groups to ... Change your Groups settings Edit membership settings, email subscriptions, update ...