Hello Guest

[Solved]Help plz OpenGL 2.1

  • 6 Replies
  • 438 Views
[Solved]Help plz OpenGL 2.1
« on: April 10, 2018, 11:59:38 »
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 :-[.
« Last Edit: April 10, 2018, 17:56:08 by Andrew Alfazy »

*

Offline josephdoss

  • *
  • 15
  • redbirdflyfree.blogspot.com
    • game dev
Re: Help plz OpenGL 2.1
« Reply #1 on: April 10, 2018, 12:12:02 »
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/

Re: Help plz OpenGL 2.1
« Reply #2 on: April 10, 2018, 15:58:37 »
thanks I still need more help. how can I send data from poitions vbo,colors vbo etc to shader like this
Code: [Select]
#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
« Last Edit: April 10, 2018, 16:07:34 by Andrew Alfazy »

*

Offline josephdoss

  • *
  • 15
  • redbirdflyfree.blogspot.com
    • game dev
Re: Help plz OpenGL 2.1
« Reply #3 on: April 10, 2018, 17:23:26 »
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.


« Last Edit: April 10, 2018, 17:29:30 by josephdoss »

*

Offline KaiHH

  • ***
  • 137
Re: [Solved]Help plz OpenGL 2.1
« Reply #4 on: April 10, 2018, 18:13:18 »
Quote
I 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.

*

Offline josephdoss

  • *
  • 15
  • redbirdflyfree.blogspot.com
    • game dev
Re: [Solved]Help plz OpenGL 2.1
« Reply #5 on: April 10, 2018, 18:54:25 »
Quote
I 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.

Re: [Solved]Help plz OpenGL 2.1
« Reply #6 on: April 10, 2018, 19:40:15 »
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.