Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / JOGL Development / JOGL2 - a problem with the project template on: 2011-08-28 21:46:41
I decided to update JOGL2 to the newest version which is jogl-b434-2011-08-24 (https://jogamp.org/deployment/autobuilds/master/). Now I'm using an older version jogl-b391-2011-05-17. I noticed that after jogl-b419-2011-08-04 some changes were introduced, for example other jar nad dll files. I have a problem with my project template becasue the newest release doesn't contain glugen-rt.dll and it seems to be necessary here:
1  
GLProfile profile = GLProfile.get(GLProfile.GL3);
What should I do ?
2  Java Game APIs & Engines / JOGL Development / Re: vbo - glDrawElements problem on: 2011-08-12 18:29:26
Exception in thread "AWT-EventQueue-0-AWTAnimator-1" javax.media.opengl.GLException: javax.media.opengl.GLException: Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glBufferData(<int> 0x8893, <long> 24, <java.nio.Buffer> java.nio.HeapByteBuffer[pos=0 lim=24 cap=24], <int> 0x88E8): GL_INVALID_OPERATION ( 1282 0x502),
...

Caused by: javax.media.opengl.GLException: Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glBufferData(<int> 0x8893, <long> 24, <java.nio.Buffer> java.nio.HeapByteBuffer[pos=0 lim=24 cap=24], <int> 0x88E8): GL_INVALID_OPERATION ( 1282 0x502)

...

refer to:
1  
gl.glBufferData(GL3.GL_ELEMENT_ARRAY_BUFFER, vboFrameIndices.length * Sizeof.BYTE, ByteBuffer.wrap(vboFrameIndices), GL3.GL_DYNAMIC_DRAW);




Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glDrawElements(<int> 0x1, <int> 0xC, <int> 0x1400, <long> 0): GL_INVALID_ENUM ( 1280 0x500)
...

refer to:
1  
gl.glDrawElements(GL3.GL_LINES, 12, GL3.GL_BYTE, 0);

3  Java Game APIs & Engines / JOGL Development / Re: vbo - glDrawElements problem on: 2011-08-12 14:25:22
Vertex shader:

1  
2  
3  
4  
5  
6  
7  
8  
9  
private static String vertexShader =
    "#version 330" + "\n" +
    "layout (location = 0) in vec4 position;" + "\n" +
    "uniform mat4 pMatrix;" + "\n" +
    "uniform mat4 mMatrix;" + "\n" +
    "void main()" + "\n" +
    "{" + "\n" +
    "gl_Position = pMatrix * mMatrix * position;" + "\n" +
    "}";


Fragment shader:

1  
2  
3  
4  
5  
6  
7  
8  
private static String fragmentShader =
    "#version 330" + "\n" +
    "out vec4 outputColor;" + "\n" +
    "uniform vec4 color;" + "\n" +  
    "void main()" + "\n" +
    "{" + "\n" +
    "outputColor = color;" + "\n" +
    "}";      
4  Java Game APIs & Engines / JOGL Development / vbo - glDrawElements problem on: 2011-08-12 12:57:10
I want to draw something using vbo and indices but my code doesn't work - I get a black screen. What's wrong ?

Creating vbo's:
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  
  vboVertices = new float[]{3.0f, 3.0f, 3.0f, 1.0f, 
                            -3.0f, 3.0f, 3.0f, 1.0f,
                            -3.0f, -3.0f, 3.0f, 1.0f,
                            3.0f, -3.0f, 3.0f, 1.0f,
                            -3.0f, 3.0f, -3.0f, 1.0f,
                            3.0f, 3.0f, -3.0f, 1.0f,
                            3.0f, -3.0f, -3.0f, 1.0f,
                            -3.0f, -3.0f, -3.0f, 1.0f};
       
  vboIndices = new byte[]{0,1, 0,3, 0,5,
                          1,4, 1,2, 2,7,
                          2,3, 3,6, 4,7,
                          4,5, 5,6, 6,7};

  int buffer[] = new int[2];
  gl.glGenBuffers(2, IntBuffer.wrap(buffer));
  vbo[0] = buffer[0];
  vbo[1] = buffer[1];

  gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo[0]);
  gl.glBufferData(GL3.GL_ARRAY_BUFFER, vboVertices.length * Sizeof.FLOAT, FloatBuffer.wrap(vboVertices), GL3.GL_DYNAMIC_DRAW);
  gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);
       
  gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo[1]);
  gl.glBufferData(GL3.GL_ELEMENT_ARRAY_BUFFER, vboIndices.length * Sizeof.BYTE, ByteBuffer.wrap(vboIndices), GL3.GL_DYNAMIC_DRAW);
  gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);


