problems texture mapping in modern OpenGL 3.3 using GLSL #version 150

Posted by RubyKing on Game Development See other posts from Game Development or by RubyKing
Published on 2012-03-24T13:49:45Z Indexed on 2012/03/24 17:38 UTC
Read the original article Hit count: 258

Filed under:
|
|

Hi all I'm trying to do texture mapping using Modern OpenGL and GLSL 150.

The problem is the texture shows but has this weird flicker I can show a video here

http://www.youtube.com/watch?v=xbzw_LMxlHw

and I have everything setup best I can

have my texcords in my vertex array sent up to opengl

I have my fragment color set to the texture values and texel values I have my vertex sending the textures cords to texture cordinates to be used in the fragment shader I have my ins and outs setup and I still don't know what I'm missing that could be causing that flicker.

here is my code

FRAGMENT SHADER

#version 150

   uniform sampler2D texture;     
   in vec2 texture_coord;

 varying vec3 texture_coordinate;      
    void main(void){


  gl_FragColor = texture(texture, texture_coord);

  }

VERTEX SHADER

#version 150


in vec4 position;


out vec2 texture_coordinate; 

out vec2 texture_coord;

uniform vec3 translations;

void main() {

texture_coord = (texture_coordinate);

gl_Position = vec4(position.xyz + translations.xyz, 1.0);  

}

Last bit

here is my vertex array with texture cordinates

GLfloat vVerts[] = {

0.5f, 0.5f, 0.0f, 0.0f, 1.0f ,

0.0f, 0.5f, 0.0f, 1.0f, 1.0f,

0.0f, 0.0f, 0.0f, 0.0f, 0.0f,

0.5f, 0.0f, 0.0f, 1.0f, 0.0f}; //tex x and y

HERE IS THE ACTUAL FULL SOURCE CODE

if you need to see all the code in its fullest glory here is a link to every file http://ideone.com/7kQN3

thank you for your help

© Game Development or respective owner

Related posts about c++

Related posts about opengl