Texture exercises
This commit is contained in:
parent
65c81c4c58
commit
afd31d361b
20
main.c
20
main.c
@ -87,10 +87,10 @@ int main(void) {
|
||||
|
||||
float v1[] = {
|
||||
// Position // Color // UV
|
||||
0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
|
||||
0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 2.0f, 2.0f,
|
||||
0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f,
|
||||
-0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||
-0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f
|
||||
-0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 2.0f
|
||||
};
|
||||
|
||||
unsigned int indices[] = {
|
||||
@ -135,12 +135,10 @@ int main(void) {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
float timeValue = glfwGetTime();
|
||||
float green = (sin(timeValue) / 2.0f) + 0.5f;
|
||||
float mix = (sin(timeValue) / 2.0f) + 0.5f;
|
||||
glUseProgram(shaderProgram);
|
||||
int ourColorLoc = glGetUniformLocation(shaderProgram, "ourColor");
|
||||
glUniform4f(ourColorLoc, 0.0f, green, 0.0f, 1.0f);
|
||||
int offsetLoc = glGetUniformLocation(shaderProgram, "offset");
|
||||
glUniform1f(offsetLoc, 0.5f);
|
||||
int offsetLoc = glGetUniformLocation(shaderProgram, "mixAmount");
|
||||
glUniform1f(offsetLoc, mix);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture1);
|
||||
@ -150,12 +148,6 @@ int main(void) {
|
||||
glBindVertexArray(vaos[0]);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
|
||||
// glBindVertexArray(vaos[1]);
|
||||
// glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
|
||||
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
// glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ out vec4 FragColor;
|
||||
|
||||
uniform sampler2D t1;
|
||||
uniform sampler2D t2;
|
||||
uniform float mixAmount;
|
||||
|
||||
void main() {
|
||||
FragColor = mix(texture(t1, tCoord), texture(t2, tCoord), 0.2);
|
||||
vec2 flipped = vec2(-tCoord.x, tCoord.y);
|
||||
FragColor = mix(texture(t1, tCoord), texture(t2, flipped), mixAmount);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user