1282 Error after calling glUseProgram()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

1282 Error after calling glUseProgram()

Felipe
Hello

Below is the full code of a program I'm trying to run in a macbook pro 2015. It is basically just trying to print
a single dot in the center. The problem is that right after calling glUseProgram() I get the 1282 error.
Can anybody help me spot any errors in the shader code?

package com.noatechnologies.tutorials.opengl3;
import static com.jogamp.opengl.GL.GL_NO_ERROR;
import static com.jogamp.opengl.GL.GL_VERSION;
import static com.jogamp.opengl.GL4.*;
import javax.swing.JFrame;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL4;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLContext;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.awt.GLCanvas;

/**
 * Copied from the book: Computer Graphics Programming in OpenGL with Java, 1st
 * Edition Program 2.2
 *
 * @author Felipe
 * @version Sep 3, 2019 5:31:57 PM
 */
public class Code_Program2_2 extends JFrame implements GLEventListener {
        private GLCanvas myCanvas;
        private int rendering_program;
        private int vao[] = new int[1];

        public Code_Program2_2() {
                setTitle("Chapter2 - program2.2");
                setSize(600, 400);
                setLocation(200, 200);
                /*Following code I got it from: http://forum.jogamp.org/GL4-not-working-in-JOGL-macbook-pro-td4040031.html
                 * This is actually a question I made. Sept. 5, 2019 3:46PM
                 */
                final GLProfile profile = GLProfile.get(GLProfile.GL4);
            final GLCapabilities glcapabilities = new GLCapabilities(profile);
                myCanvas = new GLCanvas(glcapabilities);

                myCanvas.addGLEventListener(this);
                this.add(myCanvas);
                setVisible(true);
        }

        public void display(GLAutoDrawable drawable) {
                GL4 gl = (GL4) GLContext.getCurrentGL();
                checkGLError(gl);
                gl.glUseProgram(rendering_program);
                checkGLError(gl);
                gl.glDrawArrays(GL_POINTS, 0, 1);
                checkGLError(gl);
        }

        public static void main(String[] args) {
                new Code_Program2_2();
        }

        public void init(GLAutoDrawable drawable) {
                GL4 gl = (GL4) GLContext.getCurrentGL();
                String glVersion=gl.glGetString(GL_VERSION)  ;
                System.out.println("glVersion="+glVersion);

                checkGLError(gl);
                rendering_program = createShaderProgram();
                checkGLError(gl);
                gl.glGenVertexArrays(vao.length, vao, 0);
                checkGLError(gl);
                gl.glBindVertexArray(vao[0]);
                checkGLError(gl);
        }

        private int createShaderProgram() {
                GL4 gl = (GL4) GLContext.getCurrentGL();
                String vshaderSource[] = { "#version 430 \n", "void main(void) \n",
                                "{ gl_Position = vec4(0.0, 0.0, 0.0, 1.0); } \n", };
                String fshaderSource[] = { "#version 430 \n", "out vec4 color; \n",
                                "void main(void) \n",
                                "{ color = vec4(0, 0.0, 1, 1.0); } \n", };
               
                int vShader = gl.glCreateShader(GL_VERTEX_SHADER);
                checkGLError(gl);
                gl.glShaderSource(vShader, 3, vshaderSource, null, 0);
                checkGLError(gl);
                gl.glCompileShader(vShader);
                checkGLError(gl);
                int fShader = gl.glCreateShader(GL_FRAGMENT_SHADER);
                checkGLError(gl);
                gl.glShaderSource(fShader, 4, fshaderSource, null, 0);
                checkGLError(gl);
                gl.glCompileShader(fShader);
                checkGLError(gl);
                int vfprogram = gl.glCreateProgram();
                checkGLError(gl);
                gl.glAttachShader(vfprogram, vShader);
                checkGLError(gl);
                gl.glAttachShader(vfprogram, fShader);
                checkGLError(gl);
                gl.glLinkProgram(vfprogram);
                checkGLError(gl);
                gl.glDeleteShader(vShader);
                checkGLError(gl);
                gl.glDeleteShader(fShader);
                checkGLError(gl);
               
               
               

                return vfprogram;
        }

       
        /**
         *
         * @throws Exception
         * @author Felipe
         * @version Sep 4, 2019 9:36:30 PM
         */
        public void checkGLError(GL gl)throws Error
        {
                int glError=gl.glGetError();
                if(glError!=GL_NO_ERROR)
                {
                        throw new Error("Invalid: GL error="+glError+" found");
                }

        }
        public void reshape(GLAutoDrawable drawable, int x, int y, int width,
                        int height) {
        }

