glTranslate()
Using Default Window (2 x 2)
|
#include
"stdafx.h"
#include
<GL/glut.h>
void
mydisplay() {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glEnd();
glFlush(); }
int
main(int argc,
char** argv) {
glutCreateWindow("A Triangle");
glutDisplayFunc(mydisplay);
glutMainLoop(); } |
![]() |
|
#include
<GL/glut.h>
void mydisplay() {
glClear(GL_COLOR_BUFFER_BIT);
glTranslatef(0.5f, 0.5f, 0.0f);
glBegin(GL_TRIANGLES);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glEnd();
glFlush(); }
int main(int
argc, char** argv) {
glutCreateWindow("A Triangle");
glutDisplayFunc(mydisplay);
glutMainLoop(); } |
![]() |
|
Both Triangles
#include
"stdafx.h"
#include
<GL/glut.h>
void mydisplay() {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glEnd();
glTranslatef(0.5f, 0.5f, 0.0f);
glBegin(GL_TRIANGLES);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glEnd();
glFlush(); }
int main(int
argc, char** argv) {
glutCreateWindow("A Triangle");
glutDisplayFunc(mydisplay);
glutMainLoop(); } |
![]() |