Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (682)
Games in Android Showcase (196)
games submitted by our members
Games in WIP (750)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  shader problems  (Read 1782 times)
0 Members and 1 Guest are viewing this topic.
Offline deepthought
« Posted 2010-10-01 12:25:28 »

how do i get a shader loaded into JOGL and check the status?
here's my current code


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
public void setupshaders(GL gl)
   {
      String frag = "test.frag";
      String vert ="test.vert";
          int v = gl.glCreateShader(GL.GL_VERTEX_SHADER);
           int f = gl.glCreateShader(GL.GL_FRAGMENT_SHADER);
           
           shader(gl,v,vert);
           shader(gl,f,frag);
       
           int shaderprogram = gl.glCreateProgram();
           gl.glAttachShader(shaderprogram, v);
           gl.glAttachShader(shaderprogram, f);
           gl.glLinkProgram(shaderprogram);
           gl.glValidateProgram(shaderprogram);
           System.out.println(gl.glGetString(GL.GL_VERSION));
           gl.glUseProgram(shaderprogram);
   }
   
   
   
   public  void shader(GL gl, int shadernum, String file)
    {
        String fshadername=file;
        BufferedReader shader= new BufferedReader(new InputStreamReader(new BufferedInputStream(getClass().getResourceAsStream(fshadername))));

       

         
         String tempstring="";
         Vector<String> shaderstringsvector= new Vector();
        while(true)
        {
        try {
           tempstring=shader.readLine();
        } catch (IOException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
        }

        if(tempstring==null)
        {
           break;
        }

        shaderstringsvector.add(tempstring);  
        }

        String shaderstrings[]= new String[shaderstringsvector.size()];
        int shaderlengths[]= new int[shaderstringsvector.size()];

        for(int x=0;x<shaderstringsvector.size();x++)
        {
           shaderstrings[x]=shaderstringsvector.get(x);
           shaderlengths[x]=shaderstringsvector.get(x).length();

        }
             
        gl.glShaderSource(shadernum, 1, shaderstrings, shaderlengths, 1);
gl.glCompileShader(shadernum);


    }
   
}



how do i check the compile status and such? because i keep getting the exception

Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: glGetError() returned the following error codes after a call to glUseProgram(): GL_INVALID_OPERATION
   at javax.media.opengl.DebugGL.checkGLGetError(DebugGL.java:12715)
   at javax.media.opengl.DebugGL.glUseProgram(DebugGL.java:9774)
   at shaders.shader1.setupshaders(shader1.java:228)
   at shaders.shader1.init(shader1.java:76)
   at com.sun.opengl.impl.GLDrawableHelper.init(GLDrawableHelper.java:72)
   at javax.media.opengl.GLCanvas$InitAction.run(GLCanvas.java:418)
   at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:189)
   at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:412)
   at javax.media.opengl.GLCanvas.display(GLCanvas.java:244)
   at javax.media.opengl.GLCanvas.paint(GLCanvas.java:277)
   at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
   at sun.awt.RepaintArea.paint(RepaintArea.java:224)
   at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:301)
   at java.awt.Component.dispatchEventImpl(Component.java:4486)
   at java.awt.Component.dispatchEvent(Component.java:4240)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)


what's wrong here?

Mad Scientist
Offline gouessej
« Reply #1 - Posted 2010-10-01 13:32:34 »

There is an example of shaders here (JOGL 2):
http://github.com/sgothel/jogl-demos/blob/master/src/demos/hdr/HDR.java

Offline deepthought
« Reply #2 - Posted 2010-10-01 19:25:38 »

Ok but should i use JOGL2? aparrently some things are still broken and it hasn't even been released yet. should i wait for a release or just go ahead?

Mad Scientist
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline deepthought
« Reply #3 - Posted 2010-10-02 22:26:54 »

what the heck i'll just try it.

Mad Scientist
Offline gouessej
« Reply #4 - Posted 2010-10-03 20:27:01 »

what the heck i'll just try it.
JOGL 2 is stable enough to do lots of things. I still have some freezes on Windows and Linux Sad Try it and tell us what is wrong.

Offline deepthought
« Reply #5 - Posted 2010-10-05 12:25:21 »

if i even try a simple blank window the exception

Exception in thread "main" java.lang.UnsatisfiedLinkError: com.jogamp.common.os.Platform.getPointerSizeInBitsImpl()I
   at com.jogamp.common.os.Platform.getPointerSizeInBitsImpl(Native Method)
   at com.jogamp.common.os.Platform.<clinit>(Platform.java:65)
   at com.jogamp.common.nio.Buffers.nativeOrder(Buffers.java:252)
   at com.jogamp.common.nio.Buffers.newDirectByteBuffer(Buffers.java:67)
   at com.jogamp.common.jvm.JVMUtil.<clinit>(JVMUtil.java:58)
   at javax.media.nativewindow.NativeWindowFactory.<clinit>(NativeWindowFactory.java:102)
   at javax.media.opengl.GLProfile.initProfiles(GLProfile.java:855)
   at javax.media.opengl.GLProfile.access$000(GLProfile.java:59)
   at javax.media.opengl.GLProfile$1.run(GLProfile.java:989)
   at java.security.AccessController.doPrivileged(Native Method)
   at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:987)
   at test.main(test.java:10)

shows up. what's wrong here?

Mad Scientist
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 
orrenravid (141 views)
2016-07-16 03:57:23

theagentd (210 views)
2016-07-11 14:28:54

Hydroque (293 views)
2016-07-06 05:56:57

Hydroque (441 views)
2016-07-03 08:52:54

GrandCastle (327 views)
2016-07-01 09:13:47

GrandCastle (320 views)
2016-07-01 09:09:45

CopyableCougar4 (375 views)
2016-06-25 16:56:52

Hydroque (360 views)
2016-06-22 02:17:53

SwampChicken (331 views)
2016-06-20 13:22:57

SwampChicken (281 views)
2016-06-20 13:22:49
Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42

FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!