Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/bundles/SoMaterialBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ SoMaterialBundle::SoMaterialBundle(SoAction *action)
if (SoLazyElement::getLightModel(this->state) == SoLazyElement::BASE_COLOR)
this->coloronly |= FLAG_COLORONLY;

#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
const cc_glglue * glue = sogl_glue_instance(this->state);
if (glue->nvidia_color_per_face_bug) {
if (glue && glue->nvidia_color_per_face_bug) {
this->coloronly |= FLAG_NVIDIA_BUG;
}
#endif
}

/*!
Expand Down
85 changes: 59 additions & 26 deletions src/elements/GL/SoGLDisplayList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class SoGLDisplayListP {
int openindex;
SbBool mipmap;
GLenum texturetarget;
SbBool hasGLCompatibilityProfile;
};

#define PRIVATE(obj) obj->pimpl
Expand All @@ -96,6 +97,7 @@ SoGLDisplayList::SoGLDisplayList(SoState * state, Type type, int allocnum,
PRIVATE(this)->refcount = 0;
PRIVATE(this)->mipmap = mipmaptexobj;
PRIVATE(this)->texturetarget = 0;
PRIVATE(this)->hasGLCompatibilityProfile = sogl_context_supports_legacy_rendering(state);

#if COIN_DEBUG && 0 // debug
SoDebugError::postInfo("SoGLDisplayList::SoGLDisplayList", "%p", this);
Expand Down Expand Up @@ -170,7 +172,13 @@ SoGLDisplayList::SoGLDisplayList(SoState * state, Type type, int allocnum,
}

if (PRIVATE(this)->type == DISPLAY_LIST) {
PRIVATE(this)->firstindex = (unsigned int) glGenLists(allocnum);
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
if (sogl_context_supports_legacy_rendering(state)) {
PRIVATE(this)->firstindex = (unsigned int) glGenLists(allocnum);
}
#else
assert(0 && "Not implemented for non-compatibility GL renderer");
#endif
if (PRIVATE(this)->firstindex == 0) {
SoDebugError::post("SoGLDisplayList::SoGLDisplayList",
"Could not reserve %d displaylist%s. "
Expand All @@ -193,21 +201,28 @@ SoGLDisplayList::~SoGLDisplayList()
SoDebugError::postInfo("SoGLDisplayList::~SoGLDisplayList", "%p", this);
#endif // debug

if (PRIVATE(this)->type == DISPLAY_LIST) {
glDeleteLists((GLuint) PRIVATE(this)->firstindex, PRIVATE(this)->numalloc);
}
else {
assert(PRIVATE(this)->type == TEXTURE_OBJECT);
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
if (PRIVATE(this)->hasGLCompatibilityProfile) {
if (PRIVATE(this)->type == DISPLAY_LIST) {
glDeleteLists((GLuint) PRIVATE(this)->firstindex, PRIVATE(this)->numalloc);
}
else {
assert(PRIVATE(this)->type == TEXTURE_OBJECT);

const cc_glglue * glw = cc_glglue_instance(PRIVATE(this)->context);
assert(cc_glglue_has_texture_objects(glw));
const cc_glglue * glw = cc_glglue_instance(PRIVATE(this)->context);
assert(cc_glglue_has_texture_objects(glw));

// Use temporary variable in case GLUint != unsigned int.
GLuint tmpindex = (GLuint) PRIVATE(this)->firstindex;
// It is only possible to create one texture object at a time, so
// there's only one index to delete.
cc_glglue_glDeleteTextures(glw, 1, &tmpindex);
// Use temporary variable in case GLUint != unsigned int.
GLuint tmpindex = (GLuint) PRIVATE(this)->firstindex;
// It is only possible to create one texture object at a time, so
// there's only one index to delete.
cc_glglue_glDeleteTextures(glw, 1, &tmpindex);
}
}
#else
assert(0 && "Not implemented for non-compatibility GL renderer");
#endif

delete PRIVATE(this);
}

Expand Down Expand Up @@ -242,10 +257,16 @@ SoGLDisplayList::open(SoState * state, int index)
{
if (PRIVATE(this)->type == DISPLAY_LIST) {
PRIVATE(this)->openindex = index;
// using GL_COMPILE here instead of GL_COMPILE_AND_EXECUTE will
// lead to much higher performance on nVidia cards, and doesn't
// hurt performance for other vendors.
glNewList((GLuint) (PRIVATE(this)->firstindex+PRIVATE(this)->openindex), GL_COMPILE);
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
if (sogl_context_supports_legacy_rendering(state)) {
// using GL_COMPILE here instead of GL_COMPILE_AND_EXECUTE will
// lead to much higher performance on nVidia cards, and doesn't
// hurt performance for other vendors.
glNewList((GLuint) (PRIVATE(this)->firstindex+PRIVATE(this)->openindex), GL_COMPILE);
}
#else
assert(0 && "Not implemented for non-compatibility GL renderer");
#endif
}
else {
assert(PRIVATE(this)->type == TEXTURE_OBJECT);
Expand All @@ -261,15 +282,21 @@ void
SoGLDisplayList::close(SoState * COIN_UNUSED_ARG(state))
{
if (PRIVATE(this)->type == DISPLAY_LIST) {
glEndList();
GLenum err = sogl_glerror_debugging() ? glGetError() : GL_NO_ERROR;
if (err == GL_OUT_OF_MEMORY) {
SoDebugError::post("SoGLDisplayList::close",
"Not enough memory resources available on system "
"to store full display list. Expect flaws in "
"rendering.");
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
if (sogl_context_supports_legacy_rendering(state)) {
glEndList();
GLenum err = sogl_glerror_debugging() ? glGetError() : GL_NO_ERROR;
if (err == GL_OUT_OF_MEMORY) {
SoDebugError::post("SoGLDisplayList::close",
"Not enough memory resources available on system "
"to store full display list. Expect flaws in "
"rendering.");
}
glCallList((GLuint) (PRIVATE(this)->firstindex + PRIVATE(this)->openindex));
}
glCallList((GLuint) (PRIVATE(this)->firstindex + PRIVATE(this)->openindex));
#else
assert(0 && "Not implemented for non-compatibility GL renderer");
#endif
}
else {
const cc_glglue * glw = cc_glglue_instance(PRIVATE(this)->context);
Expand All @@ -291,7 +318,13 @@ void
SoGLDisplayList::call(SoState * state, int index)
{
if (PRIVATE(this)->type == DISPLAY_LIST) {
glCallList((GLuint) (PRIVATE(this)->firstindex + index));
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
if (sogl_context_supports_legacy_rendering(state)) {
glCallList((GLuint) (PRIVATE(this)->firstindex + index));
}
#else
assert(0 && "Not implemented for non-compatibility GL renderer");
#endif
}
else {
assert(PRIVATE(this)->type == TEXTURE_OBJECT);
Expand Down
7 changes: 6 additions & 1 deletion src/elements/SoTextureCombineElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ SoTextureCombineElement::apply(SoState * state, const int unit)

assert(unit < PRIVATE(elem)->unitdata.getLength());
const UnitData & ud = PRIVATE(elem)->unitdata[unit];
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, static_cast<GLenum>(ud.rgboperation));
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, static_cast<GLenum>(ud.alphaoperation));
Expand All @@ -294,6 +294,11 @@ SoTextureCombineElement::apply(SoState * state, const int unit)
ud.constantcolor.getValue());
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, ud.rgbscale);
glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, ud.alphascale);
#else
(void) state;
(void) unit;
(void) ud;
#endif
}

SoTextureCombineElement::UnitData::UnitData()
Expand Down
1 change: 0 additions & 1 deletion src/fonts/freetype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,6 @@ cc_flwft_get_vector_glyph(void * font, unsigned int glyphindex, float complexity
cc_ftglue_FT_Done_Glyph((FT_Glyph) g);

return new_vector_glyph;

}

static void
Expand Down
42 changes: 40 additions & 2 deletions src/glue/gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@
#include <cstring>
#include <climits> /* SHRT_MAX */

