mirror of
https://github.com/kuhyx/engineer-thesis-WUT.git
synced 2026-07-04 13:03:07 +02:00
feat: draw actual texture and not some bugged abomination
This commit is contained in:
parent
4d77d24c4f
commit
6d82225bae
BIN
Engine/engine/assets/container.jpg
Normal file
BIN
Engine/engine/assets/container.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
@ -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:
|
||||
|
||||
Binary file not shown.
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user