Weird behavior when trying to make wiki examples working

Started by OverBlob, August 31, 2012, 23:27:37

Previous topic - Next topic

OverBlob

Hello guys,

I've been learning openGl and LWJGL for about4 month now. I first studied all the wiki samples and try to make them work. But from"The quad colored" example and more particularly from using more than 1 attribute in "glVertexAttribPointer" I have a weird rectangle on my screen.


instead of the beautiful colored rectangle on the wiki page...
I made a simple copy/paste of the code.

After some headaches searching why I couldn't have the same result as the wiki's I found that actually my application inverted the attributes order  between vertices and colors(it used the vertex tab as vertice colors and the color tab for position :o), so I tried to switch attribute numbers as shown in the next screenshot and then I had the expected resulting rectangle..


But I don't understand why, does someone have a clue?? It is disturbing me  ???

IchBinMude

239.GL20.glLinkProgram(pId);
240. 
241.// Position information will be attribute 0
242.GL20.glBindAttribLocation(pId, 0, "in_Position");
243.// Color information will be attribute 1
244.GL20.glBindAttribLocation(pId, 1, "in_Color");
245.// Textute information will be attribute 2
246.GL20.glBindAttribLocation(pId, 2, "in_TextureCoord");


I believe the reason is the glBindAttribLocation's are called after glLinkProgram, which more than likely is causing the swapping. Call all of the glBindAttribLocation's before you link your shader program and you won't have the "compiler mix up".

OverBlob