Kaynağa Gözat

Bugfixes in WindowSDL, Console. Added ShaderBuffer.

Thomas Buck 10 yıl önce
ebeveyn
işleme
55c1192438
7 değiştirilmiş dosya ile 18 ekleme ve 17 silme
  1. 5
    0
      ChangeLog.md
  2. 1
    2
      include/system/Shader.h
  3. 3
    3
      src/Console.cpp
  4. 2
    2
      src/RunTime.cpp
  5. 1
    1
      src/UI.cpp
  6. 5
    8
      src/system/Shader.cpp
  7. 1
    1
      src/system/WindowSDL.cpp

+ 5
- 0
ChangeLog.md Dosyayı Görüntüle

@@ -2,6 +2,11 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20150103 ]
6
+    * Fixed bug in WindowSDL where resizing only worked after calling it two times.
7
+    * Fixed bug in Console that caused its window to get bigger after each launch.
8
+    * Added ShaderBuffer class.
9
+
5 10
     [ 20141231 ]
6 11
     * No longer using Exceptions.
7 12
     * Moved OpenGL related code from Window into Shader, imguiShader in UI.

+ 1
- 2
include/system/Shader.h Dosyayı Görüntüle

@@ -17,7 +17,7 @@
17 17
 
18 18
 class ShaderBuffer {
19 19
   public:
20
-    ShaderBuffer() : buffer(0), created(false) { }
20
+    ShaderBuffer();
21 21
     ~ShaderBuffer();
22 22
 
23 23
     void bufferData(int elem, int size, void* data);
@@ -32,7 +32,6 @@ class ShaderBuffer {
32 32
 
33 33
   private:
34 34
     unsigned int buffer;
35
-    bool created;
36 35
 };
37 36
 
38 37
 class Shader {

+ 3
- 3
src/Console.cpp Dosyayı Görüntüle

@@ -71,15 +71,15 @@ void Console::callback(ImGuiTextEditCallbackData* data) {
71 71
 }
72 72
 
73 73
 void Console::display() {
74
-    if (ImGui::Begin("Console", nullptr, ImVec2(600, 400), -1.0f)) {
74
+    if (ImGui::Begin("Console", nullptr, ImVec2(600, 400))) {
75 75
         if (lastLogLength != getLog().size()) {
76 76
             lastLogLength = getLog().size();
77 77
             scrollToBottom = true;
78 78
         }
79 79
 
80
-        ImGui::BeginChild("ConsoleText", ImVec2(ImGui::GetWindowWidth(), ImGui::GetWindowSize().y - 70));
80
+        ImGui::BeginChild("ConsoleText", ImVec2(0, -ImGui::GetTextLineSpacing() * 2));
81 81
         for (unsigned long i = 0; i < getLog().size(); i++) {
82
-            ImGui::Text("%s", getLog().get(i).c_str());
82
+            ImGui::TextUnformatted(getLog().get(i).c_str());
83 83
         }
84 84
         if (scrollToBottom) {
85 85
             ImGui::SetScrollPosHere();

+ 2
- 2
src/RunTime.cpp Dosyayı Görüntüle

@@ -114,13 +114,13 @@ void RunTime::display() {
114 114
         if (ImGui::InputInt("Width##runtime", &w, 10, 100, ImGuiInputTextFlags_EnterReturnsTrue)) {
115 115
             if (w < 1)
116 116
                 w = 1;
117
-            Window::setSize(glm::vec2(w, Window::getSize().y));
117
+            Window::setSize(glm::i32vec2(w, Window::getSize().y));
118 118
         }
119 119
         int h = Window::getSize().y;
120 120
         if (ImGui::InputInt("Height##runtime", &h, 10, 100, ImGuiInputTextFlags_EnterReturnsTrue)) {
121 121
             if (h < 1)
122 122
                 h = 1;
123
-            Window::setSize(glm::vec2(Window::getSize().x, h));
123
+            Window::setSize(glm::i32vec2(Window::getSize().x, h));
124 124
         }
125 125
 
126 126
         static int fr = 0;

+ 1
- 1
src/UI.cpp Dosyayı Görüntüle

@@ -206,7 +206,7 @@ void UI::display() {
206 206
     Console::display();
207 207
 
208 208
     static bool showTestWindow = false;
209
-    if (ImGui::Begin("Engine")) {
209
+    if (ImGui::Begin("Engine", nullptr, ImVec2(400, 400))) {
210 210
         Render::displayUI();
211 211
         RunTime::display();
212 212
         SoundManager::display();

+ 5
- 8
src/system/Shader.cpp Dosyayı Görüntüle

@@ -11,18 +11,15 @@
11 11
 #include "system/Window.h"
12 12
 #include "system/Shader.h"
13 13
 
14
+ShaderBuffer::ShaderBuffer() : buffer(0) {
15
+    glGenBuffers(1, &buffer);
16
+}
17
+
14 18
 ShaderBuffer::~ShaderBuffer() {
15
-    if (created) {
16
-        glDeleteBuffers(1, &buffer);
17
-    }
19
+    glDeleteBuffers(1, &buffer);
18 20
 }
19 21
 
20 22
 void ShaderBuffer::bufferData(int elem, int size, void* data) {
21
-    if (!created) {
22
-        glGenBuffers(1, &buffer);
23
-        created = true;
24
-    }
25
-
26 23
     glBindBuffer(GL_ARRAY_BUFFER, buffer);
27 24
     glBufferData(GL_ARRAY_BUFFER, elem * size, data, GL_STATIC_DRAW);
28 25
 }

+ 1
- 1
src/system/WindowSDL.cpp Dosyayı Görüntüle

@@ -500,7 +500,7 @@ void WindowSDL::setSize(glm::i32vec2 s) {
500 500
     assert((s.x > 0) && (s.y > 0));
501 501
     if (window) {
502 502
         if ((s.x != size.x) || (s.y != size.y)) {
503
-            SDL_SetWindowSize(window, size.x, size.y);
503
+            SDL_SetWindowSize(window, s.x, s.y);
504 504
         }
505 505
     }
506 506
     size = s;

Loading…
İptal
Kaydet