• Advertisement

Devashish Khandelwal

Member
  • Content count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Devashish Khandelwal

  • Rank
    Newbie

Personal Information

  • Interests
    Art
    Design
    DevOps
    Programming

Social

  • Github
    https://github.com/Devashish0312
  1. OpenGL Uniforms

    Yeah, it is the shader's id. #include<string> class Shader { private: unsigned int m_RendererID; public: Shader(); ~Shader(); void Bind() const; void Unbind() const; //set uniforms void SetUniforms4f(const std::string& name, float v1, float v2, float v3, float v4); private: std::string ParseShader(std::string filename); unsigned int CreateShader(const std::string& vertexShader, const std::string& fragmentShader); unsigned int CompileShader(unsigned int type, const std::string& source); unsigned int GetUniformLocation(const std::string& name); };
  2. OpenGL Uniforms

    FRAGMENT SHADER: #version 330 core layout(location = 0) out vec4 color; uniform vec4 u_color; void main() { color = u_color; } AND THIS IS THE FUNCTION WHICH USES IT: unsigned int Shader::GetUniformLocation(const std::string& name) { int location = glGetUniformLocation(m_RendererID, name.c_str()); if (location == -1) { cout << "Warning :uniform" << name << " does not exist"; } return location; } I've handled the situation when location becomes -1 and therefore in the output, it's just showing Warning:uniform u_color does not exist.
  3. OpenGL Uniforms

    So, how do i make the Uniform Active? bdw thanks for the reply
  4. OpenGL Uniforms

    While writing a simple renderer using OpenGL, I faced an issue with the glGetUniformLocation function. For some reason, the location is coming to be -1. Anyone has any idea .. what should I do?
  • Advertisement