Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <GL/glut.h>
- #include <math.h>
- #define PI 3.14159265359
- GLuint draw;
- void init3D(float r, float g, float b)
- {
- glClearColor(r,g,b,1.0);
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-100.0,100.0,-100.0,100.0,0.1,80);
- }
- void initList(){
- draw = glGenLists(1);
- glNewList(draw,GL_COMPILE);
- glColorMask(1,0,0,1);
- glutSolidTeapot(50);
- //glutSolidTorus(10, 50, 50, 50);
- glTranslated(0, 0, -10);
- // /glTranslatef(-4.0f,0.0f,0.f);
- float traslation[16] = {1,0,0,0,0,1,0,0,0,0,1,0,-40.0f,0,0,1};
- float rotation [16] = {cos(90*PI/180),sin(90*PI/180),0,0,-(sin(90*PI/180)),cos(90*PI/180),0,0,0,0,1,0,0,0,0,1};
- glMultMatrixf(traslation);
- glMultMatrixf(rotation);
- glColorMask(0,0,1,1);
- glutSolidTeapot(50);
- glEndList();
- }
- void display(){
- glColorMask(1,1, 1, 1);
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- ///glColor3d(1, 0,1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glPushMatrix();
- glCallList(draw);
- glPopMatrix();
- //glutSolidTorus(10, 50, 50, 50);
- glutSwapBuffers();
- }
- void createWindow(char *windowName)
- {
- glutInitWindowPosition(300,100);
- glutInitWindowSize(800, 800);
- glutCreateWindow(windowName);
- initList();
- init3D(0.0,0.0,0.0);
- glutDisplayFunc(display);
- }
- void KEYBOARD(unsigned char key, int xx, int yy){
- switch(key){
- case 'e':
- glEnable(GL_DEPTH_TEST);
- break;
- case 'd':
- glDisable(GL_DEPTH_TEST);
- break;
- }
- glutPostRedisplay();
- }
- int main(int argc, char ** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);
- createWindow("3D Stereo");
- glutKeyboardFunc(KEYBOARD);
- // glutSpecialFunc(ESPECIAL);
- glutMainLoop(); //Start the main loop
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement