nehe port - where to find the resources (images)?

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

nehe port - where to find the resources (images)?

rtayek
hi, trying to get the nehe port to run in eclipse.

it compiles. but can not find the images like: demos\data\images\terrain.bmp

does anyone know where they live?

thanks
Reply | Threaded
Open this post in threaded view
|

Re: nehe port - where to find the resources (images)?

rtayek
found some here (including the source) http://www.java-tips.org/images/stories/tips/others/jogl/170606/nehe.zip

lesson45 now working.

vbo test throws a npe in gl.glGenBuffers(2,temp,0); - original code was using awt while i am using a jpanel.

thanks
Reply | Threaded
Open this post in threaded view
|

Re: nehe port - where to find the resources (images)?

gouessej
Administrator
Which variable is set to null? The GL? Can you show your source code?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: nehe port - where to find the resources (images)?

rtayek
At 03:12 AM 8/31/2012, you wrote:
>Which variable is set to null?
>Julien Gouesse http://tuer.sourceforge.nethttp://gouessej.wordpress.com

none naict.

private int[] VBOVertices=new int[1];
gl.glGenBuffers(1, VBOVertices, 0);


stepping into glGenBuffers throws. this code works fine in vbo test
that uses a gl canvas. i am using a gl jpanel.

i don't have the source hooked up yet.

thanks
---
co-chair http://ocjug.org/

Reply | Threaded
Open this post in threaded view
|

Re: nehe port - where to find the resources (images)?

rtayek
not sure why my code was throwing, but this code works fine:

import java.nio.FloatBuffer;
import java.nio.ShortBuffer;

import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLJPanel;
import javax.media.opengl.fixedfunc.GLPointerFunc;
import javax.swing.JFrame;
import javax.swing.WindowConstants;

import com.jogamp.common.nio.Buffers;
public class VBOGLJPanel extends GLJPanel implements GLEventListener {
        public static void main(String[] args) {
                JFrame frame=new JFrame();
                frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                VBOGLJPanel canvas=new VBOGLJPanel();
                canvas.addGLEventListener(canvas);
                frame.add(canvas);
                frame.setSize(640,480);
                frame.setVisible(true);
        }
        @Override public void init(GLAutoDrawable drawable) {
                vboInit(drawable);
        }
        private void vboInit(GLAutoDrawable drawable) {
                float[] vertexArray={-0.5f,0.5f,0,0.5f,0.5f,0,0.5f,-0.5f,0,-0.5f,-0.5f,0};
                FloatBuffer vertices=Buffers.newDirectFloatBuffer(vertexArray.length);
                vertices.put(vertexArray);
                vertices.flip();
                short[] indexArray={0,1,2,1/* 0 */,2,3};
                ShortBuffer indices=Buffers.newDirectShortBuffer(indexArray.length);
                indices.put(indexArray);
                indices.flip();
                GL gl=drawable.getGL();
                gl.glGenBuffers(1,VBOVertices,0);
                gl.glBindBuffer(GL.GL_ARRAY_BUFFER,VBOVertices[0]);
                gl.glBufferData(GL.GL_ARRAY_BUFFER,vertices.capacity()*Buffers.SIZEOF_FLOAT,vertices,GL.GL_STATIC_DRAW);
                gl.glBindBuffer(GL.GL_ARRAY_BUFFER,0);
                gl.glGenBuffers(1,VBOIndices,0);
                gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER,VBOIndices[0]);
                gl.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER,indices.capacity()*Buffers.SIZEOF_SHORT,indices,GL.GL_DYNAMIC_DRAW);
                gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER,0);
                indicesCapacity=indices.capacity();
        }
        private void vboRender(GLAutoDrawable drawable) {
                GL2 gl=drawable.getGL().getGL2();
                gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
                gl.glBindBuffer(GL.GL_ARRAY_BUFFER,VBOVertices[0]);
                gl.glVertexPointer(3,GL.GL_FLOAT,0,0);
                gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER,VBOIndices[0]);
                gl.glDrawElements(GL.GL_TRIANGLES,indicesCapacity,GL.GL_UNSIGNED_SHORT,0);
                gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
        }
        @Override public void display(GLAutoDrawable drawable) {
                vboRender(drawable);
        }
        @Override public void reshape(GLAutoDrawable drawable,int x,int y,int width,int height) {}
        public void displayChanged(GLAutoDrawable drawable,boolean modeChanged,boolean deviceChanged) {}
        @Override public void dispose(GLAutoDrawable drawable) {}
        private int[] VBOVertices=new int[1];
        private int[] VBOIndices=new int[1];
        int indicesCapacity;
        private static final long serialVersionUID=1L;
}