Ver código fonte

Fixed imgui rendering

Thomas Buck 10 anos atrás
pai
commit
d64eac9034
4 arquivos alterados com 21 adições e 18 exclusões
  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 Ver arquivo

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

+ 2
- 1
include/TextureManager.h Ver arquivo

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

+ 4
- 7
src/Debug.cpp Ver arquivo

61
     io.RenderDrawListsFn = Debug::renderImGui;
61
     io.RenderDrawListsFn = Debug::renderImGui;
62
 
62
 
63
     // Load font texture
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
     const void* png_data;
64
     const void* png_data;
69
     unsigned int png_size;
65
     unsigned int png_size;
70
     ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size);
66
     ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size);
71
     int tex_x, tex_y, tex_comp;
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
     stbi_image_free(tex_data);
72
     stbi_image_free(tex_data);
76
 
73
 
77
     return 0;
74
     return 0;

+ 12
- 10
src/TextureManager.cpp Ver arquivo

111
 int TextureManager::loadBufferSlot(unsigned char *image,
111
 int TextureManager::loadBufferSlot(unsigned char *image,
112
         unsigned int width, unsigned int height,
112
         unsigned int width, unsigned int height,
113
         ColorMode mode, unsigned int bpp,
113
         ColorMode mode, unsigned int bpp,
114
-        unsigned int slot) {
114
+        unsigned int slot, bool filter) {
115
     assert(image != NULL);
115
     assert(image != NULL);
116
     assert(width > 0);
116
     assert(width > 0);
117
     assert(height > 0);
117
     assert(height > 0);
163
 
163
 
164
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
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
     glTexImage2D(GL_TEXTURE_2D, 0, bpp / 8, width, height, 0, glcMode, GL_UNSIGNED_BYTE, image);
179
     glTexImage2D(GL_TEXTURE_2D, 0, bpp / 8, width, height, 0, glcMode, GL_UNSIGNED_BYTE, image);
178
 
180
 
179
     //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
181
     //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

Carregando…
Cancelar
Salvar