Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9214d7e
commit 7346c24
Showing
36 changed files
with
1,619 additions
and
211 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
LIBS := -lm -pthread -lGL -lGLU -lglut -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann | ||
LIBS := -lm -pthread -lGL -lGLU -lglut -lglfw -lX11 -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
# OpenGL | ||
|
||
1. [Introduction](introduction.md) | ||
1. [glinfo](glinfo.c) | ||
1. [GLUT](glut.md) | ||
1. [Lightning](lightning.md) | ||
1. Examples | ||
1. [GLUT hello world](hello_world.c) | ||
1. [glinfo](glinfo.c) | ||
1. [Triangle](triangl.c) | ||
1. [glOrtho](ortho.c) | ||
1. [glShadeModel](shade_model.c) | ||
1. [glViewport](viewport.c) | ||
1. [Depth](depth.c) | ||
1. Transformations | ||
1. [glTranslate](glTranslate.c) | ||
1. Lightning | ||
1. [Ambient](ambient.c) | ||
1. Diffuse | ||
1. [glNormal](normal.c) | ||
1. [Diffuse infinity](diffuse_infinity.c) | ||
1. [Diffuse shadow](diffuse_shadow.c) | ||
1. [Diffuse attenuation](diffuse_attenuation.c) | ||
1. [glDrawPixels (TODO)](draw_pixels.c) | ||
1. [Culling](culling.c) | ||
1. GLUT | ||
1. [glutBitmapCharacter](bitmap_character.c) | ||
1. [GLX](glx.c) | ||
1. Performance | ||
1. [Many triangles](many_triangles.c) | ||
1. [main](main.cpp) | ||
1. bouncing_balls | ||
1. [one](bouncing_balls_one.cpp) | ||
1. [many](bouncing_balls_many.cpp) | ||
1. [Texture FPS](texture_fps.cpp) | ||
1. Mini projects | ||
1. bouncing_balls | ||
1. [one](bouncing_balls_one.cpp) | ||
1. [many](bouncing_balls_many.cpp) | ||
1. [Texture FPS](texture_fps.cpp) | ||
1. [Bibliography](bibliography.md) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
The triangle only becomes gray because ambient light is halved: | ||
http://forum.unity3d.com/threads/why-is-ambient-light-at-half-strength.33955/ | ||
*/ | ||
|
||
#include <stdlib.h> | ||
|
||
#include <GL/gl.h> | ||
#include <GL/glu.h> | ||
#include <GL/glut.h> | ||
|
||
static void init(void) { | ||
GLfloat light0_ambient[] = {1.0, 1.0, 1.0, 1.0}; | ||
GLfloat light0_position[] = {0.0, -1.0, 0.0, 0.0}; | ||
glClearColor(0.0, 0.0, 0.0, 0.0); | ||
glShadeModel(GL_SMOOTH); | ||
glEnable(GL_LIGHTING); | ||
glLightfv(GL_LIGHT0, GL_POSITION, light0_position); | ||
glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); | ||
glColorMaterial(GL_FRONT, GL_AMBIENT); | ||
glEnable(GL_COLOR_MATERIAL); | ||
} | ||
|
||
static void draw_triangle() { | ||
glColor3f(1.0, 0.0, 0.0); | ||
glVertex3f(0.0f, 1.0f, 0.0f); | ||
glVertex3f(-1.0f, -1.0f, 0.0f); | ||
glVertex3f(1.0f, -1.0f, 0.0f); | ||
} | ||
|
||
static void display(void) { | ||
glClear(GL_COLOR_BUFFER_BIT); | ||
glLoadIdentity(); | ||
glBegin(GL_TRIANGLES); | ||
draw_triangle(); | ||
glEnd(); | ||
glFlush(); | ||
} | ||
|
||
static void reshape(int w, int h) { | ||
glViewport(0, 0, w, h); | ||
glMatrixMode(GL_PROJECTION); | ||
glLoadIdentity(); | ||
glOrtho(-2.0, 2.0, -2.0, 2.0, -1.0, 1.0); | ||
glMatrixMode(GL_MODELVIEW); | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
glutInit(&argc, argv); | ||
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); | ||
glutInitWindowSize(500, 500); | ||
glutInitWindowPosition(100, 100); | ||
glutCreateWindow(argv[0]); | ||
init(); | ||
glutDisplayFunc(display); | ||
glutReshapeFunc(reshape); | ||
glutMainLoop(); | ||
return EXIT_SUCCESS; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
# Bibliography | ||
|
||
Standards: | ||
|
||
- <https://www.opengl.org/registry/#oldspecs> Khronos standards | ||
|
||
From there you can reach for example: | ||
|
||
- <https://www.opengl.org/registry/doc/glspec21.20061201.pdf> 2.1 spec | ||
- <https://www.opengl.org/sdk/docs/man2/> 2.1 online reference | ||
|
||
- Demos: | ||
Tutorials with code: | ||
|
||
- <https://github.com/JoeyDeVries/LearnOpenGL> <http://learnopengl.com/> | ||
- <https://github.com/opengl-tutorials/ogl> | ||
- <https://github.com/capnramses/antons_opengl_tutorials_book> Some hardcore examples. Uses GLFW. | ||
- <https://github.com/Overv/Open.GL/tree/master/content/code> | ||
- <http://www.glprogramming.com/red/> | ||
- <https://github.com/tomdalling/opengl-series> <http://www.tomdalling.com/blog/category/modern-opengl/> Modern, no immediate rendering. | ||
- <http://www.videotutorialsrock.com/opengl_tutorial/normalize/video.php> | ||
|
||
Java: | ||
|
||
- <https://github.com/OskarVeerhoek/YouTube-tutorials> | ||
|
||
Demos: | ||
|
||
- <https://github.com/prideout/recipes> | ||
- <https://github.com/prideout/recipes> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
# glutBitmapCharacter | ||
http://stackoverflow.com/questions/8847899/opengl-how-to-draw-text-using-only-opengl-methods | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include <GL/gl.h> | ||
#include <GL/glu.h> | ||
#include <GL/glut.h> | ||
|
||
static void init() { | ||
glEnable(GL_DEPTH_TEST); | ||
glClearColor(0.0, 0.0, 0.0, 0.0); | ||
glShadeModel(GL_FLAT); | ||
} | ||
|
||
static void drawString (void *font, char *s, GLfloat x, GLfloat y, GLfloat z){ | ||
unsigned int i; | ||
/* Must come before glRasterPos. */ | ||
glColor3f(0.0f, 0.0f, 1.0f); | ||
glRasterPos3f(x, y, z); | ||
for (i = 0; i < strlen(s); i++) | ||
glutBitmapCharacter(font, s[i]); | ||
} | ||
|
||
static void display(void) { | ||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | ||
glLoadIdentity(); | ||
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); | ||
glBegin(GL_TRIANGLES); | ||
glColor3f(1.0f, 0.0f, 0.0f); | ||
glVertex3f( 0.0f, 1.0f, 0.0f); | ||
glVertex3f(-1.0f, -1.0f, 0.0f); | ||
glVertex3f( 1.0f, -1.0f, 0.0f); | ||
glEnd(); | ||
|
||
/* This is drawn as close as possible to the camera. */ | ||
drawString(GLUT_BITMAP_HELVETICA_18, "bottom", -1.0, -1.0, 3.5); | ||
|
||
/* Depth is considered. Things that come behind are hidden. */ | ||
drawString(GLUT_BITMAP_HELVETICA_18, "behind", 0.0, 0.0, -1.0); | ||
drawString(GLUT_BITMAP_HELVETICA_18, "front", 0.0, 0.5, 1.0); | ||
|
||
/* The font size is fixed no matter how far back we are.*/ | ||
drawString(GLUT_BITMAP_HELVETICA_18, "far", 200.0, 200.0, -990.0); | ||
|
||
glFlush(); | ||
} | ||
|
||
static void reshape(int w, int h) { | ||
glViewport(0, 0, w, h); | ||
glMatrixMode(GL_PROJECTION); | ||
glLoadIdentity(); | ||
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 1000.0); | ||
glMatrixMode(GL_MODELVIEW); | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
glutInit(&argc, argv); | ||
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); | ||
glutInitWindowSize(500, 500); | ||
glutInitWindowPosition(100, 100); | ||
glutCreateWindow(argv[0]); | ||
init(); | ||
glutDisplayFunc(display); | ||
glutReshapeFunc(reshape); | ||
glutMainLoop(); | ||
return EXIT_SUCCESS; | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/usr/bin/env bash | ||
sudo aptitude update | ||
sudo aptitude install -y freeglut3-dev libopencv-dev | ||
sudo aptitude install -y freeglut3-dev libglfw3-dev libopencv-dev |
Oops, something went wrong.