Is it possible to use immediate mode with shaders?

Such as:


public void render(Renderer renderer){
		Matrix4f transMatrix = MatrixUtils.createTransformationMatrix(p, 0, 0, 0, 2);
		Vector3f e = getRayPoint(t);
		renderer.initDebugRender();
		
		renderer.debugShader.setUniform("transformationMatrix", transMatrix);
		
		GL11.glLineWidth(2.5f);
		GL11.glBegin(GL11.GL_LINES);
			GL11.glVertex3f(0, 0, 0);
			GL11.glVertex3f(e.x, e.y, e.z);
		GL11.glEnd();
		
		renderer.endDebugRender();
	}

Note: initDebugRender() and endDebugRender() bind and unbind the associated shader as well as in the initDebugRender i set the view and projection matrices.

I would like to know if this would actually work?

Because i see nothing when trying it.

Shader Code: http://pastebin.com/0S7yzA47

Yes, it should work. And you can even specify generic vertex attributes with glVertexAttrib.
The only thing that does not work with immediate mode is instancing, I think.
But anything else should work just like when using buffer objects.

But I’d first start with a simpler version 110 shader that just passes-through the gl_Vertex to gl_Position, and draw a simple (-1, -1) to (+1, +1) line with glVertex3f (or glVertex2f).

I also don’t think that your driver accepts a version 330 shader (without compatibility profile) that uses the deprecated gl_Vertex in/attribute.
Mine (latest Nvidia) errors: “global variable gl_Vertex is removed after version 140”

Did you check whether the shader actually compiles without errors/warnings and that the program also links without errors/warnings?

Will try!

Also yeah i check for shader errors when linking and validating the shader(s):

glLinkProgram(programID);
			if(glGetProgrami(programID, GL_LINK_STATUS) == 0){
				throw new Exception("Error linking Shader Code: " + glGetShaderInfoLog(programID));
			}
			
			glValidateProgram(programID);
			if(glGetProgrami(programID, GL_VALIDATE_STATUS) == 0){
				throw new Exception("Error validating Shader Code: " + glGetShaderInfoLog(programID));
			}

Got your suggestion working, after realizing that i wasn’t calling the render method :cranky:.

Will try see if if works when i plugin the matrices

It works perfectly :D. I can now quickly and easily draw primitives for debugging purposed such as rays or squares.

Thanks.