Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Help setting up a GLSL shader with JOGL

843799Apr 4 2007 — edited Jun 1 2007
Hi,

I'm trying to set up a shader in jogl but with little success.
What I'm stuck at is the function glShaderSource, which Java can't find.

This is the code I'm using to set it up. Stole it from another website ^^
		gl.glShadeModel(GL.GL_SMOOTH);
		gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
		gl.glClearDepth(1.0f);
		gl.glEnable(GL.GL_DEPTH_TEST);
		gl.glDepthFunc(GL.GL_LEQUAL);
		gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
		gLDrawable.addKeyListener(this);
	   
		int v = gl.glCreateShader(GL.GL_VERTEX_SHADER);
		int f = gl.glCreateShader(GL.GL_FRAGMENT_SHADER);

		BufferedReader brv = new BufferedReader(new FileReader("./shader/vertex.shader"));
		String vsrc = "";
		String line;
		while ((line=brv.readLine()) != null) {
		  vsrc += line + "\n";
		}
		gl.glShaderSource(v, 1, vsrc, (int[])null);
		gl.glCompileShader(v);

		BufferedReader brf = new BufferedReader(new FileReader("./shader/fragment.shader"));
		String fsrc = "";
		while ((line=brf.readLine()) != null) {
		  fsrc += line + "\n";
		}
		gl.glShaderSource(f, 1, fsrc, (int[])null);
		gl.glCompileShader(f);

		int shaderprogram = gl.glCreateProgram();
		gl.glAttachShader(shaderprogram, v);
		gl.glAttachShader(shaderprogram, f);
		gl.glLinkProgram(shaderprogram);
		gl.glValidateProgram(shaderprogram);

		gl.glUseProgram(shaderprogram);	
So it finds everything else but the glShaderSource.
I looked at the examples @ jogl homepage but I think they�re using a different method or something.

Would be greatful for any help/tips!

[EDIT] The function I've seen being used is glShaderSourceARB. But I have a graphiccard that supports OpenGL 2.0 so I should not use them right?

/Yooni

Message was edited by:
Yooni

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 29 2007
Added on Apr 4 2007
1 comment
365 views