        public void dispose(GLAutoDrawable drawable) {
        }
}

Reply | Threaded
Open this post in threaded view
|

Re: 1282 Error after calling glUseProgram()

gouessej
Administrator
Hello

My hardware (at home) doesn't support OpenGL 4. Please can you post the full stack trace? It looks good to me (even though I'd preferably use direct NIO buffers instead of arrays).
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: 1282 Error after calling glUseProgram()

Felipe
I tried GL3 to see if I would get a different result but unfortunately I'm still getting the same error.

I'm not sure the stack trace would help much since I'm the one that am throwing the java error. Here it is just in case.

Exception in thread "AWT-EventQueue-0" com.jogamp.opengl.GLException: Caught Error: Invalid: GL error=1282 found on thread AWT-EventQueue-0
        at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327)
        at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
        at com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.java:1438)
        at com.jogamp.opengl.Threading.invoke(Threading.java:223)
        at com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:505)
        at com.jogamp.opengl.awt.GLCanvas.paint(GLCanvas.java:559)
        at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
        at sun.awt.RepaintArea.paint(RepaintArea.java:241)
        at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)
        at java.awt.Component.dispatchEventImpl(Component.java:4852)
        at java.awt.Component.dispatchEvent(Component.java:4604)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)
        at java.awt.EventQueue.access$400(EventQueue.java:82)
        at java.awt.EventQueue$2.run(EventQueue.java:676)
        at java.awt.EventQueue$2.run(EventQueue.java:674)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:690)
        at java.awt.EventQueue$3.run(EventQueue.java:688)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.Error: Invalid: GL error=1282 found
        at com.noatechnologies.tutorials.opengl3.Code_Program2_2.checkGLError(Code_Program2_2.java:131)
        at com.noatechnologies.tutorials.opengl3.Code_Program2_2.init(Code_Program2_2.java:75)
        at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:644)
        at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:667)
        at com.jogamp.opengl.awt.GLCanvas$10.run(GLCanvas.java:1407)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1291)
        ... 28 more
2019-09-06 23:38:38.992 java[82211:20289717] -_cgsEventRecord is deprecated for _cgsEventRecord. Please use -CGEvent.
2019-09-06 23:38:38.992 java[82211:20289717] *** Assertion failure in -[NSEvent _cgsEventRecord], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1671.40.119/AppKit.subproj/NSEvent.m:1986
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Non-Java exception raised, not handled! (Original problem: Deprecated in 10_12... DO NOT EVER USE CGSEventRecord directly. Bad things, man.... bad things.)
        at apple.awt.ComponentModel._handleEvent(Native Method)
        at apple.awt.ComponentModel.handleEvent(ComponentModel.java:273)
        at apple.awt.CWindow.handleEvent(CWindow.java:545)
        at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:753)
        at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1000)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:865)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:686)
        at java.awt.Component.dispatchEventImpl(Component.java:4648)
        at java.awt.Container.dispatchEventImpl(Container.java:2142)
        at java.awt.Window.dispatchEventImpl(Window.java:2492)
        at java.awt.Component.dispatchEvent(Component.java:4604)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)
        at java.awt.EventQueue.access$400(EventQueue.java:82)
        at java.awt.EventQueue$2.run(EventQueue.java:676)
        at java.awt.EventQueue$2.run(EventQueue.java:674)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:690)
        at java.awt.EventQueue$3.run(EventQueue.java:688)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
2019-09-06 23:38:39.135 java[82211:20289717] *** Assertion failure in -[NSEvent _cgsEventRecord], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1671.40.119/AppKit.subproj/NSEvent.m:1986
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Non-Java exception raised, not handled! (Original problem: Deprecated in 10_12... DO NOT EVER USE CGSEventRecord directly. Bad things, man.... bad things.)
        at apple.awt.ComponentModel._handleEvent(Native Method)
        at apple.awt.ComponentModel.handleEvent(ComponentModel.java:273)
        at apple.awt.CWindow.handleEvent(CWindow.java:545)
        at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:753)
        at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1000)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:865)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:686)
        at java.awt.Component.dispatchEventImpl(Component.java:4648)
        at java.awt.Container.dispatchEventImpl(Container.java:2142)
        at java.awt.Window.dispatchEventImpl(Window.java:2492)
        at java.awt.Component.dispatchEvent(Component.java:4604)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)
        at java.awt.EventQueue.access$400(EventQueue.java:82)
        at java.awt.EventQueue$2.run(EventQueue.java:676)
        at java.awt.EventQueue$2.run(EventQueue.java:674)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:690)
        at java.awt.EventQueue$3.run(EventQueue.java:688)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)