Re: JOGL2 + GLCapabilities + Windows
Posted by Marc@56K on Jan 04, 2011; 9:25pm
URL: https://forum.jogamp.org/JOGL2-GLCapabilities-Windows-tp2153961p2194356.html
I use a 32-bit jdk on a Win64 machine. I got the error with NEWT and AWT.
Without setSampleBuffers(true) the Shader doesn't compile and the variable logLength[0] returns zero.
public class GLCapabilitiesBug implements GLEventListener
{
/**
* @param args
*/
public static void main(String[] args)
{
new GLCapabilitiesBug();
}
private GLWindow window;
public GLCapabilitiesBug()
{
this.window = GLWindow.create(this.getGLCapabilities());
this.window.addGLEventListener(this);
this.window.setVisible(true);
while(true)
{
window.display();
}
}
protected GLCapabilities getGLCapabilities()
{
GLProfile glp = GLProfile.get("GL2GL3");
GLCapabilities caps = new GLCapabilities(glp);
caps.setStencilBits(8);
//caps.setSampleBuffers(true);
return caps;
}
@Override
public void display(GLAutoDrawable drawable)
{
}
@Override
public void dispose(GLAutoDrawable arg0)
{
}
@Override
public void init(GLAutoDrawable drawable)
{
String code = "void main(void){gl_Position = vec4(0,0,0,1);}";
GL2GL3 gl = drawable.getGL().getGL2GL3();
int id = gl.glCreateShader(GL2GL3.GL_VERTEX_SHADER);
gl.glShaderSource(id, 1, new String[] { code }, (int[])null, 0);
gl.glCompileShader(id);
int[] compiled = new int[1];
gl.glGetShaderiv(id, GL2GL3.GL_COMPILE_STATUS, compiled, 0);
if (compiled[0] == GL2GL3.GL_FALSE)
{
int[] logLength = new int[1];
gl.glGetShaderiv(id, GL2GL3.GL_INFO_LOG_LENGTH, logLength, 0);
byte[] log = new byte[logLength[0]];
gl.glGetShaderInfoLog(id, logLength[0], (int[])null, 0, log, 0);
System.err.println("Error compiling the shader: " + new String(log));
gl.glDeleteShader(id);
}
else
{
System.out.println("Shader compiled: id=" + id);
}
}
@Override
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4)
{
}
}