Rendering

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
gl.glUseProgram(shaderProgramID);
projectionMatrixUniform = gl.glGetUniformLocation(shaderProgramID, "pMatrix");
gl.glUniformMatrix4fv(projectionMatrixUniform, 1, false, projectionMatrix, 0);
modelViewMatrixUniform = gl.glGetUniformLocation(shaderProgramID, "mMatrix");
gl.glUniformMatrix4fv(modelViewMatrixUniform, 1, false, modelViewMatrix, 0);
colorUniform = gl.glGetUniformLocation(shaderProgramID, "color");
gl.glUniform4f(colorUniform, 1.0f, 1.0f, 1.0f, 1.0f);

gl.glEnableVertexAttribArray(0);
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo[0]);
gl.glVertexAttribPointer(0, 4, GL3.GL_FLOAT, false, 0, 0);
gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, vbo[1]);
gl.glDrawElements(GL3.GL_LINES, 12, GL3.GL_BYTE, 0);
gl.glDisableVertexAttribArray(0);
gl.glUseProgram(0);


5  Java Game APIs & Engines / JOGL Development / Shaders - compile and linking errors on: 2011-05-19 18:42:14
Hello! I have a problem with checking the linking errors. My program works but my function still prints a linker error and I don't have any ideas what is wrong (printing errors for vertex and fragment shader works correctly). However when I use gl = new DebugGL3(gl); I get some errors (refer to gl.glGetShaderiv(shaderProgramID, GL3.GL_LINK_STATUS, IntBuffer.wrap(statusLinker))) and the program doesn't start:


Exception in thread "Timer-0" javax.media.opengl.GLException: javax.media.opengl.GLException: Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glGetShaderiv(<int> 0x1, <int> 0x8B82, <java.nio.IntBuffer> java.nio.HeapIntBuffer[pos=0 lim=1 cap=1]): GL_INVALID_OPERATION ( 1282 0x502),


My initShaders function:

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  
    private void initShaders(GL3 gl)
    {
       
        shaderProgramID = gl.glCreateProgram();

        int vertexShaderID = gl.glCreateShader(GL3.GL_VERTEX_SHADER);
        gl.glShaderSource(vertexShaderID, 1, new String[]{vertexShader}, null);
        gl.glCompileShader(vertexShaderID);
        int statusVertexShader[] = new int[1];
        gl.glGetShaderiv(vertexShaderID, GL3.GL_COMPILE_STATUS, IntBuffer.wrap(statusVertexShader));
        if(statusVertexShader[0] == GL3.GL_FALSE)
        {
            int infoLogLenght[] = new int[1];
            gl.glGetShaderiv(vertexShaderID, GL3.GL_INFO_LOG_LENGTH, IntBuffer.wrap(infoLogLenght));
            ByteBuffer infoLog = Buffers.newDirectByteBuffer(infoLogLenght[0]);
            gl.glGetShaderInfoLog(vertexShaderID, infoLogLenght[0], null, infoLog);
            byte[] infoBytes =new byte[infoLogLenght[0]];
            infoLog.get(infoBytes);
            String out =new String(infoBytes);
            System.out.println("Vertex shader error:\n" + out);
        }
        gl.glAttachShader(shaderProgramID, vertexShaderID);
        gl.glDeleteShader(vertexShaderID);

        int fragmentShaderID = gl.glCreateShader(GL3.GL_FRAGMENT_SHADER);
        gl.glShaderSource(fragmentShaderID, 1, new String[]{fragmentShader}, null);
        gl.glCompileShader(fragmentShaderID);
        int statusFragmentShader[] = new int[1];
        gl.glGetShaderiv(fragmentShaderID, GL3.GL_COMPILE_STATUS, IntBuffer.wrap(statusFragmentShader));
        if(statusFragmentShader[0] == GL3.GL_FALSE)
        {
            int infoLogLenght[] = new int[1];
            gl.glGetShaderiv(fragmentShaderID, GL3.GL_INFO_LOG_LENGTH, IntBuffer.wrap(infoLogLenght));
            ByteBuffer infoLog = Buffers.newDirectByteBuffer(infoLogLenght[0]);
            gl.glGetShaderInfoLog(fragmentShaderID, infoLogLenght[0], null, infoLog);
            byte[] infoBytes =new byte[infoLogLenght[0]];
            infoLog.get(infoBytes);
            String out =new String(infoBytes);
            System.out.println("Fragment shader error:\n" + out);
        }
        gl.glAttachShader(shaderProgramID, fragmentShaderID);
        gl.glDeleteShader(fragmentShaderID);
       
       
        gl.glLinkProgram(shaderProgramID);
        gl.glValidateProgram(shaderProgramID);
       
        int statusLinker[] = new int[1];
        gl.glGetShaderiv(shaderProgramID, GL3.GL_LINK_STATUS, IntBuffer.wrap(statusLinker));
        if(statusLinker[0] == GL3.GL_FALSE)
        {
            int infoLogLenght[] = new int[1];
            gl.glGetShaderiv(shaderProgramID, GL3.GL_INFO_LOG_LENGTH, IntBuffer.wrap(infoLogLenght));
            ByteBuffer infoLog = Buffers.newDirectByteBuffer(infoLogLenght[0]);
            gl.glGetShaderInfoLog(shaderProgramID, infoLogLenght[0], null, infoLog);
            byte[] infoBytes =new byte[infoLogLenght[0]];
            infoLog.get(infoBytes);
            String out =new String(infoBytes);
            System.out.println("Linker error:\n" + out);
        }
       
    }
