Advertisement
Guest User

glutdemo

a guest
Jun 1st, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.44 KB | None | 0 0
  1. /*
  2.  * GL01Hello.cpp: Test OpenGL C/C++ Setup
  3.  */
  4. #include <iostream>
  5. #include <windows.h>  // For MS Windows
  6. #include <GL/glut.h>  // GLUT, includes glu.h and gl.h
  7.  
  8. /* Handler for window-repaint event. Call back when the window first appears and
  9.    whenever the window needs to be re-painted. */
  10. void display() {
  11.    glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set background color to black and opaque
  12.    glClear(GL_COLOR_BUFFER_BIT);         // Clear the color buffer
  13.  
  14.    // Draw a Red 1x1 Square centered at origin
  15.    glBegin(GL_QUADS);              // Each set of 4 vertices form a quad
  16.       glColor3f(1.0f, 0.0f, 0.0f); // Red
  17.       glVertex2f(-0.5f, -0.5f);    // x, y
  18.       glVertex2f( 0.5f, -0.5f);
  19.       glVertex2f( 0.5f,  0.5f);
  20.       glVertex2f(-0.5f,  0.5f);
  21.    glEnd();
  22.  
  23.    glFlush();  // Render now
  24. }
  25.  
  26. /* Main function: GLUT runs as a console application starting at main()  */
  27. int main(int argc, char** argv) {
  28.    std::cout << "inside main/n";
  29.    glutInit(&argc, argv);                 // Initialize GLUT
  30.    glutCreateWindow("OpenGL Setup Test"); // Create a window with the given title
  31.    glutInitWindowSize(320, 320);   // Set the window's initial width & height
  32.    glutInitWindowPosition(50, 50); // Position the window's initial top-left corner
  33.    glutDisplayFunc(display); // Register display callback handler for window re-paint
  34.    glutMainLoop();           // Enter the infinitely event-processing loop
  35.    return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement