Minib3d Implementing a shader

BlitzMax Forums/MiniB3D Module/Minib3d Implementing a shader

BLaBZ(Posted 2012) [#1]
Hey Guys, I'm relatively new to shader's and I'm having a hard time implementing this shader class in minib3d:




I've modified the TMesh class to enable and disable the program object right before and after it calls glDrawElements:



The shader code I'm passing in is this:

Vertex code:
Const VERTEX_CODE:String = .. 
	"attribute vec4 vPosition;~n" + ..
	"void main( void ) {~n" + ..
		"gl_Position = vPosition;~n" + ..
	"}"


Fragment code:
Const FRAGMENT_CODE:String = ..
	"precision mediump float;~n" + ..
	"void main(void) {~n" + ..
		"gl_FragColor = vec4(1.0,0.0,0.0,1.0);~n" + ..
	"}"


I keep getting this red line across the screen, I have a feeling the problem is with the shader code but I'm not sure if this implementation would work,

All guidance and tips welcome.

Thanks alot!


angros47(Posted 2012) [#2]
Why have you commented "glBindAttribLocation" ?
Without it, you don't pass vertex data to your shader, so it won't work.


AdamRedwoods(Posted 2012) [#3]
Here is my old shader class.
I won't support this, since my monkey+minib3d TShader class is much better (and old code).

TShader.bmx


TGlobal.bmx


test_shader.txt


Last edited 2012

Last edited 2012


Ferret(Posted 2012) [#4]
This might help.

First load a shader.
Bind the shader just before RenderWorld().
Unbind the shader just after RenderWorld().

This will affect the complete world, single meshes or surfaces is a litle more work.

TShader.bmx



The shader below colors everything green, so when you see allot of green it works :-)

Shader.vert


Shader.frag


Last edited 2012