Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
SER332 Lecture 24
Javier Gonzalez
PRO
April 24, 2018
Programming
0
170
SER332 Lecture 24
Introduction to Graphics and Game Development
Coding Review
(201804)
Javier Gonzalez
PRO
April 24, 2018
Tweet
Share
More Decks by Javier Gonzalez
See All by Javier Gonzalez
CSE360 Tutorial 01
javiergs
PRO
0
6
JGS594 Lecture 23
javiergs
PRO
0
400
JGS594 Lecture 22
javiergs
PRO
0
380
JGS594 Lecture 21
javiergs
PRO
0
300
JGS594 Lecture 20
javiergs
PRO
0
180
JGS594 Lecture 19
javiergs
PRO
0
340
JGS594 Lecture 18
javiergs
PRO
0
340
JGS594 Lecture 17
javiergs
PRO
0
320
JGS594 Lecture 16
javiergs
PRO
1
520
Other Decks in Programming
See All in Programming
tfcon2022_Web3Dひとめぐり.pdf
emadurandal
0
1.1k
アプリのログをチーム外で活用してもらうためにやったこと
shotakashihara
0
200
iOSアプリの技術選択2022
tattn
6
2.6k
スモールチームがAmazon Cognitoでコスパよく作るサービス間連携認証
tacke_jp
2
910
脱オブジェクト指向講座(5分LT資料)
kishida
8
11k
mrubyを1300円のボードで動かそう
yuuu
0
190
モデリングの費用対効果
masuda220
PRO
4
980
CIでAndroidUIテストの様子を録画してみた
mkeeda
0
190
ebpfとWASMに思いを馳せる2022 / techfeed-conference-2022-ebpf-wasm-amsy810
masayaaoyama
1
770
Quartoを使ってみませんか / quarto_get_started
s_uryu
2
420
Loom is Blooming
josepaumard
3
570
Let's make a contract: the art of designing a Java API
mariofusco
0
160
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
181
15k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
268
11k
YesSQL, Process and Tooling at Scale
rocio
157
12k
Pencils Down: Stop Designing & Start Developing
hursman
112
9.8k
Rails Girls Zürich Keynote
gr2m
86
12k
WebSockets: Embracing the real-time Web
robhawkes
57
5k
Large-scale JavaScript Application Architecture
addyosmani
499
110k
KATA
mclloyd
7
8.6k
Code Review Best Practice
trishagee
41
6.8k
Git: the NoSQL Database
bkeepers
PRO
415
59k
GraphQLの誤解/rethinking-graphql
sonatard
24
6.2k
Transcript
jgs SER332 Introduction to Graphics and Game Development Lecture 24:
Coding Review Javier Gonzalez-Sanchez javiergs@asu.edu PERALTA 230U Office Hours: By appointment
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 2 jgs
Main // MAIN void main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(0, 0); glutInitWindowSize(WIDTH, HEIGHT); glutCreateWindow("Coding review"); // CALLBACK glutDisplayFunc(display); // SHADE AND DEPTH glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); // LIGHT GLfloat light_position[] = { 0.0, 0.0, 1.0, 0.0 }; glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); // LOOP glutMainLoop(); }
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 3 jgs
Create Texture // TEXTURE GLuint texture_from_algorithm() { GLuint texture; const int TexHeight = 128; const int TexWidth = 128; GLubyte textureImage[TexHeight][TexWidth][3]; for (int i = 0; i < TexHeight; i++) for (int j = 0; j < TexWidth; j++) { textureImage[i][j][0] = 127 + i; textureImage[i][j][1] = 0; textureImage[i][j][2] = 127 + j; } glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TexWidth, TexHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, textureImage); return texture; }
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 4 jgs
Display Callback // DISPLAY void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // PROJECTION glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, WIDTH, HEIGHT); gluPerspective(45, 1, 1, 1000); // VIEW glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // LOOKAT gluLookAt(0.0f, 40.0f, 320.0, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f); // SQUARE glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, texture_from_algorithm());
jgs Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 5
glBegin(GL_TRIANGLES); glVertex3f(0.0, 50.0, 50.0); glNormal3f(0.0, 0.0, 1.0); glVertex3f(50.0,50.0, 50.0); glNormal3f( 0.0, 0.0, 1.0); glVertex3f(50.0, 0.0, 50.0); glNormal3f( 0.0, 0.0, 1.0); glVertex3f(50.0, 0.0, 50.0); glNormal3f(0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, 50.0); glNormal3f(0.0, 0.0, 1.0); glVertex3f(0.0, 50.0, 50.0); glNormal3f(0.0, 0.0, 1.0); glTexCoord2f(0.0, 1.0); glTexCoord2f(1.0, 1.0); glTexCoord2f(1.0, 0.0); glTexCoord2f(0.0, 0.0); glEnd(); glDisable(GL_TEXTURE_2D); // SWAP glutSwapBuffers(); }
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 6 jgs
Homework Review the full example at https://github.com/javiergs/SER332/blob/master/Lecture24/main.cpp
jgs SER332 Introduction to Graphics Javier Gonzalez-Sanchez javiergs@asu.edu Spring 2018
Disclaimer. These slides can only be used as study material for the class SER332 at ASU. They cannot be distributed or used for another purpose.