MyniqX's picture

gl_TexCoord[0].st = (0,0) always. im going to crazy...

this is my shader's code :

    static string V_PROG_default =
        @"
            varying vec2 texCoord;
 
            void main()
            {
                texCoord = gl_TexCoord[0].st;
                gl_Position = ftransform();
            }
        ";
 
        static string F_PROG_default =
        @"
            varying vec2 texCoord;
            uniform sampler2D colorMap;
 
            void main()
            {
                gl_FragColor  = texture2D(colorMap,texCoord);
            }
        ";

and here is my render code :

 
  void BindTexture(dotTexture tt,TextureUnit unit,int addr)
        {
            GL.ActiveTexture(unit);
            tt.Bind();
            GL.Uniform1(addr, (int)(unit - TextureUnit.Texture0));
            GL.ActiveTexture(TextureUnit.Texture0);
 
        }
 
void RenderPiece() 
{
             prog.Bind();
 
            BindTexture(texture, TextureUnit.Texture3, prog.getAdress("colorMap"));
 
            float x = position.x - image.origin.x;
            float y = position.y - image.origin.y;
            float w = image.size.x, h = image.size.y;
 
            GL.Begin(BeginMode.Quads);
 
 
            GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(x, y);
            GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(x + w, y);
            GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(x + w, y + h);
            GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(x, y + h);
 
            GL.End();
 
            UnBindTexture(TextureUnit.Texture3);
 
            prog.Release();
}

this is shader creating :

       public bool CreateProgram(string str_vert, string str_frag)
        {
            vert.programText.Clear();
            vert.programText.Append(str_vert);
 
            frag.programText.Clear();
            frag.programText.Append(str_frag);
 
            return CreateProgram();
        }
 
        public bool CreateProgram()
        {
            int handle = GL.CreateProgram();
 
            if (frag.Compile() == false || vert.Compile() == false)
            {
                Lup.Log("Fragment : " + frag.ErrorString + Environment.NewLine + ID +
                         "Vertex : " + vert.ErrorString);
 
                frag.Delete();
                vert.Delete();
                return false;
            }
 
            GL.AttachShader(handle, frag.programID);
            GL.AttachShader(handle, vert.programID);
            GL.LinkProgram(handle);
 
            GL.GetProgram(handle, ProgramParameter.LinkStatus, out ErrorCode);
 
            if (ErrorCode != 1)
            {
                ErrorString = GL.GetProgramInfoLog(handle);
                Lup.Log("Program Link Status : " + ErrorString);
 
                frag.Delete();
                vert.Delete();
                return false;
            }
            else
            {
                programID = handle;
                Lup.Log("Program is success :" + GL.GetProgramInfoLog(handle));
            }
 
 
            CheckUniforms();  //this ll log all uniforms in shader...
 
            return true;
        }

and result is nothing...
i have tried to debug it.. and i saw in shader texCoord.x allways lower than 0.1 maybe allways 0...
i couldnt find what is wrong.

i hope you can see.

note:
without program.bind() everything is there.
i have another shader too. it gives some lighting. but i cant see textures too.

regards...