GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Gamingcode/Chapter06/Texture.cpp at master · Bhavan-R/Gamingcode Expand file tree/ Copy pathTexture.cppMore file actions 69 lines (53 loc) · 1.4 KB / Copy pathTexture.cppFile metadata and controls69 lines (53 loc) · 1.4 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 // ---------------------------------------------------------------- // From Game Programming in C++ by Sanjay Madhav // Copyright (C) 2017 Sanjay Madhav. All rights reserved. // // Released under the BSD License // See LICENSE in root directory for full details. // ---------------------------------------------------------------- #include "Texture.h" #include <SOIL/SOIL.h> #include <GL/glew.h> #include <SDL/SDL.h> Texture::Texture() :mTextureID(0) ,mWidth(0) ,mHeight(0) { } Texture::~Texture() { } bool Texture::Load(const std::string& fileName) { int channels = 0; unsigned char* image = SOIL_load_image(fileName.c_str(), &mWidth, &mHeight, &channels, SOIL_LOAD_AUTO); if (image == nullptr) { SDL_Log("SOIL failed to load image %s: %s", fileName.c_str(), SOIL_last_result()); return false; } int format = GL_RGB; if (channels == 4) { format = GL_RGBA; } glGenTextures(1, &mTextureID); glBindTexture(GL_TEXTURE_2D, mTextureID); glTexImage2D(GL_TEXTURE_2D, 0, format, mWidth, mHeight, 0, format, GL_UNSIGNED_BYTE, image); SOIL_free_image_data(image); // Enable linear filtering glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); return true; } void Texture::Unload() { glDeleteTextures(1, &mTextureID); } void Texture::SetActive() { glBindTexture(GL_TEXTURE_2D, mTextureID); } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |