Created
April 15, 2020 13:38
-
-
Save LowSpecCorgi/026ae349a68b3bd070349cf296e83845 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Errors: | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_load_from_memory already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_load_from_callbacks already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_load already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_load_from_file already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_load_gif_from_memory already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_load_16_from_memory already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_load_16_from_callbacks already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_load_16 already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_load_from_file_16 already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_loadf_from_memory already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_loadf_from_callbacks already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_loadf already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_loadf_from_file already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_hdr_to_ldr_gamma already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_hdr_to_ldr_scale already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_ldr_to_hdr_gamma already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_ldr_to_hdr_scale already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_is_hdr_from_callbacks already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_is_hdr_from_memory already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_is_hdr already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_is_hdr_from_file already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_failure_reason already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_image_free already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_info_from_memory already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_info_from_callbacks already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_is_16_bit_from_memory already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_is_16_bit_from_callbacks already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_info already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_info_from_file already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_is_16_bit already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_is_16_bit_from_file already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_set_unpremultiply_on_load already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_convert_iphone_png_to_rgb already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_set_flip_vertically_on_load already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_set_flip_vertically_on_load_thread already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_zlib_decode_malloc_guesssize already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_zlib_decode_malloc_guesssize_headerflag already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_zlib_decode_malloc already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_zlib_decode_buffer already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_zlib_decode_noheader_malloc already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\texture.cpp.obj : error LNK2005: stbi_zlib_decode_noheader_buffer already defined in GameEngine.cpp.obj | |
Documents\GameEngine\out\build\x64-Debug\LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "texture.h" | |
Texture::Texture(std::string fileLocation) | |
:textureLocation(fileLocation) | |
{ | |
glGenTextures(1, &textureID); | |
glBindTexture(GL_TEXTURE_2D, textureID); | |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); | |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); | |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
// Load textures | |
stbi_set_flip_vertically_on_load(true); | |
unsigned char* data = stbi_load(fileLocation.c_str(), &width, &height, &nrChannels, 0); | |
if (data) | |
{ | |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); | |
glGenerateMipmap(GL_TEXTURE_2D); | |
} | |
else | |
{ | |
std::cerr << "Failed to load texture\n"; | |
} | |
stbi_image_free(data); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <glad/glad.h> | |
#include <iostream> | |
#include <vector> | |
#include <string> | |
#define STB_IMAGE_IMPLEMENTATION | |
#include "stb_image.h" | |
class Texture | |
{ | |
public: | |
unsigned int textureID; | |
int width, height, nrChannels; | |
std::string textureLocation; | |
/* | |
Creates a texture | |
- std::string fileLocation => The location of the texture | |
*/ | |
Texture(std::string fileLocation); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment