Thomas Buck 9 лет назад
Родитель
Сommit
d64eac9034
4 измененных файлов: 21 добавлений и 18 удалений
  1. 3
    0
      ChangeLog.md
  2. 2
    1
      include/TextureManager.h
  3. 4
    7
      src/Debug.cpp
  4. 12
    10
      src/TextureManager.cpp

+ 3
- 0
ChangeLog.md Просмотреть файл

@@ -2,6 +2,9 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140904 ]
6
+    * Fixed imgui colors
7
+
5 8
     [ 20140903 ]
6 9
     * Finishing imgui integration, but now as UI layer and not on top of everything
7 10
     * All global objects are now explicitly allocated in main and stored in shared_ptrs

+ 2
- 1
include/TextureManager.h Просмотреть файл

@@ -73,12 +73,13 @@ public:
73 73
      * \param mode mode of image
74 74
      * \param bpp bits per pixel of image
75 75
      * \param slot slot (ID) of image
76
+     * \param filter if the texture should be mipmap filtered
76 77
      * \returns texture ID or < 0 on error
77 78
      */
78 79
     int loadBufferSlot(unsigned char *image,
79 80
                         unsigned int width, unsigned int height,
80 81
                         ColorMode mode, unsigned int bpp,
81
-                        unsigned int slot);
82
+                        unsigned int slot, bool filter = true);
82 83
 
83 84
     int loadImage(const char *filename);
84 85
 

+ 4
- 7
src/Debug.cpp Просмотреть файл

@@ -61,17 +61,14 @@ int Debug::initialize() {
61 61
     io.RenderDrawListsFn = Debug::renderImGui;
62 62
 
63 63
     // Load font texture
64
-    //glGenTextures(1, &fontTex);
65
-    //glBindTexture(GL_TEXTURE_2D, fontTex);
66
-    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
67
-    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
68 64
     const void* png_data;
69 65
     unsigned int png_size;
70 66
     ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size);
71 67
     int tex_x, tex_y, tex_comp;
72
-    void* tex_data = stbi_load_from_memory((const unsigned char*)png_data, (int)png_size, &tex_x, &tex_y, &tex_comp, 0);
73
-    //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex_x, tex_y, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_data);
74
-    fontTex = getTextureManager().loadBufferSlot((unsigned char *)tex_data, tex_x, tex_y, RGBA, 32, 0);
68
+    void* tex_data = stbi_load_from_memory((const unsigned char*)png_data,
69
+            (int)png_size, &tex_x, &tex_y, &tex_comp, 0);
70
+    fontTex = getTextureManager().loadBufferSlot((unsigned char *)tex_data,
71
+            tex_x, tex_y, RGBA, 32, 0, false); // TODO use proper slot!
75 72
     stbi_image_free(tex_data);
76 73
 
77 74
     return 0;

+ 12
- 10
src/TextureManager.cpp Просмотреть файл

@@ -111,7 +111,7 @@ void TextureManager::bindMultiTexture(int texture0, int texture1) {
111 111
 int TextureManager::loadBufferSlot(unsigned char *image,
112 112
         unsigned int width, unsigned int height,
113 113
         ColorMode mode, unsigned int bpp,
114
-        unsigned int slot) {
114
+        unsigned int slot, bool filter) {
115 115
     assert(image != NULL);
116 116
     assert(width > 0);
117 117
     assert(height > 0);
@@ -163,17 +163,19 @@ int TextureManager::loadBufferSlot(unsigned char *image,
163 163
 
164 164
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
165 165
 
166
-    glBindTexture(GL_TEXTURE_2D, mTextureIds[slot]);
166
+    glBindTexture(GL_TEXTURE_2D, mTextureIds.at(slot));
167 167
 
168
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
169
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
170
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
171
-
172
-    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
173
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
174
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
168
+    if (filter) {
169
+        glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
170
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
171
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
172
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
173
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
174
+    } else {
175
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
176
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
177
+    }
175 178
 
176
-    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
177 179
     glTexImage2D(GL_TEXTURE_2D, 0, bpp / 8, width, height, 0, glcMode, GL_UNSIGNED_BYTE, image);
178 180
 
179 181
     //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

Загрузка…
Отмена
Сохранить