can you find out why the output image is blurred in the following code #include…
- User
can you find out why the output image is blurred in the following code #include <GL/glew.h> #include <GL/glut.h> #include #include #include #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/type_ptr.hpp> #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h"
GLuint VBO, VAO, EBO, textureID; GLuint shaderProgram; GLfloat angle = 0.0f;
std::string vertexShaderSource = "#version 300 es\n" "layout (location = 0) in vec3 aPos;\n" "layout (location = 1) in vec2 aTexCoord;\n" "out vec2 TexCoord;\n" "uniform mat4 model;\n" "uniform mat4 view;\n" "uniform mat4 projection;\n" "void main()\n" "{\n" " gl_Position = projection * view * model * vec4(aPos, 1.0);\n" " TexCoord = aTexCoord;\n" "}\0";
std::string fragmentShaderSource = "#version 300 es\n" "precision mediump float;\n" "out vec4 FragColor;\n" "in vec2 TexCoord;\n" "uniform sampler2D texture1;\n" "void main()\n" "{\n" " FragColor = texture(texture1, TexCoord);\n" "}\0";
void loadTexture(const char* filename) { int width, height, channels; stbi_set_flip_vertically_on_load(true); unsigned char* image = stbi_load(filename, &width, &height, &channels, 0);
codeglGenTextures(1, &textureID); glBindTexture(GL_TEXTURE_2D, textureID); 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); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image); glGenerateMipmap(GL_TEXTURE_2D); stbi_image_free(image);}
void setShaders() { GLint success; char infoLog[512]; // Vertex Shader GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); const char* vShaderCode = vertexShaderSource.c_str(); glShaderSource(vertexShader, 1, &vShaderCode, NULL); glCompileShader(vertexShader);
code - Assistant