cginternals / glbinding Goto Github PK
View Code? Open in Web Editor NEWA C++ binding for the OpenGL API, generated using the gl.xml specification.
Home Page: https://glbinding.org
License: MIT License
A C++ binding for the OpenGL API, generated using the gl.xml specification.
Home Page: https://glbinding.org
License: MIT License
A list of ToDos and issues for the XML-based OpenGL spec:
GLbitfield
should be replaced by appropriate bitfield groupGLenum
should be replaced by appropriate enum groupI have built and installed glbinding on Mac OS X 10.10.2 with XCode 6.2 and all the default options. However, the install name of the installed library seems wrong:
$ otool -D /usr/local/lib/libglbinding.dylib
/usr/local/lib/libglbinding.dylib:
libglbinding.dylib
The full path should be listed instead of only the filename. The expected output would be:
$ otool -D /usr/local/lib/libglbinding.dylib
/usr/local/lib/libglbinding.dylib:
/usr/local/lib/libglbinding.dylib
As a work-around, one can run this command to fix the install name:
$ sudo install_name_tool -id /usr/local/lib/libglbinding.dylib /usr/local/lib/libglbinding.dylib
But with the proper cmake settings, this should not be necessary.
Probably related is the following warning from cmake:
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
glbinding
/usr/include/glbinding/callbacks.h:30:5: error: expected identifier before numeric constant
enum class CallbackMask : unsigned char
{
None = 0x00,
...
};
None was declared in X11/X.h as:
Maybe this will work:
enum class CallbackMask : unsigned char
{
None = 0x00,
Unresolved = 0x01,
Before = 0x02,
After = 0x04,
Parameters = 0x08,
ReturnValue = 0x10,
ParametersAndReturnValue = Parameters | ReturnValue,
BeforeAndAfter = Before | After
};
You probably know about this - is there really nothing that can be done about it? I just cut down the compilation time of a small project from just about 3 minutes to 55 seconds by replacing a dozen or so gl.h
with the actually needed types.h
, enum.h
, bitfield.h
, functions.h
... The thing is just, this is a lot of manual work.
I'd rather like to be able to just include gl.h
and be able to use GL without killing my build times. Can we maybe outsource some non-GL functionality from gl.h
to external headers? Maybe employ defines to disable features we don't need?
(I haven't bothered to figure out what's actually going on in gl.h
, just pointing this out in general)
When I run the examples "meta" (glbinding make with GL_BY_STRINGS) the program crashed at Meta_BitfieldsByString.cpp line 13. And I tested when write block of code like that with my own, my program also crashed(may be vs12 not support this kind of code).
And when I run the example "callbacks" I got problem at Function.hpp line 30 with a error message "Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call". (enum class value can not as an interger?).
(I run this program in windows 7 and build it with visual studio 2013)
A lot of other libraries define macros which clash with the opengl symbols.
Currently we add underscores to avoid that.
Is there a better way?
commit 34dbf34 does not compile on windows ...
problem is probably that constexpr is not supported by the vs2013 compiler:
http://stackoverflow.com/questions/20264644/constexpr-not-compiling-in-vc2013
Currently, per-feature type declarations only exist in the functions....h
header, which seems rather large just to get a few type declarations.
glbinding contains several classes without members, so why not transforming it to a namespace?
Currently found classes:
The following error occurs when trying to build as a static library.
CMake Error at source/glbinding/CMakeLists.txt:162 (install):
install TARGETS given no ARCHIVE DESTINATION for static library target
"glbinding".
It should not take more than brew install glbinding
on Mac OS to get started.
Homebrew (http://brew.sh/) has become the de-facto standard of installing libraries and unix tools on Mac OS. glbinding adoption is definitively slowed down on Mac OS through not providing a brew recipe in the mainline of homebrew.
Hi,
I just built glbinding with:
mkdir build-release
cd build-release
cmake .. # I used ccmake, but it doesn't matter now
make
make pack
I tried to install generated packages with
sudo dpkg -i glbinding-1.0.5-dev.deb glbinding-1.0.5-runtime.deb
but dpkg complains that there's conflict because glbinding-runtime.deb tries to overwrite file /usr/share/glbinding/revision
which belongs to glbinding-dev.deb
Edit: It can be fixed with --force-overwrite
option added to dpkg invocation, but I think it's not the way.
When trying to build on a Ubuntu Travis-CI worker with clang-3.5, I get many error messages like this:
In file included from /home/travis/build/xythobuz/OpenRaider/glbinding/source/glbinding/source/Binding.cpp:2:
In file included from /home/travis/build/xythobuz/OpenRaider/glbinding/source/glbinding/include/glbinding/Binding.h:9:
/home/travis/build/xythobuz/OpenRaider/glbinding/source/glbinding/include/glbinding/gl/types.h:102:1: error:
'hash' defined as a struct template here but previously declared as a
class template [-Werror,-Wmismatched-tags]
struct hash<gl::GLenum>
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_bvector.h:523:31: note:
did you mean struct here?
template<typename> friend class hash;
I have removed the -Werror
compiler flag in cmake/PlatformLinuxGCC.cmake as a work-around. That allows me to build the library.
The implementation of wrapString() does not expect a nullptr value. This can cause the program to crash.
I've noticed this problem when attaching an After callback and calling glGetString() with an invalid enum. Trying to print the return value (which is nullptr in this case) will cause a segfault. The problem could easily be fixed by replacing:
ss << value;
by
ss << ((value == nullptr) ? "nullptr" : value);
The following snippet produces error C2668: 'gl45core::glGetUniformSubroutineuiv' : ambiguous call to overloaded function
#include <glbinding/gl/functions.h> // < imagine this was included by a 3rd party library (e.g. globjects.hpp)
#include <glbinding/gl/functions45core.h>
#include <glbinding/gl/enum45core.h>
using namespace gl45core;
int main(int argn, char** argv) {
GLuint index = 0;
glGetUniformSubroutineuiv(GL_VERTEX_SHADER, 0, &index);
}
Full log:
1>c:\users\jole\documents\visual studio 2013\projects\glbindingambiguity\glbindingambiguity\main.cpp(10): error C2668: 'gl45core::glGetUniformSubroutineuiv' : ambiguous call to overloaded function
1> d:\projects\glbinding\source\glbinding\include\glbinding\gl\functions45core.h(311): could be 'void gl45core::glGetUniformSubroutineuiv(gl45core::GLenum,gl45core::GLint,gl45core::GLuint *)'
1> d:\projects\glbinding\source\glbinding\include\glbinding\gl\functions.h(1017): or 'void gl::glGetUniformSubroutineuiv(gl::GLenum,gl::GLint,gl::GLuint *)' [found using argument-dependent lookup]
1> while trying to match the argument list '(const gl::GLenum, int, gl45core::GLuint *)'
If the first line is removed, the program compiles as expected. The problem is caused by argument dependent lookup and the fact that enums constants in the gl45core
namespace use a type from the gl
namespace. In order to fix this, per-feature declarations should be fully independent from the gl
namespace.
Consider this example:
GLuint buffer;
GLuint buffer2;
GLsizei size;
void* ptr;
GLbitfield flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT; // Not compiling
glNamedBufferStorage(buffer, size, ptr, flags);
glNamedBufferStorage(buffer2, size, ptr, flags);
This isn't allowed by glbinding as far as as I know, due to the lack of conversion of the Mask* types to GLbitfield. But this kind of uses are often encountered in OpenGL code. This problem also arise when wrapping glbinding functions into objects.
// OpenGL reference
void glNamedBufferStorage(GLuint buffer, GLsizei size, const void *data, GLbitfield flags);
// glbinding
void glNamedBufferStorage(GLuint buffer, GLsizei size, const void * data, MapBufferUsageMask flags)
GLbitfield
enums are required to be usable as flags (e.g., glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
I'm compiling glbinding with TDM GCC 4.9.2 64 bit in Windows 7.
With glbinding 1.0.4 I never had problems, while with 1.0.5 the compiler gives me "unrecognized command line options" error.
Removing this instruction @ line 137 in "source/glbinding/CMakeLists.txt" from glbinding 1.0.5 sources:
target_compile_options(${target} PRIVATE ${DEFAULT_COMPILE_FLAGS})
resolved the problem. This line was not present in glbinding 1.0.4.
Thank you for your attention and best regards
There are several problems:
warning C4244: 'argument' : conversion from 'unsigned __int64' to 'glbinding::RingBuffer<glbinding::logging::BufferType>::SizeType', possible loss of data
(RingBuffer
uses SizeType
(=unsigned int
) in its external interface, but std::int64_t
internally)RingBuffer.hpp(93): warning C4127: conditional expression is constant
RingBuffer.hpp(133): warning C4389: '!=' : signed/unsigned mismatch
callbacks.cpp(32): error C2797: 'glbinding::FunctionCall::parameters': list initialization inside member initializer list or non-static data member initializer is not implemented
RingBuffer.h(49): error C2039: 'mutex' : is not a member of 'std'
(missing include)error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl glbinding::logging::log(bool)" (__imp_?log@logging@glbinding@@YAX_N@Z) referenced in function "void __cdecl compare(void)" (?compare@@YAXXZ)
(and two more)Warnings must be fixed as well, as they are treated as errors.
Most should be easily fixable, but was there a reason for the first issue?
GLFW indicates that function pointers may vary from context to context.
http://www.glfw.org/docs/latest/group__context.html#ga35f1837e6f666781842483937612f163
This is because of
d = sorted([ es[0] for v, es in groupEnumsByValue(pureEnums).items() ])
in gen_meta.py:68
The obvious fix would be to include all elements of es
into the array list instead of just the first but this seems a bit too obvious to me, so I'll just raise this as an issue as there probably was an intend behind just inserting index 0.
gcc gives error:
../source/glbinding/source/ProcAddress.cpp: In function 'void (* glbinding::getProcAddress(const char_))()':
../source/glbinding/source/ProcAddress.cpp:27:60: error: cannot convert 'const wchar_t_' to 'LPCSTR {aka const char_}' for argument '1' to 'HINSTANCE___ LoadLibraryA(LPCSTR)'
static HMODULE module = LoadLibrary(L"OPENGL32.DLL");
I'm not sure if this is related to gcc (I use gcc-4.9.1 Rev3 x86-64 from MSYS2)
remove the L prefix fix it
Provide virtual contexts on top of real OpenGL contexts so that one real context can be used with multiple glbinding configurations including
That also enables applications and depending libraries to use multiple configurations per context, too.
Derived informations from the actual OpenGL context can be shared (e.g. function pointers).
The following program encounters a run-time failure:
#include <SFML\Window.hpp>
#include <glbinding\gl\gl.h>
#include <glbinding\Binding.h>
using namespace gl;
int main(int argc, const char* argv[])
{
sf::Window window(sf::VideoMode(640, 480), "GLBinding Test");
glbinding::Binding::initialize();
glClearColor(0.0f, 0.5f, 0.8f, 1.0f);
// truncated
}
With the error message:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Which occurs on line 71 of Function.hpp and the call stack for the error originates from the glClearColor
call:
template <typename... Arguments>
struct FunctionHelper<void, Arguments...>
{
void call(const glbinding::Function<void, Arguments...> * function, Arguments&&... arguments) const
{
// truncated
if (function->isEnabled(glbinding::CallbackMask::After)) // line 71
function->after(functionCall);
}
};
The toolchain used to build the library:
The same tools were used to build SFML and GLEW which have no issues with the same program.
So why not transforming it to a namespace?
Hi,
I recently tried to extract the shader compilation log with the usual approach:
GLint status;
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE) {
...
}
But this doesn't compile because of different types (GLint and const gl::GLboolean). From my pov that is not what I expect. Of course I can use !status
, but this behaviour breaks the compatibilty, isnt't it?
seems that ContextHandler.cpp include glxew.h which is from glew,but glx.h is enough for glXGetCurrentContext. this leads compile error when glew is not installed
glbinding cannot currently be used as a submodule. This is because glbinding expects the .git directory to be in it's root source directory, which is not the case when it is cloned as a submodule. When cloned as a submodule however there will be a .git file in it's root source directory with something like gitdir: ../../.git/modules/ThirdParty/glbinding
pointing to it's .git directory and it should be able to use this.
In files glbinding/include/glbinding/Function.h and other unnamed namespaces are used, so all classes declared insde are in fact global, because it's header file included from gl*.h.
I think such helper classes shouldn't pollute global namespace.
I just had compilation error because of this issue.
I tried to use error checking after-callbacks as shown in the main README, but using a glGetError()
call in the callback caused it to loop back into the callback. Being new the library, I had no idea why my program became completely unresponsive. After some reading, I found using Binding::GetError.directCall()
was the correct way to go.
Maybe the example should be changed so other people don't run into the same issue? Or is this possibly a bug?
Currently, per-feature include headers are structured this way:
glbinding/gl/functions.h
glbinding/gl/functions10.h
// ...
glbinding/gl/functions32.h
glbinding/gl/functions32core.h
glbinding/gl/functions32ext.h
// ...
I suggest using this structure for glbinding 2.0:
glbinding/gl/functions.h
glbinding/gl10/functions.h
// ...
glbinding/gl32/functions.h
glbinding/gl32core/functions.h
glbinding/gl32ext/functions.h
// ...
explicitly model test or example for testing multi-context behavior of function binding as well as different feature binding behavior.
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.