6  Java Game APIs & Engines / JOGL Development / Re: vertex shader problem on: 2011-05-09 19:47:50
First I had an another code for update vertices and vertex shader without uniform vec2 offset:
 
Vertex Shader
1  
2  
3  
4  
5  
6  
7  
8  
#version 330

layout(location = 0) in vec4 position;

void main()
{
   gl_Position = position;
}


Function for update vertices which was being executed in display:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
private void adjustVertexData(GL3 gl)
{
         
     for(int i = 0; i < fNewData.capacity(); i += 4)
     {
          tempVertexData[i] += fXOffset;
          tempVertexData[i + 1] += fXOffset;
     }
       
       
     for(int i = 0; i < fNewData.capacity(); i++)
     {
          fNewData.put(tempVertexData[i]);
     }
       
     fNewData.rewind();
     gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vertexBufferObject);
     gl.glBufferSubData(GL3.GL_ARRAY_BUFFER, 0, Buffers.SIZEOF_FLOAT * fNewData.capacity(), fNewData);
     gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);
}


Fields fXOffset and fYOffset was initialized ( private float fXOffset = 0.01f; private float fYOffset = 0.01f;) in both cases. I assumed that I don't need update fXOffset and fYOffset in the next version of my program which has another vertex shader and use glUniform2f. Now everything works fine with fXOffset += 0.01f; and fYOffset += 0.01 at the begining of display. I don't clearly understand why earlier my code doesn't work properly. Is it because of uniform variable nature ?

