g++ main.cpp -lfreeglut -lopengl32 -lglu32
OpenGL has only a function for controlling graphics hardwares.
Graphic libraries are needed to use the graphics hardwares effectively.
Normally the graphics libraries are part of OS.
freeglut can not use on Mac OS.
ARB : Architecture Review Board
GL : This relates to a set of geometric primitives, such as point, line and polygon.
GLU : This provides important utilities and more building models (such as qradric surfaces). e.g., gluLookAt..)
★Windows 10 64bit ! VS2013 Good!! <- I don’t probably use VS any more.
sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev
★ Gute codes for working really
Streaming (referred from opengl-wiki)
Streaming is the process of frequently uploading data to a buffer object and then using that buffer object in some OpenGL process.
The key to effective streaming is avoiding this synchronization.
sample code (GLEssentials) for Mac OS X
This includes usages of Vertex Buffer Objects (VBOs), Vertex Array Objects (VAOs), Framebuffer Objects (FBO), and GLSL Program Objects.
sourceUtil.c : Functions for loading source files for shaders
vectorUtil.c : Functions for performing vector math.
modelUtil.c : Functions for loading a model file for vertex arrays. The model file format used is a simple “binary blob” invented for the purpose of this sample code.
Shader- In the field of computer graphics, a shader is a computer program that is used to do shading – the production of appropriate levels of light and color within an image – or, in the modern era, also to produce special effects or do postprocessing.
OpenGL uses geometry primitives to draw different objects in the 3D world. A geometry primitive, which may be a set of points, lines, triangles, or polygonal faces, determines how OpenGL sorts and renders its associated vertex data.
A Vertex Buffer Object (VBO) is an OpenGL feature that provides methods for uploading data (vertex, normal vector, color, etc.) to the video device for non-immediate-mode rendering. VBOs offer substantial performance gains over immediate mode rendering primarily because the data resides in the video device memory rather than the system memory and so it can be rendered directly by the video device.
frame buffer – VBO, PBO
glGenBuffers : generate VBO
glBufferData/glBufferSubData : upload and download data to the device / copy data to buffer
GL_STATIC_DRAW: The vertex data will be uploaded once and drawn many times (e.g. the world).
GL_DYNAMIC_DRAW: The vertex data will be changed from time to time, but drawn many times more than that.
GL_STREAM_DRAW: The vertex data will change almost every time it’s drawn (e.g. user interface)
glMapBuffer/glUnmapBuffer : A more efficient way to upload data to the device is to get a pointer to the internal drivers’ memory with the functions glMapBuffer and glUnmapBuffer.
OpenGL Interoperability (referred from NVIDIA_CUDA_PROGRAMMING_GUIDE.pdf)
A buffer object must be registered to CUDA before it can be mapped. This is done with cudaGLRegisterBufferObject();
Once it is registered, a buffer object can be read from or written to by kernels using the device memory address returned by cudaGLMapBufferObject():
Unmapping is done with cudaGLUnmapBufferObject() and unregistering with cudaGLUnregisterBufferObject().
Mac Cool Site!
g++ torus.c -o torus -lm -lGL -lGLU -lglut
-OpenGL + CUDA
sine curve program
VBO : Vertex Buffer Object
glGenBuffers(1, &bufferID); //Generate a buffer ID
glVertexPointer : Specify pointer to vertex coords array
GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_POLYGON, GL_QUAD_STRIP, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_QUADS
1. zip for mac os x in XCODE ← GL_LINE_STRIP
add framework-GLUT.framework, OpenGL.framework
explanation of source
2.sample 2 for mac os x in XCODE ← GL_POINTS < ← MMS point cloud data
g++ main.c -o go -lglut -lGL -lGLU
glColor3f (0, 1.0, 1.0); //←glColor3ub (0, 1, 2);
glVertex3f(1, 1, 1); // ← glVertex3f(x,y,z); //example; Airborne Lidar, MMS
glVertex3f(0.9, 0.8, 0.7);
<MMS point cloud>
→ Read Text — Comma Separated
while (fscanf(fpr, “%f,%f,%f,%f,%f,%f,%f,%f,%d,%d,%d”, &x,&y,&z,&lat,&lon,&elh,&gps,&er,&r,&g,&b) != EOF)
<Read Text Data>
Displaying a Window
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
int main(int argc, char** argv)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);