Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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 1464 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?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
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?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
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.

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
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?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (86 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!