What do those openGL commands do?Monkey Forums/Monkey Beginners/What do those openGL commands do?
I researched what a stack is, but I'd like to understand exactly what these are doing within monkey. Especially why people would translate before drawing?
What the heck is Translate doing? I read some code before it did something like
but when I commented it out, it still worked the same way? Why would you ever want to translate with two negative values to begin with? I'm confused, the projection was set to 2D aswell.
Canvas.SetProjection2d(0, DeviceWidth(), 0, DeviceHeight())
well, any help with understanding this is appreciated.
| Translate moves the 0,0 origin from the top left corner of the display to wherever you want it to be. if your display windows is 640x480 and you want the origin to move to the center of the screen from the top left corner you would do Translate(320,240) so all of the drawings that are drawn at 0,0 it would display in the center of the screen. |
also the PushMatrix and PopMatrix stores and restore Scale, Rotation etc. to the point where push matrix was used.. For example, if your images are drawn at normal size and you set scale to twice the size everything you draw will be drawn relative to the new scale. if you use scale again to twice the size, such as scale(2,2) now the images are going to be scaled to four times the original size. then if you set rotation and translate. you would have to use at least 2 different commands to return it to its original state but if you used push matrix, all you would need to do is popmatrix to return to the state the drawing were drawn just before pushmatrix was used.. if you use push matrix after scale was set to twice the size and you do other scale manipulation. the PopMatrix would return the scale only to twice the size, that is to the state right before PushMatrix was used.
| Ah, that makes alot more sense. |
dont think I quite understand the purpose of translate but ill definately try and study what you said more. thanks