What is Vector in glfw

1
2
3
4
5
layout(location=0)in       vec3 position
void main()
{
  gl_Position=vec4(position.x,position.y.position.z,1.0);
}


What are these "vec3","vec4" in glfw?
Why they have been used here?
They are mathematical vectors. If you've ever studied linear algebra you'd know that They are one of the most important things in 3D programming.

If you want someone to explain vector multiplication and scalar, and pretty much how they are used within the 3D World - https://www.youtube.com/playlist?list=PLRwVmtr-pp04XomGtm-abzb-2M1xszjFx

Bunch of vector videos in that playlist.

Then there is khan academy with mathematical vectors - https://www.youtube.com/playlist?list=PLFD0EB975BA0CC1E0

Or you can just google linear algebra vectors and read about them =)

Edit:

Note that openGL does not have vec3, vec4 like in your code. You will have to use a library for that, the best one in my opinion, and the most used one is GLM.
Last edited on
How is that possible! I have copied it from the source code of my tutorial
That's because your code is GLSL. It's shaders, right? In GLSL (the code you write for shaders) vec3, vec4, and matrices exist there, but not in the CPU part of openGL. Then you would need a library

http://learnopengl.com has a page where it explains everything about vectors and matrices aswell (matrices are even more important than vectors)

http://learnopengl.com/#!Getting-started/Transformations

Edit: Also, you should stop posting in the windows section of this forum, this has nothing to do with window programming.
Last edited on
Which section would be more apropriate for these questions? #TarikNeaj
General c++ Programming
Topic archived. No new replies allowed.