With glDeleteShader the program also works. I saw this way of using glDeleteShaders in some sample program and I coded my program similar. Is it mistake ? When using glDeleteShader in that way can bring me some troubles ?
7  Java Game APIs & Engines / JOGL Development / Re: vertex shader problem on: 2011-05-09 15:02:50
Ok, I added to my init shaders function simple error checking code and now I'm getting the message: "linker error: 0". I still can't understand what is wrong ....

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  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
private void initShaders(GL3 gl)
    {
        shaderProgramID = gl.glCreateProgram();

        int vertexShaderID = gl.glCreateShader(GL3.GL_VERTEX_SHADER);
        gl.glShaderSource(vertexShaderID, 1,
            new String[]{vertexShader}, null);
        gl.glCompileShader(vertexShaderID);
       
       
       
        int statusVertex[] = new int[1];
        gl.glGetShaderiv(vertexShaderID, GL3.GL_COMPILE_STATUS, IntBuffer.wrap(statusVertex));
        if(statusVertex[0] == GL3.GL_FALSE)
        {
            int infoLogLenght[] = new int[1];
            gl.glGetShaderiv(vertexShaderID, GL3.GL_INFO_LOG_LENGTH, IntBuffer.wrap(infoLogLenght));
           
            byte infLog[] = new byte[1];
            gl.glGetShaderInfoLog(vertexShaderID, infoLogLenght[0], null, ByteBuffer.wrap(infLog));
            System.out.println("vertex shader error:" + Byte.toString(infLog[0]));
           
        }
       
       
       
        gl.glAttachShader(shaderProgramID, vertexShaderID);
        gl.glDeleteShader(vertexShaderID);

       
       
       
        int fragmentShaderID = gl.glCreateShader(GL3.GL_FRAGMENT_SHADER);
        gl.glShaderSource(fragmentShaderID, 1,
            new String[]{fragmentShader}, null);
        gl.glCompileShader(fragmentShaderID);
       
       
       
        int statusFragment[] = new int[1];
        gl.glGetShaderiv(fragmentShaderID, GL3.GL_COMPILE_STATUS, IntBuffer.wrap(statusFragment));
        if(statusFragment[0] == GL3.GL_FALSE)
        {
            int infoLogLenght[] = new int[1];
            gl.glGetShaderiv(fragmentShaderID, GL3.GL_INFO_LOG_LENGTH, IntBuffer.wrap(infoLogLenght));
           
            byte infLog[] = new byte[1];
            gl.glGetShaderInfoLog(fragmentShaderID, infoLogLenght[0], null, ByteBuffer.wrap(infLog));
            System.out.println("fragment shader error:" + Byte.toString(infLog[0]));
           
        }
       
       
       
        gl.glAttachShader(shaderProgramID, fragmentShaderID);
        gl.glDeleteShader(fragmentShaderID);
       
        gl.glLinkProgram(shaderProgramID);
       
       
       
        int statusLinker[] = new int[1];
        gl.glGetShaderiv(shaderProgramID, GL3.GL_LINK_STATUS, IntBuffer.wrap(statusLinker));
        if(statusLinker[0] == GL3.GL_FALSE)
        {
            int infoLogLenght[] = new int[1];
            gl.glGetShaderiv(shaderProgramID, GL3.GL_INFO_LOG_LENGTH, IntBuffer.wrap(infoLogLenght));
           
            byte infLog[] = new byte[1];
            gl.glGetShaderInfoLog(shaderProgramID, infoLogLenght[0], null, ByteBuffer.wrap(infLog));
            System.out.println("linker error:" + Byte.toString(infLog[0]));
           
        }
        gl.glValidateProgram(shaderProgramID);
       
    }
8  Java Game APIs & Engines / JOGL Development / vertex shader problem on: 2011-05-08 21:36:53
I have started learning modern opengl (version 3.3). I use JOGL2 RC2 Signed Released (jogl-2.0-b23-20110303-windows-i586). I have a problem with vertex shader - uniform vec2 offset doesn't work. The triangle doesn't move .... My initShader function works properly. I don't know what is wrong.

Tutorial: http://arcsynthesis.org/gltut/Positioning/Tut03%20A%20Better%20Way.html

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  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
public class Scene3D implements GLEventListener 
{
    private Frame frame;
    private FPSAnimator animator;
    private int vertexBufferObject;
    private int shaderProgramID;
    private FloatBuffer vertexDataBuffer;
    private float fXOffset = 0.01f;
    private float fYOffset = 0.01f;
    private int offsetLocation;
    private float vertices[];

    private static String vertexShader =
    "#version 330" + "\n" +
    "layout (location = 0) in vec4 position;" + "\n" +
    "uniform vec2 offset;" + "\n" +      
    "void main()" + "\n" +
    "{" + "\n" +
    "vec4 totalOffset = vec4(offset.x, offset.y, 0.0, 0.0);" + "\n" +      
    "gl_Position = position + totalOffset;" + "\n" +
    "}";
   
    private static String fragmentShader =
    "#version 330" + "\n" +  
    "out vec4 outputColor;" + "\n" +
    "void main()" + "\n" +
    "{" + "\n" +      
    "outputColor = vec4(1.0f, 1.0f, 1.0f, 1.0f);" + "\n" +
    "}";        
   
