Jump to content
OpenGL API Specifications
Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 12 December 2012 - 08:41 PM
Posted 13 December 2012 - 10:52 PM
// bind texture glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texId); // send texture to shader GLuint id = glGetUniformLocation(programId, "gSampler"); glUniform1i(id, 0); // 0 for GL_TEXTURE0
Edited by rocklobster, 13 December 2012 - 10:54 PM.
Posted 14 December 2012 - 10:28 AM
Posted 17 December 2012 - 12:44 AM
Thanks for the response, but i still can't get this to work. I fixed 'Bind texture' part in my GenerateTexture() function but I don't see the way to use
GLuint id = glGetUniformLocation(programId, "gSampler");
and i put this
glUniform1i(id, 0); // 0 for GL_TEXTURE0
in my render function
the problem is that the tutorials on the link i posted use more than one shader function to load and process shaders. So I can't get programId from outside. When I put this function inside CompileShaders function that is used in tutorials I still can't make this work. Can you help?
// loading the data GLuint myShader = CreateShaders("vertex.vert", "fragment.frag"); GLuint texId = CreateTexture("logo.png"); // when drawing glUseProgram(myShader); glBindTexture(GL_TEXTURE_2D, texId); glActiveTexture(GL_TEXTURE0); GLuint loc = glGetUniformLocation(myShader, "gSampler"); glUniform1i(loc, 0); // then just draw your mesh glDrawArrays(GL_TRIANGLES, 0, mesh.count);
Edited by rocklobster, 17 December 2012 - 12:46 AM.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.