[Solved]Help plz OpenGL 2.1

Started by Andrew Alfazy, April 10, 2018, 11:59:38

Previous topic - Next topic

Andrew Alfazy

Hi,
I'm trying to learn OpenGL 2.1,How can I draw Triangle with VBOs and shader without vao(because it is opengl 3.xx),And If you now a good Tutorial it is better.
thanks.
and sorry  for my bad English :-[.

josephdoss

The OpenGL SuperBible is the book that helped me the most. ( 7th Edition was the best ).
There are some good websites out there, but this book is the only resource I keep coming back to.

http://www.openglsuperbible.com/

Nehe is probably my second most useful resource.
http://nehe.gamedev.net/

Andrew Alfazy

thanks I still need more help. how can I send data from poitions vbo,colors vbo etc to shader like this
#version 120

attribute vec2 position;
attribute vec4 color;
attribute vec2 texCoord;

varying vec4 vColor;
varying vec2 vTexCoord;

void main(void){
	vColor = color;
	vTexCoord = texCoord;
	
	gl_Position = vec4(position,0.0,1.0);
}

OpenGL 2.1 plz

josephdoss

Here's a great page that walks you through communicating with shaders, with code examples.
http://wiki.lwjgl.org/wiki/GLSL_Tutorial:_Communicating_with_Shaders.html

If you ever plan on moving up to a newer version of OpenGL, I suggest you stop using attributes and start using uniforms. It'll save you a lot of headache in the long run.



KaiHH

QuoteI suggest you stop using attributes and start using uniforms. It'll save you a lot of headache in the long run.
I think the headache will only get bigger, trying to find ways to shove all the million vertices into a big uniform array... :)

Remember that the "attribute" keyword in the vertex shader is equivalent to the "in" attribute, so they are used to specify the variable holding the vertex attribute value for a particular shader invocation.

josephdoss

QuoteI think the headache will only get bigger, trying to find ways to shove all the million vertices into a big uniform array... :)
Oh goodness, I might have been doing it wrong this whole time.
Thanks KaiHH.

Andrew Alfazy

In my opinion:
using uniforms to render models is bad idea because in this situation we sending too many vertices (vertices color and texcoords )per model per frame to GPU we will get bad performance but when we use vbo(s) we send vertices to GPU once per model at start then we just switching between vbo(s) per model per frame (no data resend) uniform useful in some situations like custom lighting,reflection,blur,etc.