    public Scene3D(GLCapabilities capabilities)
    {
        GLCanvas glComponent = new GLCanvas(capabilities);
        glComponent.setFocusable(true);
        glComponent.addGLEventListener(this);
       
        frame = new JFrame("JOGL");
        frame.addWindowListener(new WindowAdapter()
        {
            @Override
            public void windowClosing(WindowEvent e)
            {
                runExit();
            }
        });
        frame.setLayout(new BorderLayout());
        glComponent.setPreferredSize(new Dimension(800, 600));
        frame.add(glComponent, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
        glComponent.requestFocus();
        animator = new FPSAnimator(glComponent, 60, true);
        animator.start();
    }

    public static void main(String[] args)
    {
       
        GLProfile profile = GLProfile.get(GLProfile.GL3);
        final GLCapabilities capabilities = new GLCapabilities(profile);
       
        SwingUtilities.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                new Scene3D(capabilities);
               
            }
        });
       
    }

    @Override
    public void init(GLAutoDrawable glad)
    {
        GL3 gl = glad.getGL().getGL3();
        gl.setSwapInterval(1);
        gl.glEnable(GL3.GL_DEPTH_TEST);
        gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

        vertices = new float[]{0.0f, 0.5f, 0.0f, 1.0f,
                                       0.5f, -0.366f, 0.0f, 1.0f,
                                       -0.5f, -0.366f, 0.0f, 1.0f};
       
        vertexDataBuffer = Buffers.newDirectFloatBuffer(vertices.length);
        vertexDataBuffer.put(vertices);
        vertexDataBuffer.flip();

        initShaders(gl);
        initVBO(gl);
        offsetLocation = gl.glGetUniformLocation(shaderProgramID, "offset");
    }

    @Override
    public void dispose(GLAutoDrawable glad)
    {
       
    }

    @Override
    public void display(GLAutoDrawable glad)
    {
        GL3 gl = glad.getGL().getGL3();
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        gl.glUseProgram(shaderProgramID);
        gl.glUniform2f(offsetLocation, fXOffset, fYOffset);
        gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vertexBufferObject);
        gl.glEnableVertexAttribArray(0);
        gl.glVertexAttribPointer(0, 4, GL3.GL_FLOAT, false, 0, 0);
        gl.glDrawArrays(GL3.GL_TRIANGLES, 0, 3);
        gl.glDisableVertexAttribArray(0);
        gl.glUseProgram(0);
    }

    @Override
    public void reshape(GLAutoDrawable glad, int x, int y, int width, int height)
    {
       
    }
   
    private void initVBO(GL3 gl)
    {
        int buffer[] = new int[1];
        gl.glGenBuffers(1, IntBuffer.wrap(buffer));
        vertexBufferObject = buffer[0];
        gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vertexBufferObject);
        gl.glBufferData(GL3.GL_ARRAY_BUFFER, Buffers.SIZEOF_FLOAT * vertexDataBuffer.capacity(), vertexDataBuffer, GL3.GL_STREAM_DRAW);
        gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);
    }
   
    private void initShaders(GL3 gl)
    {
        shaderProgramID = gl.glCreateProgram();

        int vertexShaderID = gl.glCreateShader(GL3.GL_VERTEX_SHADER);
        gl.glShaderSource(vertexShaderID, 1,
            new String[]{vertexShader}, null);
        gl.glCompileShader(vertexShaderID);
        gl.glAttachShader(shaderProgramID, vertexShaderID);
        gl.glDeleteShader(vertexShaderID);

        int fragmentShaderID = gl.glCreateShader(GL3.GL_FRAGMENT_SHADER);
        gl.glShaderSource(fragmentShaderID, 1,
            new String[]{fragmentShader}, null);
        gl.glCompileShader(fragmentShaderID);
        gl.glAttachShader(shaderProgramID, fragmentShaderID);
        gl.glDeleteShader(fragmentShaderID);
       
        gl.glLinkProgram(shaderProgramID);
        gl.glValidateProgram(shaderProgramID);
       
    }

    private void runExit()
    {
        new Thread(new Runnable()
        {
            @Override
            public void run()
            {
                animator.stop();
                System.exit(0);
            }
        }).start();
    }

}
9  Java Game APIs & Engines / JOGL Development / Re: vbo MapBuffer problem on: 2011-05-03 22:07:30
I know these concepts (that are fundamentals of OpenGL), but I wrong understood you. My English isn't perfect. I assumed that using glTranslate to animate is not a good idea. Of course when I only want to animate the cube and nothing else happens I can use glTranslate instead of glMapBuffer to achieve the same effect:

1  
2  
3  
4  
5  
gl.glPushMatrix();
gl.glTranslatef(0.0f, y, 0.0f);
gl.glDrawArrays(GL.GL_QUADS, 0, 24);
gl.glPopMatrix();
y += 0.5f;


