Lecture_Chapter4_b

Ecs 175 chapter 4 object transformation 34 notes on

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ect Transformation 33 A Brief Review of Linear Algebra •  Applying multiple transformations in sequence Mscal · Mrot · v = v ￿ (Mscal · Mrot ) · v = v ￿ Order of operations is important! ECS 175 Chapter 4: Object Transformation 34 Notes on Matrices in OpenGL •  OpenGL <3.0 includes matrix operations and stack glMatrixMode(…) glLoadMatrix(…) glMultMatrix(…) glPushMatrix() //push current matrix to top of stack glPopMatrix() //take matrix from top of stack … Assignment 2: You may use glLoadMatrix, glMultMatrix or pass the matrices to the vertex shader as uniform variables (do not use glTranslate, glRotate). •  Matrix operations and stack deprecated in OpenGL 3.0+ •  Implement own transformation matrices •  Pass to vertex shader (OpenGL/GLSL: uniform variables) ECS 175 Chapter 4: Object Transformation 35 Notes on Matrices in OpenGL •  OpenGL <3.0 vertex shader example void main(void) { gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex; } •  OpenGL 3.0+ vertex shader example attribute vec3 in_Position; //vertex attribute is part of VBO/vertex array uniform mat4 m_modelview; //custom uniform variable for modelview matrix uniform mat4 m_projection; //custom uniform variable for projection matrix void main(void) { gl_Position = m_projection * m_modelview * vec4(in_Position,1.0); } ECS 175 Chapter 4: Object Transformation 36 Homogeneous Coordinates •  Problems so far: •  No translation •  No explicit notion of local and global coordinates •  No distinction between points and vectors Homogeneous coordinates solve these problems. ECS 175...
View Full Document

Ask a homework question - tutors are online