From 55a1e2658500028d0f1b2c193e66afbc9360f98d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 6 May 2013 18:10:21 -0700 Subject: [PATCH] remove the Texture class no longer in use --- interface/src/Texture.cpp | 76 --------------------------------------- interface/src/Texture.h | 16 --------- interface/src/main.cpp | 1 - 3 files changed, 93 deletions(-) delete mode 100644 interface/src/Texture.cpp delete mode 100644 interface/src/Texture.h diff --git a/interface/src/Texture.cpp b/interface/src/Texture.cpp deleted file mode 100644 index 1544413315..0000000000 --- a/interface/src/Texture.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// -// Texture.cpp -// interface -// -// Added by Yoz on 11/5/12. -// -// Code lifted from http://en.wikibooks.org/wiki/OpenGL_Programming/Intermediate/Textures - -#include "Texture.h" - -#include "InterfaceConfig.h" -#include "Log.h" - -#include -#include -#include - -#define TEXTURE_LOAD_ERROR 0 - -/** - * Read a given filename as a PNG texture, and set - it as the current default OpenGL texture. - * @param[in] filename Relative path to PNG file - * @return Zero for success. - */ - -int load_png_as_texture(char* filename) -{ - std::vector image; - // width and height will be read from the file at the start - // and loaded into these vars - unsigned int width = 1, height = 1; - unsigned error = lodepng::decode(image, width, height, filename); - if (error) { - printLog("Error loading texture\n"); - return (int) error; - } - - // Make some OpenGL properties better for 2D and enable alpha channel. - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glEnable(GL_ALPHA_TEST); - - if(glGetError() != GL_NO_ERROR) - { - printLog("Error initing GL\n"); - return 1; - } - - // Texture size must be power of two for the primitive OpenGL version this is written for. Find next power of two. - size_t u2 = 1; while(u2 < width) u2 *= 2; - size_t v2 = 1; while(v2 < height) v2 *= 2; - // Ratio for power of two version compared to actual version, to render the non power of two image with proper size. - // double u3 = (double)width / u2; - // double v3 = (double)height / v2; - - // Make power of two version of the image. - std::vector image2(u2 * v2 * 4); - for(size_t y = 0; y < height; y++) - for(size_t x = 0; x < width; x++) - for(size_t c = 0; c < 4; c++) - { - image2[4 * u2 * y + 4 * x + c] = image[4 * width * y + 4 * x + c]; - } - - // Enable the texture for OpenGL. - glEnable(GL_TEXTURE_2D); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); //GL_NEAREST = no smoothing - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, 4, u2, v2, 0, GL_RGBA, GL_UNSIGNED_BYTE, &image2[0]); - - return 0; -} - diff --git a/interface/src/Texture.h b/interface/src/Texture.h deleted file mode 100644 index 3ed764f577..0000000000 --- a/interface/src/Texture.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// Texture.h -// interface -// -// Created by Yoz Work on 11/5/12. -// -// - -#ifndef __interface__Texture__ -#define __interface__Texture__ - -#include "InterfaceConfig.h" - -int load_png_as_texture(char* filename); - -#endif /* defined(__interface__texture__) */ diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 8916fcd319..d0b9b01df9 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -69,7 +69,6 @@ #include "Camera.h" #include "Avatar.h" -#include "Texture.h" #include #include #include "VoxelSystem.h"