In more complex situation, for example in same physics simulation where many object interact with each other using glTranslate to animate objects seems to be unsuitable. I'm going to work in JOGL 2, because I want to learn opengl 3.3 (and subsequent) features. I know a few very good opengl tutorials but first I need to make good JOGL2 framework in Netbeans. Which JOGL2 tutorial can you recommend me ?
10  Java Game APIs & Engines / JOGL Development / Re: vbo MapBuffer problem on: 2011-05-03 11:24:30
Thank you. I examine how VBO works. It is good thing when you have many objects, for example in some physics simulations. However a transfer of data between a gpu memory and client memory might be a bottleneck. I want to use JCUDA to interact with JOGL. Then VBO cooperate with JCUDA and a data transfer between the client and server is needless. What do you mean by transform matrices ? Could you show some example? JOGL 1.1.1.a supports opengl 3.0. How big are difference between using VBO in JOGL 2 and JOGL 1.1.1.a ?
11  Java Game APIs & Engines / JOGL Development / Re: vbo MapBuffer problem on: 2011-05-02 16:56:19
Netbeans 6.7.1 + JOGL 1.1.1.a (plugin). Complete Netbeans project: http://www.speedyshare.com/files/28257488/SimpleGLCanvas.rar
12  Java Game APIs & Engines / JOGL Development / Re: vbo MapBuffer problem on: 2011-05-02 14:22:00
I changed my code but still nothing happens.
13  Java Game APIs & Engines / JOGL Development / vbo MapBuffer problem on: 2011-05-02 12:38:27
Hi! I use JOGL 1.1.1.a. I can draw my cube using vbo but when I want to animate the cube I have a problem with change vertices position.

Init VBO
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
gl.glGenBuffers(bufferSize, IntBuffer.wrap(buffer));

verticesID = buffer[0];
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, verticesID);
gl.glBufferData(GL.GL_ARRAY_BUFFER, BufferUtil.SIZEOF_FLOAT * vertices.capacity(), vertices, GL.GL_DYNAMIC_DRAW);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);

normalsID = buffer[1];
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, normalsID);
gl.glBufferData(GL.GL_ARRAY_BUFFER, BufferUtil.SIZEOF_FLOAT * normals.capacity(), normals, GL.GL_DYNAMIC_DRAW);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);

gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL.GL_NORMAL_ARRAY);


Display and Update Vertices
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  
gl.glPushMatrix();

gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, material.getAmbient(), 0);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, material.getDiffuse(), 0);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, material.getSpecular(), 0);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, material.getEmission(), 0);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, material.getShininess(), 0);

gl.glBindBuffer(GL.GL_ARRAY_BUFFER, verticesID);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);

gl.glBindBuffer(GL.GL_ARRAY_BUFFER, normalsID);
gl.glNormalPointer(GL.GL_FLOAT, 0, 0);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);

gl.glDrawArrays(GL.GL_QUADS, 0, 24);

gl.glBindBuffer(GL.GL_ARRAY_BUFFER, verticesID);

byteBuffer = gl.glMapBuffer(GL.GL_ARRAY_BUFFER, GL.GL_READ_WRITE);
if(bufferRW != null)
{
     srcVertices = byteBuffer.asFloatBuffer();
     
     vertices.rewind();
           
     for(int i = 0; i < 24; i++)
     {
          vX = srcVertices.get();
          vY = srcVertices.get();
          vZ = srcVertices.get();

          vertices.put(vX);
          vertices.put(vY + 0.2f);
          vertices.put(vZ);
     }
}
gl.glUnmapBuffer(GL.GL_ARRAY_BUFFER);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
gl.glPopMatrix();


The cube should move up but nothing happens. What is wrong with my code ?
14  Java Game APIs & Engines / JOGL Development / Re: JOGL2 - confusion on: 2011-04-26 10:36:30
The latest dev build == the latest automatic build ?
15  Java Game APIs & Engines / JOGL Development / Re: JOGL2 - confusion on: 2011-04-25 12:43:35
The latest signed release (the most stable and recommended version) of JOGL 2 seems to be : jogl-2.0-b23-20110303,  but this is still JOGL 2 Release Candidate 2 version. If I'm wrong, please let me know.
16  Java Game APIs & Engines / JOGL Development / JOGL2 - confusion on: 2011-04-24 18:22:52
I'm going to try JOGL 2. Has JOGL 2 (final, stable version) been released already ? Where is the official JOGL website ?
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (23 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (41 views)
2014-08-06 19:49:38
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!