#include <Inventor/C/glue/gl.h>

#ifdef HAVE_AGL
#include <AGL/agl.h>
#endif /* HAVE_AGL */
Expand All @@ -265,8 +267,6 @@
#include <EGL/eglext.h>
#endif /* HAVE_EGL */

#include <Inventor/C/glue/gl.h>

#include <Inventor/C/errors/debugerror.h>
#include <Inventor/C/glue/dl.h>
#include <Inventor/C/tidbits.h>
Expand Down Expand Up @@ -2399,8 +2399,12 @@ cc_glglue_instance(int contextid)
gi->max_texture_size = gltmp;

if (gi->context_supports_legacy_rendering) {
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
glGetIntegerv(GL_MAX_LIGHTS, &gltmp);
gi->max_lights = (int) gltmp;
#else
gi->max_lights = 0;
#endif
}
else {
gi->max_lights = 0;
Expand Down Expand Up @@ -5062,10 +5066,20 @@ cc_glglue_is_texture_size_legal(const cc_glglue * glw,
switch (bytespertexel) {
default:
case 1:
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
format = internalformat = GL_LUMINANCE;
#else
internalformat = GL_R8;
format = GL_RED;
#endif
break;
case 2:
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
format = internalformat = GL_LUMINANCE_ALPHA;
#else
internalformat = GL_RG8;
format = GL_RG;
#endif
break;
case 3:
format = internalformat = GL_RGB8;
Expand Down Expand Up @@ -5143,10 +5157,18 @@ GLint coin_glglue_get_internal_texture_format(const cc_glglue * glw,
if (compress) {
switch (numcomponents) {
case 1:
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
format = GL_COMPRESSED_LUMINANCE_ARB;
#else
format = GL_COMPRESSED_RED;
#endif
break;
case 2:
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
format = GL_COMPRESSED_LUMINANCE_ALPHA_ARB;
#else
format = GL_COMPRESSED_RG;
#endif
break;
case 3:
format = GL_COMPRESSED_RGB_ARB;
Expand All @@ -5161,10 +5183,18 @@ GLint coin_glglue_get_internal_texture_format(const cc_glglue * glw,
SbBool usenewenums = glglue_allow_newer_opengl(glw) && cc_glglue_glversion_matches_at_least(glw,1,1,0);
switch (numcomponents) {
case 1:
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
format = usenewenums ? GL_LUMINANCE8 : GL_LUMINANCE;
#else
format = GL_R8;
#endif
break;
case 2:
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
format = usenewenums ? GL_LUMINANCE8_ALPHA8 : GL_LUMINANCE_ALPHA;
#else
format = GL_RG8;
#endif
break;
case 3:
format = usenewenums ? GL_RGB8 : GL_RGB;
Expand All @@ -5187,10 +5217,18 @@ GLenum coin_glglue_get_texture_format(const cc_glglue * COIN_UNUSED_ARG(glw), in
GLenum format;
switch (numcomponents) {
case 1:
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
format = GL_LUMINANCE;
#else
format = GL_RED;
#endif
break;
case 2:
#if defined(COIN_BUILD_LEGACY_GL_RENDERER)
format = GL_LUMINANCE_ALPHA;
#else
format = GL_RG;
#endif
break;
case 3:
format = GL_RGB;
Expand Down
Loading
Loading