标签:blog io color ar os for sp on 2014
Main.cpp
#include <GLUT/glut.h> #include <cstdlib> /* for exit */ using namespace std; static void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } static void init() { glClearColor(1.0, 0.9, 0.65, 0.0); glColor3f(0.5,0.1, 0.1); } static void keyboard(unsigned char key, int x, int y) { switch(key) { case 'q': case 'Q': case 27: // ESC key exit(0); break; } } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500, 500); glutInitWindowPosition(0,0); glutCreateWindow("template"); glutDisplayFunc(display); glutKeyboardFunc(keyboard); init(); glutMainLoop(); return 0; }
cmake_minimum_required (VERSION 2.6) project(OpenGL) find_package(OpenGL REQUIRED) include_directories(${OPENGL_INCLUDE_DIR}) find_package(GLUT REQUIRED) include_directories(${GLUT_INCLUDE_DIR}) set(CMAKE_CXX_FLAGS "-g -Wall") add_executable(OpenGL Main.cpp) target_link_libraries(OpenGL ${GLUT_LIBRARY} ${OPENGL_LIBRARY})
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
./OpenGL
标签:blog io color ar os for sp on 2014
原文地址:http://blog.csdn.net/pyang1989/article/details/40708885