let there be textures
This commit is contained in:
parent
56daae2c9e
commit
66c96af62a
@ -65,6 +65,8 @@ GLuint LinkShader(GLuint vertexShader, GLuint fragmentShader){
|
||||
glGetProgramInfoLog(shaderProgram, 512, NULL, buffer);
|
||||
printf("%s", buffer);
|
||||
|
||||
glUseProgram(shaderProgram);
|
||||
|
||||
return shaderProgram;
|
||||
}
|
||||
|
||||
@ -120,28 +122,36 @@ int main(void)
|
||||
GLuint tex[2];
|
||||
glGenTextures(2, tex);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, tex[0]);
|
||||
|
||||
//Load image
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, tex[0]);
|
||||
image = stbi_load("./sample.png", &width, &height, NULL, 3);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||
stbi_image_free(image);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
glUniform1i(glGetUniformLocation(shaderProgram, "kitty"), 0);
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, tex[1]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
|
||||
|
||||
//Load image
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, tex[1]);
|
||||
image2 = stbi_load("./sample2.png", &width, &height, NULL, 3);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image2);
|
||||
stbi_image_free(image2);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
glUniform1i(glGetUniformLocation(shaderProgram, "puppy"), 1);
|
||||
|
||||
/* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); */
|
||||
/* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); */
|
||||
/* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); */
|
||||
/* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); */
|
||||
|
||||
GLint posAttrib = glGetAttribLocation(shaderProgram, "positions");
|
||||
glEnableVertexAttribArray(posAttrib);
|
||||
glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 7, 0);
|
||||
@ -154,7 +164,6 @@ int main(void)
|
||||
glEnableVertexAttribArray(texCoordsAttrib);
|
||||
glVertexAttribPointer(texCoordsAttrib, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 7, (void*)(5*sizeof(float)));
|
||||
|
||||
glUseProgram(shaderProgram);
|
||||
|
||||
int i = 0;
|
||||
bool should_close = false;
|
||||
|
Loading…
Reference in New Issue
Block a user