Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "GL/freeglut.h"
- void init()
- {
- //selecteaza culoarea de fond
- glClearColor(1, 1, 1, 1);
- //glShadeModel(GL_FLAT); //
- }
- void triangle()
- {
- // se va folosi glBegin() cu parametrul corespunzator pentru
- //desenarea triunghiului
- glBegin(GL_TRIANGLES); //Begin triangle coordinates
- //Triangle
- glColor3f(1.0f,0.0f,0.0f);glVertex3f(0.0f, 0.0f, 1.0f);
- glColor3f(0.0f,1.0f, 0.0f);glVertex3f(0.0f, 1.0f, 0.0f);
- glColor3f(0.0f, 0.0f, 1.0f);glVertex3f(1.0f, 0.0f, 0.0f);
- glEnd(); //End triangle coordinates
- }
- void display()
- {
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- triangle();
- glutSwapBuffers();
- }
- void reshape(int w, int h)
- {
- glViewport(0, 0, (GLsizei)w, (GLsizei)h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- if (w <= h)
- gluOrtho2D(0, 30, 0, 30 * (GLfloat)h / (GLfloat)w);
- else
- gluOrtho2D(0, 30 * (GLfloat)w / (GLfloat)h, 0, 30);
- glMatrixMode(GL_MODELVIEW);
- }
- int main(int argc, char **argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE|GLUT_DEPTH);
- glutInitWindowPosition(100, 100);
- glutInitWindowSize(640, 480);
- glutCreateWindow("SPG OpenGL");
- init();
- glutDisplayFunc(display);
- //glutReshapeFunc(reshape);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement