matus-chochlik / oglplus

OGLplus is a collection of open-source, cross-platform libraries which implement an object-oriented facade over the OpenGL® (version 3 and higher) and also OpenAL® (version 1.1) and EGL (version 1.4) C-language APIs. It provides wrappers which automate resource and object management and make the use of these libraries in C++ safer and more convenient.
http://oglplus.org/
Boost Software License 1.0
492 stars 72 forks source link

Fails to build with OpenGL 3.0 #109

Open bfops opened 9 years ago

bfops commented 9 years ago
[ 11%] Building CXX object source/lib/oglplus/CMakeFiles/oglplus.dir/text.cpp.o
In file included from /home/ben/devl/oglplus/source/lib/oglplus/text.cpp:33:0:
/home/ben/devl/oglplus/include/oglplus/text/bitmap_glyph.hpp:17:2: error: #error "The Bitmap glyph text rendering utility requires GL version 3.1"
 #error "The Bitmap glyph text rendering utility requires GL version 3.1"
  ^
In file included from /home/ben/devl/oglplus/source/lib/oglplus/text.cpp:34:0:
/home/ben/devl/oglplus/include/oglplus/text/stb_truetype.hpp:17:2: error: #error "The STB TrueType text rendering utility requires GL version 3.1"
 #error "The STB TrueType text rendering utility requires GL version 3.1"
  ^
In file included from /home/ben/devl/oglplus/include/oglplus/text/bitmap_glyph/pager.hpp:145:0,
                 from /home/ben/devl/oglplus/include/oglplus/text/bitmap_glyph/font_essence.hpp:19,
                 from /home/ben/devl/oglplus/include/oglplus/text/bitmap_glyph.hpp:22,
                 from /home/ben/devl/oglplus/source/lib/oglplus/text.cpp:33:
/home/ben/devl/oglplus/implement/oglplus/text/bitmap_glyph/pager.ipp: In constructor ‘oglplus::text::BitmapGlyphPager::BitmapGlyphPager(oglplus::text::BitmapGlyphRenderingBase&, oglplus::TextureUnitSelector, GLsizei)’:
/home/ben/devl/oglplus/implement/oglplus/text/bitmap_glyph/pager.ipp:98:2: error: ‘Buffer’ is not a member of ‘oglplus::Texture {aka oglplus::Object<oglplus::ObjectOps<oglplus::tag::ExplicitSel, oglplus::tag::Texture> >}’
  Texture::Buffer(
  ^
source/lib/oglplus/CMakeFiles/oglplus.dir/build.make:376: recipe for target 'source/lib/oglplus/CMakeFiles/oglplus.dir/text.cpp.o' failed
make[2]: *** [source/lib/oglplus/CMakeFiles/oglplus.dir/text.cpp.o] Error 1
CMakeFiles/Makefile2:5000: recipe for target 'source/lib/oglplus/CMakeFiles/oglplus.dir/all' failed
make[1]: *** [source/lib/oglplus/CMakeFiles/oglplus.dir/all] Error 2
Makefile:113: recipe for target 'all' failed
make: *** [all] Error 2

This seems intentional - should the configure script just fail if it can't find OpenGL > 3.0, or should this component just be disabled?

bfops commented 9 years ago

Ah, I notice I have OpenGL version string: 3.0 Mesa 10.3.2 as well as OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.3.2 installed; does oglplus rely on non-core features?

bfops commented 9 years ago

Oops, I was building the develop branch. The build succeeds for me on master, but the examples seem to be using the non-core OpenGL. I'm getting a lot of errors like:

Program build error
Source file: '/home/ben/devl/oglplus/implement/oglplus/shader.ipp'
Source line: 50
Source function: 'Compile'
Message: 'OpenGL shading language compilation error'
GL constant: 'VERTEX_SHADER'
Object type: 'SHADER'
Object: (1)
Log:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

001_triangle: /home/ben/devl/oglplus/example/oglplus/glut_main.cpp:117: static void oglplus::SingleExample::CloseFunc(): Assertion `SingleInstance()' failed.
Aborted
bfops commented 9 years ago

The master build only succeeds because ./configure.sh infers GL_VERSION_3_3; it still fails if I pass --max-gl-version 3_1 or lower. When the build succeeds with 3_2 or 3_3, I get those errors from the examples.

bfops commented 9 years ago

The cloud_trace example fails because this operator is only defined in 3_2 and above in include/oglplus/framebuffer.hpp:

inline FramebufferTarget operator << (
    FramebufferTargetAndAttch taa,
    TextureName tex
)

Removing that example makes the build succeed with 3_1 for me.

matus-chochlik commented 9 years ago

Hi,

yeah, most of the examples use GLSL 3.30 or higher, there are however some using GLSL 1.40. And (un)fortunately most of my machines support at least GL version 3.3. I'll have to install Mesa somewhere and test it with that.

bfops commented 9 years ago

I'm noticing that quite a few of the examples are labeled OpenGL 3.0 and still use GLSL 330; downgrading to #version 130 makes them run fine.

Also, quite a few examples are labeled GL_VERSION_3_0 but use geometry shaders, which need GL_VERSION_3_2.

If you don't feel like doing all that fiddling, I can work on a PR to fix the GL_VERSION_3_0 examples to either work with OpenGL 3.0 or to have a higher version constraint.

I'm also a little confused because my machine does support OpenGL 3.3 (GLSL 330) core profile, but the binaries don't seem to realize they have that option. It's probably an environment issue on my end, but I don't really know how to go about diagnosing it..

Unfortunately, I'm still at a loss for getting the build to pass with --max-gl-version 3_0, even without the cloud_trace example built in.

bfops commented 9 years ago

Oh, the configure script does mention that the build will fail with OpenGL 3.0. I feel like it should be possible to get a successful build with 3.0 and 3.1 though.

I actually did manage to get the examples to use the core profile instead of compatibility, just by adding glutInitContextVersion (3, 3); to glut_main.cpp, and all the ones I tried worked fine.