/* * GL01Hello.cpp: Test OpenGL C/C++ Setup */ #include // For MS Windows #include // GLUT, includes glu.h and gl.h' #include /* Handler for window-repaint event. Call back when the window first appears and whenever the window needs to be re-painted. */ void display() { int const win_width = glutGet(GLUT_WINDOW_WIDTH); int const win_height = glutGet(GLUT_WINDOW_HEIGHT); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set background color to black and opaque glClear(GL_COLOR_BUFFER_BIT); // Clear the color buffer; this clears the whole window regardless of the set viewport glViewport(0, 0, win_width, win_height); // we can set the viewport after clearing // Draw a Red 1x1 Square centered at origin glBegin(GL_QUADS); // Each set of 4 vertices form a quad glColor3f(1.0f, 0.0f, 0.0f); // Red glVertex2f(-0.5f, -0.5f); // x, y glVertex2f( 0.5f, -0.5f); glVertex2f( 0.5f, 0.5f); glVertex2f(-0.5f, 0.5f); glEnd(); glutSwapBuffers(); } /* Main function: GLUT runs as a console application starting at main() */ int main(int argc, char** argv) { std::cout<<"Hello, world!!"<