Skip to content

Commit

Permalink
Merge branch 'modeller-diagram' of https://github.com/EkkiD/500lines
Browse files Browse the repository at this point in the history
…into EkkiD-modeller-diagram

Conflicts:
	modeller/chapter.md
  • Loading branch information
MichaelDiBernardo committed Mar 18, 2015
2 parents db88d9a + 49c65f1 commit 9e3c4f6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions modeller/chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,20 @@ Some common transformation matrices are translations (moves), scaling, and rotat
To draw an item to the screen, we need to convert between a few different coordinate spaces.

![Transformation Pipeline](newtranspipe.png?raw=true)
Thank you very much to Dr. Anton Gerdelan for the image. His OpenGL tutorial book is available [here](http://antongerdelan.net/opengl/).
Thank you to Dr. Anton Gerdelan for the image. His OpenGL tutorial book is available at [http://antongerdelan.net/opengl/](http://antongerdelan.net/opengl/).

We let specialized OpenGL functions handle the right hand side of the diagram: conversion from eye space to homogeneous clip space is handled by `gluPerspective`, and conversion to normalized device space and viewport space is handled by `glViewport`. These matrices do not change during program execution.
Points in the view space are converted into points in 2D using the projection matrix.
The right hand side of the diagram, including all of the transformations from Eye Space to Viewport Space will all be handled for us by OpenGL.
Conversion from eye space to homogeneous clip space is handled by `gluPerspective`, and conversion to normalized device space and viewport space is handled by `glViewport`.
These two matrices are multiplied together and stored as the GL_PROJECTION matrix.
We don't need to know the terminology or the details of how these matrices work for this project.

We need to manage the left hand side of the diagram ourselves. We define a matrix which converts points from the model spaces into the world space, called the Model matrix. We alse define the view matrix, which converts from the world space into the eye space.
We do, however, need to manage the left hand side of the diagram ourselves. We define a matrix which converts points in the model (also called a mesh) from the model spaces into the world space, called the model matrix. We alse define the view matrix, which converts from the world space into the eye space.
In this project, we combine these two matrices to obtain the ModelView matrix.

### Rendering With the Viewer
The `render` function begins by setting up the parts of the OpenGL state that need to be set up at render time. It initializes the projection matrix via `init_view` and uses data from the `interaction` member to initialize the ModelView matrix with the transformation matrix that converts from the scene space to world space. (We will see more about the `Interaction` class below.) It clears the screen with `glClear` and it tells the scene to render itself, and then renders the unit grid.
To learn more about the full graphics rendering pipeline, and the coordinate spaces involved, refer to chapter 2 of ["Real Time Rendering"](http://www.realtimerendering.com/), or another introductory computer graphics book.

### Rendering with the Viewer
The `render` function begins by setting up any of the OpenGL state that needs to be done at render time. It initializes the projection matrix via `init_view` and uses data from the interaction member to initialize the ModelView matrix with the transformation matrix that converts from the scene space to world space. We will see more about the Interaction class below. It clears the screen with `glClear` and it tells the scene to render itself, and then renders the unit grid.

We disable OpenGL's lighting before rendering the grid. With lighting disabled, OpenGL renders items with solid colors, rather than simulating a light source. This way, the grid has visual differentiation from the scene.
Finally, `glFlush` signals to the graphics driver that we are ready for the buffer to be flushed and displayed to the screen.
Expand Down

0 comments on commit 9e3c4f6

Please sign in to comment.