Add the OpenGL example CMake
This commit is contained in:
commit
590f456eff
|
@ -0,0 +1 @@
|
|||
build
|
|
@ -0,0 +1,19 @@
|
|||
cmake_minimum_required(VERSION 3.9)
|
||||
|
||||
project(OpengGL_Example)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
add_executable(opengl_example main.cpp)
|
||||
|
||||
# Set executable dependency libraries
|
||||
# Equivalent to pass flags -lGL, -lGLU and -lglut
|
||||
target_link_libraries(opengl_example GL GLU glut)
|
||||
|
||||
# Add target to run executable
|
||||
add_custom_target(run-ex1
|
||||
COMMAND opengl_example
|
||||
DEPENDS opengl_example
|
||||
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
||||
)
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
#gcc -o opengl_example main.cpp -lGL -lGLU -lglut -lm
|
||||
|
||||
rm -rf build
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake ..
|
||||
make -j4
|
|
@ -0,0 +1,28 @@
|
|||
// http://www.codebind.com/linux-tutorials/install-opengl-ubuntu-linux/
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
void displayMe(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glBegin(GL_POLYGON);
|
||||
glVertex3f(0.5, 0.0, 0.5);
|
||||
glVertex3f(0.5, 0.0, 0.0);
|
||||
glVertex3f(0.0, 0.5, 0.0);
|
||||
glVertex3f(0.0, 0.0, 0.5);
|
||||
glEnd();
|
||||
glFlush();
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_SINGLE);
|
||||
glutInitWindowSize(1920, 1080);
|
||||
glutInitWindowPosition(0, 0);
|
||||
glutCreateWindow("Hello world!");
|
||||
glutFullScreen();
|
||||
glutDisplayFunc(displayMe);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue