This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 29th, 2013  |  syntax: None  |  size: 1.45 KB  |  views: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * GL01Hello.cpp: Test OpenGL C/C++ Setup
  3.  */
  4. #include <windows.h>  // For MS Windows
  5. #include <GL/glut.h>  // GLUT, includes glu.h and gl.h'
  6. #include <iostream>
  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<<"Hello, world!!"<<std::endl;
  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. }
clone this paste RAW Paste Data