Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // OpenGL code
- Texture temp;
- void debugSetTexture(Texture t)
- {
- temp = t;
- }
- // Window resize handler
- void graphicsWindowResize(int w, int h)
- {
- glViewport(0, 0, w, h);
- glLoadIdentity();
- }
- float iasd = 0;
- void graphicsDraw()
- {
- // Prepare for 2d drawing
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, graphicsGetWindowSize().X, graphicsGetWindowSize().Y, 0, 0, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(.375f, .375f, 0);
- glClearColor(1, 1, 1, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glTranslatef(iasd, 0, 0);
- iasd += 0.1;
- if (iasd > 100) iasd = 0;
- glColor3d(.5, .6, 1);
- // Draw something:
- glBegin(GL_QUADS);
- glVertex2f(1.0f, 2.0f);
- glVertex2f(550.0f, 2.0f);
- glVertex2f(550.0f, 430.0f);
- glVertex2f(1.0f, 430.0f);
- glEnd();
- temp.enable();
- glColor3d(1, 1, 1);
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0); glVertex3f(80.5, 180.5, 0);
- glTexCoord2f(1, 0); glVertex3f(180.5, 180.5, 0);
- glTexCoord2f(1, 1); glVertex3f(180.5, 80.5, 0);
- glTexCoord2f(0, 1); glVertex3f(80.5, 80.5, 0);
- glEnd();
- // Swap buffers
- glutSwapBuffers();
- }
- void graphicsMainLoop()
- {
- // Now we need to create a new thread for gl main loop
- if (Fork()) { // Main thread
- glutMainLoop();
- }
- else { // Child thread
- return;
- }
- }
- void graphicsLoopFunction()
- {
- glutPostRedisplay();
- }
- void grahpicsInit2D(int* argc, char** argv)
- {
- // Initialize glut
- glutInit(argc, argv);
- glutInitWindowSize(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_MULTISAMPLE);
- glutCreateWindow("Hello world!");
- // Set up 2d mode
- glDisable(GL_DEPTH_TEST);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glEnable(GL_TEXTURE_2D);
- glShadeModel(GL_FLAT);
- glClearColor(1, 1, 1, 1.0);
- // More initialization
- glutDisplayFunc(graphicsDraw);
- glutReshapeFunc(graphicsWindowResize);
- glutIdleFunc(graphicsLoopFunction);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement