shader not working on my machine

Before you tell me to update my drivers, I have. And the highest my machine will update to is:
OpenGL Version: 2.1.0 - Build 8.15.10.2086

Here’s the vertex shader code… it just wont compile for me


attribute vec3 vertex;
attribute vec2 texturecoordinate;
uniform vec3 rotation;
uniform vec3 translation;
uniform vec3 rotation_centre;
void main() {

	vec3 adjusted = vertex + translation;
	
	if (rotation.x != 0 || rotation.y != 0 || rotation.z != 0) {
		adjusted -= rotation_centre;
		float cosx = cos(rotation.x);
		float sinx = sin(rotation.x);
		float cosy = cos(rotation.y);
		float siny = sin(rotation.y);
		float cosz = cos(rotation.z);
		float sinz = sin(rotation.z);
		float nx = adjusted.x;
		float ny = (adjusted.y * cosx) - (adjusted.z * sinx);
		float nz = (adjusted.y * sinx) + (adjusted.z * cosx);
		float cz = (nz * cosy) - (nx * siny);
		float cx = (nz * siny) + (nx * cosy);
		float cy = ny;
		nx = (cx * cosz) - (cy * sinz);
		ny = (cx * sinz) + (cy * cosz);
		nz = cz;
		adjusted = vec3(nx,ny,nz) + rotation_centre;
	}
	
	vec4 mvv = gl_ModelViewMatrix * vec4(adjusted, 1.0);
	gl_Position = gl_ProjectionMatrix *  mvv;
	
}

Here is the error when I try to compile the vertex shader using RenderMonkey

Direct image link: http://i.imgur.com/wZ0vvWk.jpg

The most important part of the error message is cut off in your screenshot but you could try replacing the [icode]0[/icode]s with [icode]0.0[/icode]s.

Why you are doing uniform transform matrix math manually per vertex? Build up one mat4 at cpu containing all transformations and concanate that with view projection.

There is a method that functions like that , this is for testing. The error message says != is not supported

That actually helped with 1 of 2 Eclipse debug errors. I’ll run the code through RenderMonkey and get a full screen shot of the error too for you:

Direct img url: http://i.imgur.com/noXZ3iW.jpg

Sorry if the error is completely amateur I really don’t know much about shaders at all. I’ve always paid people to write them for my programs due to lack of study time…

Updated shader code, all that’s different is the 0 are now 0.0


attribute vec3 vertex;
attribute vec2 texturecoordinate;
uniform vec3 rotation;
uniform vec3 translation;
uniform vec3 rotation_centre;

void main() {

	vec3 adjusted = vertex + translation;
	
	if (rotation.x != 0.0 || rotation.y != 0.0 || rotation.z != 0.0) {
		adjusted -= rotation_centre;
		float cosx = cos(rotation.x);
		float sinx = sin(rotation.x);
		float cosy = cos(rotation.y);
		float siny = sin(rotation.y);
		float cosz = cos(rotation.z);
		float sinz = sin(rotation.z);
		float nx = adjusted.x;
		float ny = (adjusted.y * cosx) - (adjusted.z * sinx);
		float nz = (adjusted.y * sinx) + (adjusted.z * cosx);
		float cz = (nz * cosy) - (nx * siny);
		float cx = (nz * siny) + (nx * cosy);
		float cy = ny;
		nx = (cx * cosz) - (cy * sinz);
		ny = (cx * sinz) + (cy * cosz);
		nz = cz;
		adjusted = vec3(nx,ny,nz) + rotation_centre;
	}
	
	vec4 mvv = gl_ModelViewMatrix * vec4(adjusted, 1.0);
	gl_Position = gl_ProjectionMatrix *  mvv;
	
}

Now your shader compile fine. Rest of bugs are from render monkey.

In my Eclipse project I am still getting one error, but I’m not sure if this is something the general public could help with since lcass is the author of my wrapper.
But this still prints in my console: “Unable to link shader program:”

Source of error printing:


	/**
	 * Link the shader program to the GPU , must be done before attaching to a
	 * Vbo
	 */
	public void link() {
		glLinkProgram(programID);
		if (glGetProgrami(programID, GL_LINK_STATUS) == GL_FALSE) {
			System.err.println("Unable to link shader program:");
			dispose();
		}
	}

I’m a bit confused as to how to fix this, since I really don’t understand the code itself.

If you don’t understad the code then you either need to put more time into learning it, or use a library that handles it for you.

