-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to exclude Khronos platform code #211
Comments
This is not that easy anymore, previously only GLES types and functions depended on khronos types, now more or less everything references the khronos types: typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef void GLvoid;
typedef khronos_int8_t GLbyte;
typedef khronos_uint8_t GLubyte;
typedef khronos_int16_t GLshort;
typedef khronos_uint16_t GLushort;
typedef int GLint;
typedef unsigned int GLuint;
typedef khronos_int32_t GLclampx;
typedef int GLsizei;
typedef khronos_float_t GLfloat;
typedef khronos_float_t GLclampf;
typedef double GLdouble;
typedef double GLclampd;
typedef void *GLeglClientBufferEXT;
typedef void *GLeglImageOES;
typedef char GLchar;
typedef char GLcharARB;
#ifdef __APPLE__
typedef void *GLhandleARB;
#else
typedef unsigned int GLhandleARB;
#endif
typedef khronos_uint16_t GLhalf;
typedef khronos_uint16_t GLhalfARB;
typedef khronos_int32_t GLfixed;
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef khronos_intptr_t GLintptr;
#else
typedef khronos_intptr_t GLintptr;
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef khronos_intptr_t GLintptrARB;
#else
typedef khronos_intptr_t GLintptrARB;
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef khronos_ssize_t GLsizeiptr;
#else
typedef khronos_ssize_t GLsizeiptr;
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef khronos_ssize_t GLsizeiptrARB;
#else
typedef khronos_ssize_t GLsizeiptrARB;
#endif
typedef khronos_int64_t GLint64;
typedef khronos_int64_t GLint64EXT;
typedef khronos_uint64_t GLuint64;
typedef khronos_uint64_t GLuint64EXT;
typedef struct __GLsync *GLsync; It's an enhancement but nothing with high priority right now, especially since you can just generate a header only version now which includes all the definitions of khronos types within the header. |
I am generating a header-only version that way, but the Khronos code in that header is what I want to cut out.
Having not read the generator code, If I were to manually replace the Khronos types in this list with the types they resolve to, would that be enough for Glad 2 to have this feature?
…On May 23, 2019 8:21:55 AM MDT, David Herberth ***@***.***> wrote:
This is not that easy anymore, previously only GLES types and functions
depended on khronos types, now more or less everything references the
khronos types:
```c
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef void GLvoid;
typedef khronos_int8_t GLbyte;
typedef khronos_uint8_t GLubyte;
typedef khronos_int16_t GLshort;
typedef khronos_uint16_t GLushort;
typedef int GLint;
typedef unsigned int GLuint;
typedef khronos_int32_t GLclampx;
typedef int GLsizei;
typedef khronos_float_t GLfloat;
typedef khronos_float_t GLclampf;
typedef double GLdouble;
typedef double GLclampd;
typedef void *GLeglClientBufferEXT;
typedef void *GLeglImageOES;
typedef char GLchar;
typedef char GLcharARB;
#ifdef __APPLE__
typedef void *GLhandleARB;
#else
typedef unsigned int GLhandleARB;
#endif
typedef khronos_uint16_t GLhalf;
typedef khronos_uint16_t GLhalfARB;
typedef khronos_int32_t GLfixed;
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&
(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef khronos_intptr_t GLintptr;
#else
typedef khronos_intptr_t GLintptr;
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&
(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef khronos_intptr_t GLintptrARB;
#else
typedef khronos_intptr_t GLintptrARB;
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&
(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef khronos_ssize_t GLsizeiptr;
#else
typedef khronos_ssize_t GLsizeiptr;
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&
(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef khronos_ssize_t GLsizeiptrARB;
#else
typedef khronos_ssize_t GLsizeiptrARB;
#endif
typedef khronos_int64_t GLint64;
typedef khronos_int64_t GLint64EXT;
typedef khronos_uint64_t GLuint64;
typedef khronos_uint64_t GLuint64EXT;
typedef struct __GLsync *GLsync;
```
It's an enhancement but nothing with high priority right now,
especially since you can just generate a header only version now which
includes all the definitions of khronos types within the header.
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#211 (comment)
|
You can edit the specification and remove all links (require instructions) to khrplatform. Alternatively to do it in glad, you'd probably need a pre processor that does the same, go through all types remove the khrplatform requirement and replace the types. |
It may not be as simple as a dictionary lookup with this:
I'm open to suggestions. EDIT: There are generic fallback types for everything except the above. OpenGL and EGL use
Because |
The problem is, if you put the mapping that is in And the mapping needs to be maintained, this already broke once. What is the usecase (with a header only build) that you would not want to have |
Not true. khrplatform.h does a song and dance where it tries to find the "best" int32/uint32/int64/uint64 types for the platform, while my substitutions just use the fixed-size fallbacks, which I consider to be more correct.
True, but they would be platforms that don't support fixed-size integers, which are IMHO not worthwhile platforms anyways. 32-bit APIs (slightly older OpenGL) simply won't have 64-bit types to resolve, so compatibility would not change for them.
Please elaborate.
It's just a nice-to-have. It's easy to forget about the khrplatform code in there, which is subject to license terms that are easy to ignore. I'd rather have slightly smaller headers that make more sense for my way of thinking. |
Every time new types are introduced or the names change, the "internal" mapping is going to be out of sync. This affects all non-C generators a lot more than the C generator since most of the time it's just new C types, but it happened with C before: KhronosGroup/OpenGL-Registry@d146746
That's the thing, I do agree with you here, but at the end of the day it's "just" generated code. |
The scope of this proposed feature is C, C++, and languages that can use C such as D. It will not be available for OpenGL SC or Vulkan SC as that could raise compliance issues. In other words, this is a feature for game engines only. There are plenty of engines that copy the functions into their own code (such as Lobster) but I don't want to do that because Glad feels better. I don't see a problem with
If it's in my source repo, it's my generated code, and I love it like the rest of my code. |
The link to the Khronos commit was an example of what broke glad. It is possible to workaround it
Yeah, I think having it as an option doesn't hurt. I'll have to look into a proper way how to implement it, since this kind of breaks the requirement system of the specifications. The types "require" khrplatform and not One option would be to simply replace khrplatform with a custom khrplatform that exposes the same types but is "simpler", but that feels like a half-assed solution, I'd prefer something where only the required types end up in the header (without
Agreed. |
I know. Not sure how a workaround would work, but I'm content with the idea of assuming things won't break in the future after substituting types.
Agreed. |
I dont think this is feasible anymore and already is broken in glad 1, glad 2 includes a header only option which embedds the external headers. |
In generated Glad 2 headers, there are a few hundred lines of code prefixed with khronos_ or KHRONOS_, none of which I use in my projects. Some of the khronos_ types directly translate to GL types and could be replaced with standard C/C++ types instead.
I recall that in the past, Glad had an option to exclude the Khronos code. It would be nice to have that feature.
The text was updated successfully, but these errors were encountered: