Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GLUT/GLUT.h>
- #include <iostream>
- void render(void);
- void keyboard(unsigned char c, int x, int y);
- void mouse(int button, int state, int x, int y);
- int main(int argc, char** argv) {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
- glutInitWindowPosition(100, 100);
- glutInitWindowSize(640, 480);
- glutCreateWindow("Simple GLUT Application");
- glutDisplayFunc(render);
- glutKeyboardFunc(keyboard);
- glutMouseFunc(mouse);
- glutMainLoop();
- }
- void keyboard(unsigned char c, int x, int y) {
- if (c == 27) {
- exit(0);
- }
- }
- void mouse(int button, int state, int x, int y) {
- if (button == GLUT_RIGHT_BUTTON) {
- exit(0);
- }
- }
- void render(void) {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glBegin(GL_TRIANGLES);
- glColor3f(1, 0, 0);
- glVertex2f(-0.5, -0.5);
- glColor3f(0, 1, 0);
- glVertex2f(0.5, -0.5);
- glColor3f(0, 0, 1);
- glVertex2f(0.0, 0.5);
- glEnd();
- glutSwapBuffers();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement