Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:10:42+00:00 2026-06-04T03:10:42+00:00

In GLSL version 110 i can get coordinate in gl_TexCoord[] but it’s deprecated in

  • 0

In GLSL version 110 i can get coordinate in gl_TexCoord[] but it’s deprecated in 150.

OpenGL code:

shader.setupShaderFromFile(GL_VERTEX_SHADER, "t.vert");
shader.setupShaderFromFile(GL_FRAGMENT_SHADER, "t.frag");
shader.linkProgram();

glGetFloatv(GL_MODELVIEW_MATRIX, modelview_mat_);
glGetFloatv(GL_PROJECTION_MATRIX, projectionview_mat_);

shader.begin();

glUniformMatrix4fv( glGetUniformLocation(shader.getProgram(), "MVMatrix"), 1, GL_FALSE, modelview_mat_);
glUniformMatrix4fv( glGetUniformLocation(shader.getProgram(), "MPMatrix"), 1, GL_FALSE, projectionview_mat_);

glBegin(GL_QUADS);
    glTexCoord2f(0, 0);glVertex2f(0, 0);
    glTexCoord2f(1, 0);glVertex2f(100, 0);
    glTexCoord2f(1, 1);glVertex2f(100, 100);
    glTexCoord2f(0, 1);glVertex2f(0, 100);
glEnd();

shader.end();

Shader Code:

VERTEX-

#version 150
in vec3 in_vertex;
in vec2 in_coord;
uniform mat4 MVMatrix;
uniform mat4 MPMatrix;

out vec2 tex_coord;

void main()
{
    vec4 v = vec4( in_vertex, 1.0 );

    tex_coord = in_coord;
    gl_Position = MPMatrix * MVMatrix * v;
}

FRAGMENT:

#version 150

in vec2 tex_coord;

out vec4 frgcolor;

void main()
{
    frgcolor = vec4( tex_coord, 0.0, 1.0);
}

final screen is a red quad.

How to pass texture coordinate to shader? or my code is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:10:44+00:00Added an answer on June 4, 2026 at 3:10 am

    If you don’t want to use the deprecated methods, you’ll have to stop using glTexCoord2f, and use a custom attribute.

    If you want to stay with immediate mode, you’ll use glVertexAttrib2f.

    You pair this up with your new variable ‘in_coord’ by quering the index after shader linking:

    int program = glCreateProgram();
    //create shader as normal
    int texcoord_index = glGetAttribLocation(program, "in_coord");
    
    glBegin(GL_QUADS);
    glVertexAttrib2f(texcoord_index, 0, 0); ...
    

    If you want to use VA/VBO instead, the functions you use instead is glEnableVertexAttribArray/glVertexAttribPointer

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an GLSL geometry shader that looks like the following: #version 150 uniform
I have this shader code (GLSL): #version 420 in vec4 vertex; uniform mat4 modelViewMatrix;
i am using this code to check if my glsl shader compiled fine. glGetObjectParameterivARB(obj,
I know that iPhone uses OpenGL ES 2.0, but I don't know the version
My code approaches GLSL shader management in the way, that it creates each shader
Do someone know how to get glsl shaders work in gtk-opengl window? With glut
I declare my GLSL ES shader program within a HTML file, using this code:
I am trying to use GLSL with openGL 2.0. Can anyone give me a
I'm trying to get a handle on OpenGL VAOs/VBOs, and conceptually I'm there, but
I want to accomplish a GLSL Shader, that can texture and color my vertex

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.