Browse Source

Bugfixes in WindowSDL, Console. Added ShaderBuffer.

Thomas Buck 10 years ago
parent
commit
55c1192438
7 changed files with 18 additions and 17 deletions
  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 View File

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
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
     [ 20141231 ]
10
     [ 20141231 ]
6
     * No longer using Exceptions.
11
     * No longer using Exceptions.
7
     * Moved OpenGL related code from Window into Shader, imguiShader in UI.
12
     * Moved OpenGL related code from Window into Shader, imguiShader in UI.

+ 1
- 2
include/system/Shader.h View File

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

+ 3
- 3
src/Console.cpp View File

71
 }
71
 }
72
 
72
 
73
 void Console::display() {
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
         if (lastLogLength != getLog().size()) {
75
         if (lastLogLength != getLog().size()) {
76
             lastLogLength = getLog().size();
76
             lastLogLength = getLog().size();
77
             scrollToBottom = true;
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
         for (unsigned long i = 0; i < getLog().size(); i++) {
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
         if (scrollToBottom) {
84
         if (scrollToBottom) {
85
             ImGui::SetScrollPosHere();
85
             ImGui::SetScrollPosHere();

+ 2
- 2
src/RunTime.cpp View File

114
         if (ImGui::InputInt("Width##runtime", &w, 10, 100, ImGuiInputTextFlags_EnterReturnsTrue)) {
114
         if (ImGui::InputInt("Width##runtime", &w, 10, 100, ImGuiInputTextFlags_EnterReturnsTrue)) {
115
             if (w < 1)
115
             if (w < 1)
116
                 w = 1;
116
                 w = 1;
117
-            Window::setSize(glm::vec2(w, Window::getSize().y));
117
+            Window::setSize(glm::i32vec2(w, Window::getSize().y));
118
         }
118
         }
119
         int h = Window::getSize().y;
119
         int h = Window::getSize().y;
120
         if (ImGui::InputInt("Height##runtime", &h, 10, 100, ImGuiInputTextFlags_EnterReturnsTrue)) {
120
         if (ImGui::InputInt("Height##runtime", &h, 10, 100, ImGuiInputTextFlags_EnterReturnsTrue)) {
121
             if (h < 1)
121
             if (h < 1)
122
                 h = 1;
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
         static int fr = 0;
126
         static int fr = 0;

+ 1
- 1
src/UI.cpp View File

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

+ 5
- 8
src/system/Shader.cpp View File

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

+ 1
- 1
src/system/WindowSDL.cpp View File

500
     assert((s.x > 0) && (s.y > 0));
500
     assert((s.x > 0) && (s.y > 0));
501
     if (window) {
501
     if (window) {
502
         if ((s.x != size.x) || (s.y != size.y)) {
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
     size = s;
506
     size = s;

Loading…
Cancel
Save