diff --git a/Engine/engine/assets/container.jpg b/Engine/engine/assets/container.jpg new file mode 100644 index 0000000..50aa4c9 Binary files /dev/null and b/Engine/engine/assets/container.jpg differ diff --git a/Engine/engine/draw.cpp b/Engine/engine/draw.cpp index 373bf33..1164bb1 100644 --- a/Engine/engine/draw.cpp +++ b/Engine/engine/draw.cpp @@ -185,7 +185,7 @@ drawFigureReturn drawDebilMode(const char* vertexPath, const char* fragmentPath, // set it via the texture class ourShader.setInt("texture1", 1); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); - + drawFigureReturn newReturn; newReturn.success = 0; newReturn.VAO = VAO; @@ -227,7 +227,7 @@ void doDrawArrays(const unsigned int shaderProgram, const unsigned int vertexArr // use shader program to render an object glUseProgram(shaderProgram); updateUniformColor(shaderProgram, "ourColor"); - const unsigned int texture = generateTexture("./assets/Preview.png", 430, 288, 3); + const unsigned int texture = generateTexture("./assets/Preview.png"); glBindTexture(GL_TEXTURE_2D, texture); glBindVertexArray(vertexArrayObject); // From left: diff --git a/Engine/engine/match b/Engine/engine/match index ea8f253..8f59bfa 100755 Binary files a/Engine/engine/match and b/Engine/engine/match differ diff --git a/Engine/engine/textures.cpp b/Engine/engine/textures.cpp index 97674c6..431d588 100644 --- a/Engine/engine/textures.cpp +++ b/Engine/engine/textures.cpp @@ -91,9 +91,9 @@ unsigned int generateAndBindTexture(const GLenum textureTarget, const GLsizei nu return texture; } -unsigned int loadAndBindTextureFile(unsigned int texture, const char* texturePath, const int textureWidth, const int textureHeight, const int colorChannels) { - - unsigned char *data = loadTexture(texturePath, textureWidth, textureHeight, colorChannels); +unsigned int loadAndBindTextureFile(unsigned int texture, const char* texturePath) { + int textureWidth, textureHeight, colorChannels; + unsigned char *data = stbi_load("assets/container.jpg", &textureWidth, &textureHeight, &colorChannels, 0); if(data) { // generate texture /* @@ -118,9 +118,9 @@ unsigned int loadAndBindTextureFile(unsigned int texture, const char* texturePat } } -unsigned int generateTexture(const char* texturePath, const int textureWidth, const int textureHeight, const int colorChannels) { +unsigned int generateTexture(const char* texturePath) { unsigned int texture = generateAndBindTexture(GL_TEXTURE_2D, 1); - texture = loadAndBindTextureFile(texture, texturePath, textureWidth, textureHeight, colorChannels); + texture = loadAndBindTextureFile(texture, texturePath); } // const char* texturePath, int textureWidth, int textureHeight, int colorChannels, const GLenum textureTarget, const GLint sCoordinateOption, const GLint tCoordinateOption, const GLint rCoordinateOption, const float* borderColor @@ -134,9 +134,7 @@ unsigned int loadAndCreateTexture() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // load image, create texture and generate mipmaps - int width = 430, height = 288, nrChannels; - - texture = loadAndBindTextureFile(texture, "assets/Preview.png", width, height, nrChannels); + texture = loadAndBindTextureFile(texture, "assets/Preview.png"); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); diff --git a/Engine/engine/textures.hpp b/Engine/engine/textures.hpp index 7fa23f4..70d449f 100644 --- a/Engine/engine/textures.hpp +++ b/Engine/engine/textures.hpp @@ -10,7 +10,7 @@ void setTextureTCoordinate(const GLenum textureTarget = GL_TEXTURE_2D, const GLi void setTextureRCoordinate(const GLenum textureTarget = GL_TEXTURE_3D, const GLint rCoordinateOption = GL_REPEAT, const float* borderColor = NULL); void setTextureFilteringAndMipMap(const GLenum textureTarget = GL_TEXTURE_2D, const GLenum filterType = GL_TEXTURE_MAG_FILTER, const GLint textureFilteringMethod = GL_NEAREST, const GLint mipMapFilteringMethod = GL_NEAREST_MIPMAP_NEAREST); unsigned int generateAndBindTexture(const GLenum textureTarget); -unsigned int generateTexture(const char* texturePath, const int textureWidth, const int textureHeight, const int colorChannels); +unsigned int generateTexture(const char* texturePath); unsigned char* loadTexture(const char* texturePath, int textureWidth, int textureHeight, int colorChannels); // const char* texturePath, int textureWidth, int textureHeight, int colorChannels, const GLenum textureTarget, const GLint sCoordinateOption, const GLint tCoordinateOption, const GLint rCoordinateOption, const float* borderColor