mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
make legacy gl2.0 work without BaseVertex extensions
This commit is contained in:
@@ -75,9 +75,6 @@ opengl_vbogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream
|
|||||||
chunk.vertices.data() );
|
chunk.vertices.data() );
|
||||||
chunkrecord.is_good = true;
|
chunkrecord.is_good = true;
|
||||||
}
|
}
|
||||||
if( m_activestreams != Streams ) {
|
|
||||||
bind_streams( Units, Streams );
|
|
||||||
}
|
|
||||||
// ...render...
|
// ...render...
|
||||||
if( chunkrecord.index_count > 0 ) {
|
if( chunkrecord.index_count > 0 ) {
|
||||||
/*
|
/*
|
||||||
@@ -86,13 +83,28 @@ opengl_vbogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream
|
|||||||
chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
|
chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
|
||||||
chunkrecord.vertex_offset );
|
chunkrecord.vertex_offset );
|
||||||
*/
|
*/
|
||||||
::glDrawRangeElementsBaseVertex(
|
if (GLAD_GL_VERSION_3_2 || GLAD_GL_ARB_draw_elements_base_vertex) {
|
||||||
chunk.type,
|
if( m_activestreams != Streams ) {
|
||||||
0, chunkrecord.vertex_count,
|
bind_streams( Units, Streams );
|
||||||
chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
|
}
|
||||||
chunkrecord.vertex_offset );
|
::glDrawRangeElementsBaseVertex(
|
||||||
|
chunk.type,
|
||||||
|
0, chunkrecord.vertex_count,
|
||||||
|
chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ),
|
||||||
|
chunkrecord.vertex_offset );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bind_streams( Units, Streams, chunkrecord.vertex_offset );
|
||||||
|
::glDrawRangeElements(
|
||||||
|
chunk.type,
|
||||||
|
0, chunkrecord.vertex_count,
|
||||||
|
chunkrecord.index_count, GL_UNSIGNED_INT, reinterpret_cast<void const *>( chunkrecord.index_offset * sizeof( gfx::basic_index ) ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if( m_activestreams != Streams ) {
|
||||||
|
bind_streams( Units, Streams );
|
||||||
|
}
|
||||||
::glDrawArrays( chunk.type, chunkrecord.vertex_offset, chunkrecord.vertex_count );
|
::glDrawArrays( chunk.type, chunkrecord.vertex_offset, chunkrecord.vertex_count );
|
||||||
}
|
}
|
||||||
// ...post-render cleanup
|
// ...post-render cleanup
|
||||||
@@ -211,10 +223,10 @@ opengl_vbogeometrybank::delete_buffer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
opengl_vbogeometrybank::bind_streams( gfx::stream_units const &Units, unsigned int const Streams ) {
|
opengl_vbogeometrybank::bind_streams( gfx::stream_units const &Units, unsigned int const Streams, size_t offset ) {
|
||||||
|
|
||||||
if( Streams & gfx::stream::position ) {
|
if( Streams & gfx::stream::position ) {
|
||||||
::glVertexPointer( 3, GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast<void const *>( 0 ) );
|
::glVertexPointer( 3, GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast<void const *>( sizeof( gfx::basic_vertex ) * offset ) );
|
||||||
::glEnableClientState( GL_VERTEX_ARRAY );
|
::glEnableClientState( GL_VERTEX_ARRAY );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -222,14 +234,14 @@ opengl_vbogeometrybank::bind_streams( gfx::stream_units const &Units, unsigned i
|
|||||||
}
|
}
|
||||||
// NOTE: normal and color streams share the data, making them effectively mutually exclusive
|
// NOTE: normal and color streams share the data, making them effectively mutually exclusive
|
||||||
if( Streams & gfx::stream::normal ) {
|
if( Streams & gfx::stream::normal ) {
|
||||||
::glNormalPointer( GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast<void const *>( 12 ) );
|
::glNormalPointer( GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast<void const *>( 12 + sizeof( gfx::basic_vertex ) * offset ) );
|
||||||
::glEnableClientState( GL_NORMAL_ARRAY );
|
::glEnableClientState( GL_NORMAL_ARRAY );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
::glDisableClientState( GL_NORMAL_ARRAY );
|
::glDisableClientState( GL_NORMAL_ARRAY );
|
||||||
}
|
}
|
||||||
if( Streams & gfx::stream::color ) {
|
if( Streams & gfx::stream::color ) {
|
||||||
::glColorPointer( 3, GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast<void const *>( 12 ) );
|
::glColorPointer( 3, GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast<void const *>( 12 + sizeof( gfx::basic_vertex ) * offset ) );
|
||||||
::glEnableClientState( GL_COLOR_ARRAY );
|
::glEnableClientState( GL_COLOR_ARRAY );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -238,7 +250,7 @@ opengl_vbogeometrybank::bind_streams( gfx::stream_units const &Units, unsigned i
|
|||||||
if( Streams & gfx::stream::texture ) {
|
if( Streams & gfx::stream::texture ) {
|
||||||
for( auto unit : Units.texture ) {
|
for( auto unit : Units.texture ) {
|
||||||
::glClientActiveTexture( GL_TEXTURE0 + unit );
|
::glClientActiveTexture( GL_TEXTURE0 + unit );
|
||||||
::glTexCoordPointer( 2, GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast<void const *>( 24 ) );
|
::glTexCoordPointer( 2, GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast<void const *>( 24 + sizeof( gfx::basic_vertex ) * offset ) );
|
||||||
::glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
::glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||||
}
|
}
|
||||||
m_activetexturearrays = Units.texture;
|
m_activetexturearrays = Units.texture;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ private:
|
|||||||
delete_buffer();
|
delete_buffer();
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
bind_streams( gfx::stream_units const &Units, unsigned int const Streams );
|
bind_streams(gfx::stream_units const &Units, unsigned int const Streams , size_t offset = 0);
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
release_streams();
|
release_streams();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
OpenGL, OpenGL ES loader generated by glad 0.1.34 on Wed Jan 20 19:37:38 2021.
|
OpenGL, OpenGL ES loader generated by glad 0.1.34 on Fri Jan 22 22:11:52 2021.
|
||||||
|
|
||||||
Language/Generator: C/C++
|
Language/Generator: C/C++
|
||||||
Specification: gl
|
Specification: gl
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
Extensions:
|
Extensions:
|
||||||
GL_ARB_clip_control,
|
GL_ARB_clip_control,
|
||||||
GL_ARB_direct_state_access,
|
GL_ARB_direct_state_access,
|
||||||
|
GL_ARB_draw_elements_base_vertex,
|
||||||
GL_ARB_multi_bind,
|
GL_ARB_multi_bind,
|
||||||
GL_ARB_texture_filter_anisotropic,
|
GL_ARB_texture_filter_anisotropic,
|
||||||
GL_EXT_clip_control,
|
GL_EXT_clip_control,
|
||||||
@@ -26,9 +27,9 @@
|
|||||||
Reproducible: False
|
Reproducible: False
|
||||||
|
|
||||||
Commandline:
|
Commandline:
|
||||||
--profile="compatibility" --api="gl=3.3,gles2=3.2" --generator="c" --spec="gl" --no-loader --extensions="GL_ARB_clip_control,GL_ARB_direct_state_access,GL_ARB_multi_bind,GL_ARB_texture_filter_anisotropic,GL_EXT_clip_control,GL_EXT_framebuffer_object,GL_EXT_geometry_shader,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_sRGB,GL_GREMEDY_string_marker,GL_KHR_debug,GL_OES_draw_elements_base_vertex"
|
--profile="compatibility" --api="gl=3.3,gles2=3.2" --generator="c" --spec="gl" --no-loader --extensions="GL_ARB_clip_control,GL_ARB_direct_state_access,GL_ARB_draw_elements_base_vertex,GL_ARB_multi_bind,GL_ARB_texture_filter_anisotropic,GL_EXT_clip_control,GL_EXT_framebuffer_object,GL_EXT_geometry_shader,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_sRGB,GL_GREMEDY_string_marker,GL_KHR_debug,GL_OES_draw_elements_base_vertex"
|
||||||
Online:
|
Online:
|
||||||
https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&api=gl%3D3.3&api=gles2%3D3.2&extensions=GL_ARB_clip_control&extensions=GL_ARB_direct_state_access&extensions=GL_ARB_multi_bind&extensions=GL_ARB_texture_filter_anisotropic&extensions=GL_EXT_clip_control&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_geometry_shader&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_EXT_texture_sRGB&extensions=GL_GREMEDY_string_marker&extensions=GL_KHR_debug&extensions=GL_OES_draw_elements_base_vertex
|
https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&api=gl%3D3.3&api=gles2%3D3.2&extensions=GL_ARB_clip_control&extensions=GL_ARB_direct_state_access&extensions=GL_ARB_draw_elements_base_vertex&extensions=GL_ARB_multi_bind&extensions=GL_ARB_texture_filter_anisotropic&extensions=GL_EXT_clip_control&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_geometry_shader&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_EXT_texture_sRGB&extensions=GL_GREMEDY_string_marker&extensions=GL_KHR_debug&extensions=GL_OES_draw_elements_base_vertex
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -4774,6 +4775,10 @@ typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC)(GLuint id, GLuint buff
|
|||||||
GLAPI PFNGLGETQUERYBUFFEROBJECTUIVPROC glad_glGetQueryBufferObjectuiv;
|
GLAPI PFNGLGETQUERYBUFFEROBJECTUIVPROC glad_glGetQueryBufferObjectuiv;
|
||||||
#define glGetQueryBufferObjectuiv glad_glGetQueryBufferObjectuiv
|
#define glGetQueryBufferObjectuiv glad_glGetQueryBufferObjectuiv
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef GL_ARB_draw_elements_base_vertex
|
||||||
|
#define GL_ARB_draw_elements_base_vertex 1
|
||||||
|
GLAPI int GLAD_GL_ARB_draw_elements_base_vertex;
|
||||||
|
#endif
|
||||||
#ifndef GL_ARB_multi_bind
|
#ifndef GL_ARB_multi_bind
|
||||||
#define GL_ARB_multi_bind 1
|
#define GL_ARB_multi_bind 1
|
||||||
GLAPI int GLAD_GL_ARB_multi_bind;
|
GLAPI int GLAD_GL_ARB_multi_bind;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
OpenGL, OpenGL ES loader generated by glad 0.1.34 on Wed Jan 20 19:37:38 2021.
|
OpenGL, OpenGL ES loader generated by glad 0.1.34 on Fri Jan 22 22:11:52 2021.
|
||||||
|
|
||||||
Language/Generator: C/C++
|
Language/Generator: C/C++
|
||||||
Specification: gl
|
Specification: gl
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
Extensions:
|
Extensions:
|
||||||
GL_ARB_clip_control,
|
GL_ARB_clip_control,
|
||||||
GL_ARB_direct_state_access,
|
GL_ARB_direct_state_access,
|
||||||
|
GL_ARB_draw_elements_base_vertex,
|
||||||
GL_ARB_multi_bind,
|
GL_ARB_multi_bind,
|
||||||
GL_ARB_texture_filter_anisotropic,
|
GL_ARB_texture_filter_anisotropic,
|
||||||
GL_EXT_clip_control,
|
GL_EXT_clip_control,
|
||||||
@@ -26,9 +27,9 @@
|
|||||||
Reproducible: False
|
Reproducible: False
|
||||||
|
|
||||||
Commandline:
|
Commandline:
|
||||||
--profile="compatibility" --api="gl=3.3,gles2=3.2" --generator="c" --spec="gl" --no-loader --extensions="GL_ARB_clip_control,GL_ARB_direct_state_access,GL_ARB_multi_bind,GL_ARB_texture_filter_anisotropic,GL_EXT_clip_control,GL_EXT_framebuffer_object,GL_EXT_geometry_shader,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_sRGB,GL_GREMEDY_string_marker,GL_KHR_debug,GL_OES_draw_elements_base_vertex"
|
--profile="compatibility" --api="gl=3.3,gles2=3.2" --generator="c" --spec="gl" --no-loader --extensions="GL_ARB_clip_control,GL_ARB_direct_state_access,GL_ARB_draw_elements_base_vertex,GL_ARB_multi_bind,GL_ARB_texture_filter_anisotropic,GL_EXT_clip_control,GL_EXT_framebuffer_object,GL_EXT_geometry_shader,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_sRGB,GL_GREMEDY_string_marker,GL_KHR_debug,GL_OES_draw_elements_base_vertex"
|
||||||
Online:
|
Online:
|
||||||
https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&api=gl%3D3.3&api=gles2%3D3.2&extensions=GL_ARB_clip_control&extensions=GL_ARB_direct_state_access&extensions=GL_ARB_multi_bind&extensions=GL_ARB_texture_filter_anisotropic&extensions=GL_EXT_clip_control&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_geometry_shader&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_EXT_texture_sRGB&extensions=GL_GREMEDY_string_marker&extensions=GL_KHR_debug&extensions=GL_OES_draw_elements_base_vertex
|
https://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&api=gl%3D3.3&api=gles2%3D3.2&extensions=GL_ARB_clip_control&extensions=GL_ARB_direct_state_access&extensions=GL_ARB_draw_elements_base_vertex&extensions=GL_ARB_multi_bind&extensions=GL_ARB_texture_filter_anisotropic&extensions=GL_EXT_clip_control&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_geometry_shader&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_EXT_texture_sRGB&extensions=GL_GREMEDY_string_marker&extensions=GL_KHR_debug&extensions=GL_OES_draw_elements_base_vertex
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -985,6 +986,7 @@ PFNGLWINDOWPOS3SPROC glad_glWindowPos3s = NULL;
|
|||||||
PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv = NULL;
|
PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv = NULL;
|
||||||
int GLAD_GL_ARB_clip_control = 0;
|
int GLAD_GL_ARB_clip_control = 0;
|
||||||
int GLAD_GL_ARB_direct_state_access = 0;
|
int GLAD_GL_ARB_direct_state_access = 0;
|
||||||
|
int GLAD_GL_ARB_draw_elements_base_vertex = 0;
|
||||||
int GLAD_GL_ARB_multi_bind = 0;
|
int GLAD_GL_ARB_multi_bind = 0;
|
||||||
int GLAD_GL_ARB_texture_filter_anisotropic = 0;
|
int GLAD_GL_ARB_texture_filter_anisotropic = 0;
|
||||||
int GLAD_GL_EXT_clip_control = 0;
|
int GLAD_GL_EXT_clip_control = 0;
|
||||||
@@ -2002,6 +2004,13 @@ static void load_GL_ARB_direct_state_access(GLADloadproc load) {
|
|||||||
glad_glGetQueryBufferObjectui64v = (PFNGLGETQUERYBUFFEROBJECTUI64VPROC)load("glGetQueryBufferObjectui64v");
|
glad_glGetQueryBufferObjectui64v = (PFNGLGETQUERYBUFFEROBJECTUI64VPROC)load("glGetQueryBufferObjectui64v");
|
||||||
glad_glGetQueryBufferObjectuiv = (PFNGLGETQUERYBUFFEROBJECTUIVPROC)load("glGetQueryBufferObjectuiv");
|
glad_glGetQueryBufferObjectuiv = (PFNGLGETQUERYBUFFEROBJECTUIVPROC)load("glGetQueryBufferObjectuiv");
|
||||||
}
|
}
|
||||||
|
static void load_GL_ARB_draw_elements_base_vertex(GLADloadproc load) {
|
||||||
|
if(!GLAD_GL_ARB_draw_elements_base_vertex) return;
|
||||||
|
glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)load("glDrawElementsBaseVertex");
|
||||||
|
glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)load("glDrawRangeElementsBaseVertex");
|
||||||
|
glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)load("glDrawElementsInstancedBaseVertex");
|
||||||
|
glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)load("glMultiDrawElementsBaseVertex");
|
||||||
|
}
|
||||||
static void load_GL_ARB_multi_bind(GLADloadproc load) {
|
static void load_GL_ARB_multi_bind(GLADloadproc load) {
|
||||||
if(!GLAD_GL_ARB_multi_bind) return;
|
if(!GLAD_GL_ARB_multi_bind) return;
|
||||||
glad_glBindBuffersBase = (PFNGLBINDBUFFERSBASEPROC)load("glBindBuffersBase");
|
glad_glBindBuffersBase = (PFNGLBINDBUFFERSBASEPROC)load("glBindBuffersBase");
|
||||||
@@ -2064,6 +2073,7 @@ static int find_extensionsGL(void) {
|
|||||||
if (!get_exts()) return 0;
|
if (!get_exts()) return 0;
|
||||||
GLAD_GL_ARB_clip_control = has_ext("GL_ARB_clip_control");
|
GLAD_GL_ARB_clip_control = has_ext("GL_ARB_clip_control");
|
||||||
GLAD_GL_ARB_direct_state_access = has_ext("GL_ARB_direct_state_access");
|
GLAD_GL_ARB_direct_state_access = has_ext("GL_ARB_direct_state_access");
|
||||||
|
GLAD_GL_ARB_draw_elements_base_vertex = has_ext("GL_ARB_draw_elements_base_vertex");
|
||||||
GLAD_GL_ARB_multi_bind = has_ext("GL_ARB_multi_bind");
|
GLAD_GL_ARB_multi_bind = has_ext("GL_ARB_multi_bind");
|
||||||
GLAD_GL_ARB_texture_filter_anisotropic = has_ext("GL_ARB_texture_filter_anisotropic");
|
GLAD_GL_ARB_texture_filter_anisotropic = has_ext("GL_ARB_texture_filter_anisotropic");
|
||||||
GLAD_GL_EXT_framebuffer_object = has_ext("GL_EXT_framebuffer_object");
|
GLAD_GL_EXT_framebuffer_object = has_ext("GL_EXT_framebuffer_object");
|
||||||
@@ -2152,6 +2162,7 @@ int gladLoadGLLoader(GLADloadproc load) {
|
|||||||
if (!find_extensionsGL()) return 0;
|
if (!find_extensionsGL()) return 0;
|
||||||
load_GL_ARB_clip_control(load);
|
load_GL_ARB_clip_control(load);
|
||||||
load_GL_ARB_direct_state_access(load);
|
load_GL_ARB_direct_state_access(load);
|
||||||
|
load_GL_ARB_draw_elements_base_vertex(load);
|
||||||
load_GL_ARB_multi_bind(load);
|
load_GL_ARB_multi_bind(load);
|
||||||
load_GL_EXT_framebuffer_object(load);
|
load_GL_EXT_framebuffer_object(load);
|
||||||
load_GL_GREMEDY_string_marker(load);
|
load_GL_GREMEDY_string_marker(load);
|
||||||
|
|||||||
Reference in New Issue
Block a user