Skip to content

#2460: Fix getBoolean(GLExt.GL_FRAMEBUFFER_SRGB_CAPABLE_EXT) causes error 1280 (invalid enum) #2461

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
48 changes: 20 additions & 28 deletions jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2024 jMonkeyEngine
* Copyright (c) 2009-2025 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -129,7 +129,7 @@ public GLRenderer(GL gl, GLExt glext, GLFbo glfbo) {
this.glext = glext;
this.texUtil = new TextureUtil(gl, gl2, glext);
}

/**
* Enable/Disable default automatic generation of mipmaps for framebuffers
* @param v Default is true
Expand Down Expand Up @@ -159,14 +159,14 @@ public void pushDebugGroup(String name) {
}
}



@Override
public Statistics getStatistics() {
return statistics;
}

@Override
@Override
public EnumSet<Caps> getCaps() {
return caps;
}
Expand Down Expand Up @@ -223,7 +223,7 @@ private void loadCapabilitiesES() {
String version = gl.glGetString(GL.GL_VERSION);
int oglVer = extractVersion(version);
if (isWebGL(version)) {
caps.add(Caps.WebGL);
caps.add(Caps.WebGL);
}
caps.add(Caps.GLSL100);
caps.add(Caps.OpenGLES20);
Expand Down Expand Up @@ -709,7 +709,7 @@ public void initialize() {
}else if(gl instanceof GLES_30){
((GLES_30)gl).glGenVertexArrays(intBuf16);
int vaoId = intBuf16.get(0);
((GLES_30)gl).glBindVertexArray(vaoId);
((GLES_30)gl).glBindVertexArray(vaoId);
} else{
throw new UnsupportedOperationException("Core profile not supported");
}
Expand Down Expand Up @@ -1288,7 +1288,7 @@ private boolean isValidNumber(FloatBuffer fb) {
}
return true;
}

private boolean isValidNumber(Vector2f v) {
return isValidNumber(v.x) && isValidNumber(v.y);
}
Expand Down Expand Up @@ -1453,7 +1453,7 @@ protected void updateShaderBufferBlock(final Shader shader, final ShaderBufferBl

final BufferObject bufferObject = bufferBlock.getBufferObject();
final BufferType bufferType = bufferBlock.getType();


if (bufferObject.isUpdateNeeded()) {
if (bufferType == BufferType.ShaderStorageBufferObject) {
Expand Down Expand Up @@ -1483,7 +1483,7 @@ protected void updateShaderBufferBlock(final Shader shader, final ShaderBufferBl
}
if (bufferBlock.getLocation() != NativeObject.INVALID_ID) {
gl3.glUniformBlockBinding(shaderId, bufferBlock.getLocation(), bindingPoint);
}
}
}
break;
}
Expand Down Expand Up @@ -1613,7 +1613,7 @@ public void updateShaderSourceData(ShaderSource source) {
}

}

if (linearizeSrgbImages) {
stringBuf.append("#define SRGB 1\n");
}
Expand Down Expand Up @@ -1746,7 +1746,7 @@ public void updateShaderData(Shader shader) {
public void setShader(Shader shader) {
if (shader == null) {
throw new IllegalArgumentException("Shader cannot be null");
} else {
} else {
if (shader.isUpdateNeeded()) {
updateShaderData(shader);
}
Expand Down Expand Up @@ -2126,12 +2126,12 @@ public void setReadDrawBuffers(FrameBuffer fb) {
final int MRT_OFF = 100;

if (fb != null) {

if (fb.getNumColorBuffers() == 0) {
// make sure to select NONE as draw buf
// no color buffer attached.
gl2.glDrawBuffer(GL.GL_NONE);
gl2.glReadBuffer(GL.GL_NONE);
gl2.glDrawBuffer(GL.GL_NONE);
gl2.glReadBuffer(GL.GL_NONE);
} else {
if (fb.getNumColorBuffers() > limits.get(Limits.FrameBufferAttachments)) {
throw new RendererException("Framebuffer has more color "
Expand Down Expand Up @@ -2243,7 +2243,7 @@ private void readFrameBufferWithGLFormat(FrameBuffer fb, ByteBuffer byteBuf, int
}

setFrameBuffer(fb);


} else {
setFrameBuffer(null);
Expand Down Expand Up @@ -2722,7 +2722,7 @@ public void setTexture(int unit, Texture tex) throws TextureUnitException {
if (unit < 0 || unit >= RenderContext.maxTextureUnits) {
throw new TextureUnitException();
}

Image image = tex.getImage();
if (image.isUpdateNeeded() || (image.isGeneratedMipmapsRequired() && !image.isMipmapsGenerated())) {
// Check NPOT requirements
Expand Down Expand Up @@ -2753,7 +2753,7 @@ public void setTexture(int unit, Texture tex) throws TextureUnitException {
if (tex.getName() != null) glext.glObjectLabel(GL.GL_TEXTURE, tex.getImage().getId(), tex.getName());
}
}

@Override
public void setTextureImage(int unit, TextureImage tex) throws TextureUnitException {
if (unit < 0 || unit >= RenderContext.maxTextureUnits) {
Expand All @@ -2766,7 +2766,7 @@ public void setTextureImage(int unit, TextureImage tex) throws TextureUnitExcept
tex.bindImage(gl4, texUtil, unit);
}
}

@Override
public void setUniformBufferObject(int bindingPoint, BufferObject bufferObject) {
if (bufferObject.isUpdateNeeded()) {
Expand Down Expand Up @@ -3490,19 +3490,11 @@ public void setMainFrameBufferSrgb(boolean enableSrgb) {
setFrameBuffer(null);

if (enableSrgb) {
if (
// Workaround: getBoolean(GLExt.GL_FRAMEBUFFER_SRGB_CAPABLE_EXT) causes error 1280 (invalid enum) on macos
JmeSystem.getPlatform().getOs() != Platform.Os.MacOS
&& !getBoolean(GLExt.GL_FRAMEBUFFER_SRGB_CAPABLE_EXT)
) {
logger.warning("Driver claims that default framebuffer " + "is not sRGB capable. Enabling anyway.");
}

gl.glEnable(GLExt.GL_FRAMEBUFFER_SRGB_EXT);

logger.log(Level.FINER, "SRGB FrameBuffer enabled (Gamma Correction)");
logger.log(Level.INFO, "SRGB FrameBuffer enabled (Gamma Correction)");
} else {
gl.glDisable(GLExt.GL_FRAMEBUFFER_SRGB_EXT);
logger.log(Level.INFO, "SRGB FrameBuffer disabled (Gamma Correction)");
}
}

Expand Down