From d2e93235b9ccd37bf8c8fb7c4376ab1911c83639 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 11 May 2008 15:16:25 +0000 Subject: console font --- src/render/textures.cc | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'src/render/textures.cc') diff --git a/src/render/textures.cc b/src/render/textures.cc index eef5f1d..8dac3a3 100644 --- a/src/render/textures.cc +++ b/src/render/textures.cc @@ -28,8 +28,14 @@ void Textures::init() load("textures/common/notex"); // console characters - if (load("bitmaps/conchars") == 0) { - con_error << "Essential file bitmaps/conchars missing" << std::endl; + if (!load("bitmaps/fonts/console", false)) { + con_error << "Essential file bitmaps/fonts/console missing" << std::endl; + core::application()->shutdown(); + } + + // console characters + if (!load("bitmaps/fonts/gui", false)) { + con_error << "Essential file bitmaps/fonts/gui missing" << std::endl; core::application()->shutdown(); } @@ -59,7 +65,7 @@ void Textures::clear() index = 0; } -size_t Textures::load(std::string name) +size_t Textures::load(std::string name, bool filter) { // check if it is already loaded iterator it = registry.find(name); @@ -97,8 +103,7 @@ size_t Textures::load(std::string name) gluBuild2DMipmaps(GL_TEXTURE_2D, image->channels(), image->width(), image->height(), texture_type, GL_UNSIGNED_BYTE, image->data()); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR); + set_filter(filter); // add to the registry registry[name] = id; @@ -119,7 +124,7 @@ size_t Textures::find(std::string name) return id; } -size_t Textures::bind(std::string name) +size_t Textures::bind(std::string name, bool filter) { size_t id = 0; iterator it = registry.find(name); @@ -129,17 +134,29 @@ size_t Textures::bind(std::string name) id = load(name); glBindTexture(GL_TEXTURE_2D, textures[id]); + set_filter(filter); return id; } -size_t Textures::bind(size_t texture) +size_t Textures::bind(size_t texture, bool filter) { size_t id = texture; if (texture >= index) id = 0; glBindTexture(GL_TEXTURE_2D, textures[id]); + set_filter(filter); return id; } +void Textures::set_filter(bool filter) +{ + if (filter) { + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR); + } else { + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + } + } } -- cgit v1.2.3