I only have free time from my job to study programming during the winter season… the rest of the year I travel to a lot of different states AND I have a toddler. I’m kind of tired of getting “learn what it does, use libgdx, etc etc”… No offence.
There’s a reason I’m paying $100s USD to other developers to create a solid foundation for me… If I had the time I did when I was a teenager, I’d love to learn the background code. But I simply can’t…
There’s nothing wrong with paying people to write a library and developer tools to my exact specifications. I’d much rather invest money and enjoy the little free time I have writing game play than spending my 1 or 2 days every other week stressing over background code and making 0 progress.

So… you don’t have the time to learn to use OpenGL directly, yet for some reason you don’t want to use a library that abstracts that away and would rather waste hours looking for other programmers who can be bothered to do it for you, and then pay them $100s to give you an inferior product to what already exists for free.

It doesn’t add up at all.

I get that you don’t have a lot of free time, but you’re still contradicting yourself.

I’ve used libraries such as LibGDX, jPCT, other small stuff from the net/githubs, etc.
I want something extremely lightweight, well documented, and written to MY EXACT specifications so that I can read and understand each and every single function at a later date when I have the available free time.
This isn’t a spontaneous idea I came up with over night. I have responsibilities in the real world and I’m doing things a certain way for very specific reasons. My personal library will be able to produce the assets I will need for my upcoming game - saving me money in the long run when it comes to needing models and certain textures.
It is what it is and I’m not really sure why anybody would be concerned about how my project is developed or why I’m doing things the way I do them… :clue:

Also if I wanted top notch quality I would use a game engine and mitigate the manual coding process completely. This is a part of my life that I do for fun. I’m not trying to create a number one MORPG or knock off of some other game. People spend money on stuff like drugs all the time, if I want to spend money on an inferior lwjgl product, so be it. I’m enjoying myself. :slight_smile:

Imagine walking in the jungle along next (but not to close) to a crocodile/piranha-infested river. You’ve just passed a newly constructed bridge with 2 lanes for cars and a footpath for pedestrians.

You come along a guy trying to build bridge out of fallen trees and stuff. You tell him there’s a bridge just around the bend but he says he’s trying to learn how to build bridges. You find that acceptable, so you resume walking down the river.

You come across another guy who jumps in the river and swims across to the other side, amazingly making it unharmed. You tell him there was a bridge just around the corner but he says it doesn’t matter because he’s already made it across. He’s right so you resume walking further down without further argument.

You then come across a guy who asks you if you can help him build a bridge across the river. You notify him that there is a bridge just around the bend, but he says he wants a bridge here, and with only a footpath for pedestrians. You tell him a guy down the river has been building his own bridge where he wanted it but the guy responds that he doesn’t have the time. You have places to be and other things to do so you just resume walking down the river.

You come back the next day and find the first guy has nearly finished his bridge. You then continue down the river and come across the same guy who has just finished asking to another guy to help him build a bridge. He appears to have been unsuccessful. You tell him that he could have been across the river yesterday if he just used the already existing bridge, or that if he starting building the bridge himself he would be almost finished. You even mention the guy who just swam across but he just sticks to his idea that he wants someone to build a bridge for him. Sick of arguing, you continue your walk along the river.

Over the next month, the first guy finishes his bridge, another five people come along and build their own bridges, and a few more lucky people swim across unharmed. You’ve stopped bothering to talk to the guy who wants a bridge built, but one day you see he has found a few people to build a bridge for him. You congratulate him but continue on your way regardless.

The next week you come back and see the guy standing on the other side of his new bridge, asking the people who built the bridge for him to help him cut a path through the jungle and back to the main road.

The moral of the story is that I have too much spare time and need to stop procrastinating and get back to my work.

… now that my thread has been saturated with stupid pointless annoying messages. I’m still having the same problem with the shader

That code should’ve not only checked the link status of the program but also any log messages generated by the driver upon linking the program.
Since compiling the individual shader objects seemed to have succeeded but the linker now complaining about something (maybe some varyings not fitting together), the error messages produced by the linker would now be very useful.
If you can, add (or have it added by the original author) the following right after the invocation of glLinkProgram, and see what gets printed:


String log = glGetProgramInfoLog(programID, 1024);
System.err.println("Linkage log: " + log);

That would give more insight into what goes wrong there.

Thank you! Finally I’m on the right path… The console error says:
Linkage log: Fragment shader uses varying vecdata but vertex shader does not write to it.
I’m going to toy around with the shaders myself but I’m not sure if I’ll be able to solve this.

Show the fragment shader code if you want some help with it?

The fragment shader currently does not implement that , hold on ill send you an update.