Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (290)
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 / Re: JOGL 2D Texture Example on: 2012-08-21 23:31:51
Agh, silly me.
1  
gl.glVertexPointer(3, GL2.GL_FLOAT, 0, verts);

Where are your 3D coordinates, mate? It reads outside the bounds of the vertex array since it assumes that it has 3 coordinates per vertex, not 2. Change the 3 to 2 and it should work.

Updated, but still the same problem.

Since it's saying it's accessing memory address 0x0, I don't think the bounds problem would be it?  It's like it's not even getting the buffers in the first place.
2  Java Game APIs & Engines / JOGL Development / Re: JOGL 2D Texture Example on: 2012-08-21 23:20:28
When do I have to disable them?  Before glDrawArrays?  Because if I don't call glDrawArrays, it doesn't crash, but, of course, nothing is displayed.  If I call glDrawArrays, it crashes, but it feels... like calling disable before drawing wouldn't work?
3  Java Game APIs & Engines / JOGL Development / Re: JOGL 2D Texture Example on: 2012-08-21 23:11:19
Sorry, I missed some of the initialization steps in the copy+paste.

That's how I've setup the surface.
4  Java Game APIs & Engines / JOGL Development / JOGL 2D Texture Example on: 2012-08-21 22:26:04
I'm sorry, but I've been trying to find an example of how to do 2D textures with JOGL and just keep failing.  My code looks like this:

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  
In reshape:
        gl.glViewport(0, 0, width, height); // Reset The Current Viewport
       gl.glMatrixMode(GL2.GL_PROJECTION); // Select The Projection Matrix
       gl.glLoadIdentity(); // Reset The Projection Matrix
       // hard coded values - this needs to change based on screen size
       gl.glOrthof(0, GL_WIDTH, GL_HEIGHT, 0, -1, 1);
        gl.glMatrixMode(GL2.GL_MODELVIEW); // Select The Modelview Matrix
       gl.glLoadIdentity(); // Reset The Modelview Matrix

In draw:
        gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        gl.glClear(GL2.GL_DEPTH_BUFFER_BIT | GL2.GL_COLOR_BUFFER_BIT);

        gl.glEnable(GL2.GL_TEXTURE_2D);
        gl.glEnable(GL2.GL_BLEND);
        gl.glBlendFunc(GL2.GL_ONE, GL2.GL_ONE_MINUS_SRC_ALPHA);
        gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL2.GL_COLOR_ARRAY);
        gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        gl.glLoadIdentity();

            final Texture mTest = TextureIO.newTexture(getClass().getResource("/images/glass.png"), false, TextureIO.PNG);
            final float[] coordData = {
                    0, 0, //
                   0, 1, //
                   1, 0, //
                   1, 1,
            };
            final float[] vertices = {
                    0.0f, 0.0f, 0, // Left Bottom
                   0.0f, 128, 0, // Left Top
                   128, 0.0f, 0, // Right Bottom
                   128, 128, 0
            };
            // Setup the vertices into the buffer
           verts = Buffers.newDirectFloatBuffer(vertices.length);
            verts.put(vertices).position(0);

            // Setup the texture coordinates
           coords = Buffers.newDirectFloatBuffer(coordData.length);
            coords.put(coordData).position(0);

            mTest.enable(gl);
            mTest.bind(gl);
            gl.glLoadIdentity();
            gl.glTranslatef(100, 100, 0);
            gl.glVertexPointer(3, GL2.GL_FLOAT, 0, verts);
            gl.glTexCoordPointer(2, GL2.GL_FLOAT, 0, coords);
            gl.glDrawArrays(GL2.GL_TRIANGLE_STRIP, 0, 4);


I get a "Invalid memory access of location 0x0 rip=0x11cfae8ae" when it executes gl.glDrawArrays, and I just don't understand what I'm doing wrong.

I'm almost positive I have the latest version, as I donwloaded from http://jogamp.org/ just the other day.

Any help would be greatly appreciated.

Thank you.
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (63 views)
2013-05-17 21:29:12

alaslipknot (72 views)
2013-05-16 21:24:48

gouessej (103 views)
2013-05-16 00:53:38

gouessej (100 views)
2013-05-16 00:17:58

theagentd (110 views)
2013-05-15 15:01:13

theagentd (100 views)
2013-05-15 15:00:54

StreetDoggy (145 views)
2013-05-14 15:56:26

kutucuk (168 views)
2013-05-12 17:10:36

kutucuk (167 views)
2013-05-12 15:36:09

UnluckyDevil (176 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.194 seconds with 21 queries.