opengl-soil try to put a texture for first time

110 views Asked by At

i follow this tutorial http://open.gl/textures? i cannot understand these pieces of code and does not run in my visual studio project. Also, what type format is "in vec2" and "out vec3"??

in vec2 texcoord;

out vec3 Color;
out vec2 Texcoord;

void main()
{
    Texcoord = texcoord;

....

glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE,
                       7*sizeof(float), 0);
glVertexAttribPointer(colAttrib, 3, GL_FLOAT, GL_FALSE,
                       7*sizeof(float), (void*)(2*sizeof(float)));

GLint texAttrib = glGetAttribLocation(shaderProgram, "texcoord");
glEnableVertexAttribArray(texAttrib);
glVertexAttribPointer(texAttrib, 2, GL_FLOAT, GL_FALSE,
                       7*sizeof(float), (void*)(5*sizeof(float)));
1

There are 1 answers

0
derhass On

The first part you quoted is supposed to be a vertex shader. It is written in GLSL and not supposed to be understood by Visual Studio (or any other C/C++ compiler, for that matter), but by the GLSL compiler of your GL implementation. The rest you quoted is GL client code which is executed on the host CPU, setting up generic vertex attribute arrays.

You should really work through the more basic parts of that tutorial, before trying the textures lesseon. Shaders and generic attributes are introduced in the drawing lesson of said tutorial, which is essential for all of the following lesseons.