Created
February 14, 2016 10:02
-
-
Save icedraco/d6aabc92d922cc05618f to your computer and use it in GitHub Desktop.
OpenGL Testing Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //--- Includes ---------------------------------------------------------------- | |
| // STL Includes | |
| #include <iostream> | |
| #include <string> | |
| #include <cstring> | |
| #include <fstream> | |
| #include <vector> | |
| #include <exception> | |
| #include <stdexcept> | |
| // STDLIB | |
| #include <math.h> | |
| // OpenGL | |
| #include <glut.h> | |
| //--- Macros ------------------------------------------------------------------ | |
| // OpenGL window properties | |
| #define WINDOW_TITLE "Test" | |
| #define WINDOW_HEIGHT 512 | |
| #define WINDOW_WIDTH 512 | |
| using namespace std; | |
| // Avoid the urges to resize the window | |
| void resize(int width, int height) { | |
| glutReshapeWindow(WINDOW_WIDTH, WINDOW_HEIGHT); | |
| } | |
| void display() { | |
| glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); | |
| glClearColor(0, 0, 0, 0); | |
| glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
| glLoadIdentity(); | |
| glScalef(1, 1.4142, 1); | |
| glTranslatef(0.7071, 0.7071, 0); | |
| glRotatef(225, 0, 0, 1); | |
| glColor3f(1.0, 1.0, 1.0); | |
| glBegin(GL_TRIANGLES); | |
| glVertex2d(0,0); | |
| glVertex2d(1,0); | |
| glVertex2d(0,1); | |
| glEnd(); | |
| glFlush(); | |
| } | |
| //--- Entry Point -----------------------------------------------------------// | |
| int main(int argc, char **argv) { | |
| int ret = 0; | |
| // GLUT Window Initialization | |
| glutInit(&argc, argv); | |
| glutInitDisplayMode(GLUT_SINGLE); | |
| glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); | |
| glutCreateWindow(WINDOW_TITLE); | |
| glutDisplayFunc(display); | |
| glutMainLoop(); | |
| // Wait for input before closing console | |
| int tmp; | |
| cin >> tmp; | |
| return ret; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RM = /bin/rm | |
| CC = /usr/bin/g++ | |
| CC_FLAGS = -pthread -std=c++11 -ggdb | |
| LIB = -L/usr/lib/x86_64-linux-gnu/ -lpthread -lglut -lGL -lGLU | |
| INCLUDE = -I/usr/include/GL/ | |
| # File names | |
| # EXECUTION: | |
| # make && GL_PRELOAD=/usr/lib/x86_64-linux-gnu/libpthread.so ./ass | |
| EXEC = ass | |
| SOURCES = $(wildcard *.cpp) | |
| OBJECTS = $(SOURCES:.cpp=.o) | |
| # Main target | |
| $(EXEC): $(OBJECTS) | |
| $(CC) $(CC_FLAGS) $(OBJECTS) $(LIB) $(INCLUDE) -o $(EXEC) | |
| # To obtain object files | |
| %.o: %.cpp | |
| $(CC) $(INCLUDE) $(CC_FLAGS) $< -c -o $@ | |
| # To remove generated files | |
| clean: | |
| $(RM) -f $(EXEC) $(OBJECTS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment