progschj / opengl-examples Goto Github PK
View Code? Open in Web Editor NEWA collection of simple single file OpenGL examples
License: zlib License
A collection of simple single file OpenGL examples
License: zlib License
According to: http://gamedev.stackexchange.com/questions/47910/after-a-succesful-gllinkprogram-should-i-delete-detach-my-shaders
it seems better to detach and delete shaders vertex/geom/frag as soon as they get attached to the shader program than doing it at the end of the main.
I tried it on Ubuntu 14.04:
ondrej@eagle:~/repos/OpenGL-Examples/build(master)$ cmake ..
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.6")
-- Using X11 for window creation
-- Using GLX for context creation
CMake Error at glfw/CMakeLists.txt:234 (message):
The XInput library and headers were not found
-- Configuring incomplete, errors occurred!
See also "/home/ondrej/repos/OpenGL-Examples/build/CMakeFiles/CMakeOutput.log".
See also "/home/ondrej/repos/OpenGL-Examples/build/CMakeFiles/CMakeError.log".
But the package xinput
is installed in my Ubuntu
$ make
[ 3%] Built target glxw
[ 24%] Built target glfw
Linking CXX executable 00skeleton
/usr/bin/ld: glxw/libglxw.a(glxw.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [00skeleton] Error 1
make[1]: *** [CMakeFiles/00skeleton.dir/all] Error 2
make: *** [all] Error 2
zsh: exit 2 make
$
When I try to execute the compiled examples (e.g. 01shader_vbo1
) I only get
failed to open window
Do you have any idea what the problem might be?
It seems to be complaining that GLXW/glxw.h is missing ..
build master + $ make
Scanning dependencies of target glfw
[ 1%] Building C object glfw/src/CMakeFiles/glfw.dir/clipboard.c.o
[ 2%] Building C object glfw/src/CMakeFiles/glfw.dir/context.c.o
[ 3%] Building C object glfw/src/CMakeFiles/glfw.dir/gamma.c.o
[ 5%] Building C object glfw/src/CMakeFiles/glfw.dir/init.c.o
[ 6%] Building C object glfw/src/CMakeFiles/glfw.dir/input.c.o
[ 7%] Building C object glfw/src/CMakeFiles/glfw.dir/joystick.c.o
[ 9%] Building C object glfw/src/CMakeFiles/glfw.dir/monitor.c.o
[ 10%] Building C object glfw/src/CMakeFiles/glfw.dir/time.c.o
[ 11%] Building C object glfw/src/CMakeFiles/glfw.dir/window.c.o
[ 13%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_clipboard.c.o
[ 14%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_gamma.c.o
[ 15%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_init.c.o
[ 17%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_monitor.c.o
[ 18%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_window.c.o
[ 19%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_unicode.c.o
[ 21%] Building C object glfw/src/CMakeFiles/glfw.dir/linux_joystick.c.o
[ 22%] Building C object glfw/src/CMakeFiles/glfw.dir/posix_time.c.o
[ 23%] Building C object glfw/src/CMakeFiles/glfw.dir/posix_tls.c.o
[ 25%] Building C object glfw/src/CMakeFiles/glfw.dir/glx_context.c.o
Linking C static library libglfw3.a
[ 25%] Built target glfw
Scanning dependencies of target 00skeleton
[ 26%] Building CXX object CMakeFiles/00skeleton.dir/00skeleton.cpp.o
/mnt/data/home/stu/projects/tutorials/OpenGL-Examples/00skeleton.cpp:8:23: fatal error: GLXW/glxw.h: No such file or directory
#include <GLXW/glxw.h>
^
compilation terminated.
CMakeFiles/00skeleton.dir/build.make:54: recipe for target 'CMakeFiles/00skeleton.dir/00skeleton.cpp.o' failed
make[2]: *** [CMakeFiles/00skeleton.dir/00skeleton.cpp.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/00skeleton.dir/all' failed
make[1]: *** [CMakeFiles/00skeleton.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2
I tried to compile the samples on my Mac (OS X El Capitan version 10.11.6). By following the documentation, the cmake ..
step worked fine but during compilation, I got the following error:
[ 91%] Generating include/KHR/khrplatform.h
Downloading KHR/khrplatform.h from http://www.khronos.org/registry/egl/api/KHR/khrplatform.h to /Users/gbittoun/Documents/OpenGL-Examples/build/glxw/include/KHR/khrplatform.h
[ 92%] Generating include/GLES2/gl2.h, include/GLES2/gl2ext.h, include/GLES2/gl2platform.h
Downloading GLES2/gl2.h from http://www.khronos.org/registry/gles/api/GLES2/gl2.h to /Users/gbittoun/Documents/OpenGL-Examples/build/glxw/include/GLES2/gl2.h
Downloading GLES2/gl2platform.h from http://www.khronos.org/registry/gles/api/GLES2/gl2platform.h to /Users/gbittoun/Documents/OpenGL-Examples/build/glxw/include/GLES2/gl2platform.h
Downloading GLES2/gl2ext.h from http://www.khronos.org/registry/gles/api/GLES2/gl2ext.h to /Users/gbittoun/Documents/OpenGL-Examples/build/glxw/include/GLES2/gl2ext.h
[ 92%] Generating src/glxw_es2.c, include/GLXW/glxw_es2.h
Parsing header gl2ext.h
Generating header /Users/gbittoun/Documents/OpenGL-Examples/build/glxw/include/GLXW/glxw_es2.h
Generating library source /Users/gbittoun/Documents/OpenGL-Examples/build/glxw/src/glxw_es2.c
Scanning dependencies of target glxw_es2
[ 93%] Building C object glxw/CMakeFiles/glxw_es2.dir/src/glxw_es2.c.o
/Users/gbittoun/Documents/OpenGL-Examples/build/glxw/src/glxw_es2.c:3:10: fatal error: 'EGL/egl.h' file not found
#include <EGL/egl.h>
^
1 error generated.
make[2]: *** [glxw/CMakeFiles/glxw_es2.dir/src/glxw_es2.c.o] Error 1
make[1]: *** [glxw/CMakeFiles/glxw_es2.dir/all] Error 2
make: *** [all] Error 2
I looked for this egl.h
file on my computer and it seems that it indeed doesn’t exist or at least, not in a directory named EGL
. I could find it in the directory /opt/X11/include/GLES
. I tried to copy it in the include dir of glxw… without success.
Is there a way to compile these examples on mac ? I don’t renounce to make them work, I’ll open a pull request if I find a correct way to fix this.
All examples just say:
ondrej@eagle:~/repos/OpenGL-Examples/build(master)$ ./00skeleton
failed to open window
It's caused by this part:
// create a window
GLFWwindow *window;
if((window = glfwCreateWindow(width, height, "00skeleton", 0, 0)) == 0) {
std::cerr << "failed to open window" << std::endl;
glfwTerminate();
return 1;
}
But I don't know how to fix it.
Hi,
I have build these projects with CodeBlocks and MinGW on windows.
Everything is correct except compute shader nbody.
I have some errors in Code Blocks:
||=== Build: all in OPENGLEXAMPLES (compiler: GNU GCC Compiler) ===|
E:\Lab\OpenGL-Examples\13compute_shader_nbody.cpp||In function 'int main()':|
E:\Lab\OpenGL-Examples\13compute_shader_nbody.cpp|368|error: taking address of temporary array|
CMakeFiles\13compute_shader_nbody.dir\build.make|54|recipe for target 'CMakeFiles/13compute_shader_nbody.dir/13compute_shader_nbody.cpp.obj' failed|
CMakeFiles\Makefile2|636|recipe for target 'CMakeFiles/13compute_shader_nbody.dir/all' failed|
E:\Lab\OpenGL-Examples\build\Makefile|116|recipe for target 'all' failed|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 3 second(s)) ===|
I suspect line 368
glBindBuffersBase(GL_SHADER_STORAGE_BUFFER, 0, 2, (const GLuint[]){positions_vbo, velocities_vbo});
Please give me some advice how fix this line.
build$ make
Scanning dependencies of target glxw
[ 1%] Building C object glxw/CMakeFiles/glxw.dir/src/glxw.c.o
In file included from /Users/anonymous/git/OpenGL/OpenGL-Examples/build/glxw/src/glxw.c:1:
In file included from /Users/anonymous/git/OpenGL/OpenGL-Examples/build/glxw/include/GLXW/glxw.h:7:
/Users/anonymous/git/OpenGL/OpenGL-Examples/build/glxw/include/GL/glcorearb.h:82:10: fatal error: 'KHR/khrplatform.h' file not found
#include <KHR/khrplatform.h>
^~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [glxw/CMakeFiles/glxw.dir/src/glxw.c.o] Error 1
make[1]: *** [glxw/CMakeFiles/glxw.dir/all] Error 2
make: *** [all] Error 2
I reckon this is because it's not getting the opengl version it wants, any chance of some more error reporting ?
These ones got the error:
./11tesselation
./12shader_image_load_store
./13compute_shader_nbody
BTW, these are all all very nice examples :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.