Преглед изворни кода

removed depth bit requirement to window creation, and smushed a bunch of memory leaks

naelstrof пре 7 година
родитељ
комит
66237354da
4 измењених фајлова са 15 додато и 5 уклоњено
  1. 1
    1
      CMakeLists.txt
  2. 0
    1
      src/framebuffer.cpp
  3. 4
    0
      src/slop.cpp
  4. 10
    3
      src/window.cpp

+ 1
- 1
CMakeLists.txt Прегледај датотеку

@@ -21,7 +21,7 @@ endif()
21 21
 
22 22
 include_directories("${PROJECT_BINARY_DIR}")
23 23
 
24
-add_definitions(-DSLOP_VERSION="v6.3.43")
24
+add_definitions(-DSLOP_VERSION="v6.3.44")
25 25
 
26 26
 # The names have to be unique unfortunately.
27 27
 set(EXECUTABLE_NAME "slop")

+ 0
- 1
src/framebuffer.cpp Прегледај датотеку

@@ -61,7 +61,6 @@ slop::Framebuffer::~Framebuffer() {
61 61
     glDeleteTextures(1, &image);
62 62
     glDeleteFramebuffers(1,&fbuffer);
63 63
     glDeleteBuffers(2,buffers);
64
-    delete shader;
65 64
 }
66 65
 
67 66
 void slop::Framebuffer::resize( int w, int h ) {

+ 4
- 0
src/slop.cpp Прегледај датотеку

@@ -294,6 +294,10 @@ slop::SlopSelection slop::GLSlopSelect( slop::SlopOptions* options, bool* cancel
294 294
     glClear (GL_COLOR_BUFFER_BIT);
295 295
     window->display();
296 296
     // Then we clean up.
297
+    for( int i=0;i<shaders.size();i++ ) {
298
+      delete shaders[i];
299
+    }
300
+    delete pingpong;
297 301
     delete window;
298 302
     delete slop::mouse;
299 303
     Window selectedWindow = memory->selectedWindow;

+ 10
- 3
src/window.cpp Прегледај датотеку

@@ -11,7 +11,6 @@ slop::SlopWindow::SlopWindow() {
11 11
                                    GLX_GREEN_SIZE, 1,
12 12
                                    GLX_BLUE_SIZE, 1,
13 13
                                    GLX_ALPHA_SIZE, 1,
14
-                                   GLX_DEPTH_SIZE, 1,
15 14
                                    None };
16 15
     int nelements;
17 16
     int render_event_base, render_error_base;
@@ -31,15 +30,21 @@ slop::SlopWindow::SlopWindow() {
31 30
         vi = glXGetVisualFromFBConfig(x11->display, fbc[i]);
32 31
         if (!vi) { continue; }
33 32
         pictFormat = XRenderFindVisualFormat(x11->display, vi->visual);
34
-        if (!pictFormat) { continue; }
33
+        if (!pictFormat) {
34
+          XFree( vi );
35
+          continue;
36
+        }
35 37
         if(pictFormat->direct.alphaMask > 0) {
36 38
             fbconfig = fbc[i];
37 39
             break;
40
+        } else { 
41
+          XFree( vi );
38 42
         }
39 43
     }
40 44
     if (i == nelements ) {
41 45
         throw new std::runtime_error( "No matching visuals available" );
42 46
     }
47
+    XFree( fbc );
43 48
 
44 49
     XSetWindowAttributes attributes;
45 50
     attributes.colormap = XCreateColormap(x11->display, RootWindow(x11->display, vi->screen), vi->visual, AllocNone);
@@ -56,6 +61,7 @@ slop::SlopWindow::SlopWindow() {
56 61
     window = XCreateWindow( x11->display, x11->root, 0, 0, WidthOfScreen( x11->screen ), HeightOfScreen( x11->screen ),
57 62
                             0, vi->depth, InputOutput,
58 63
                             vi->visual, valueMask, &attributes );
64
+    XFree( vi );
59 65
 
60 66
     if ( !window ) {
61 67
         throw new std::runtime_error( "Couldn't create a GL window!" );
@@ -120,6 +126,7 @@ slop::SlopWindow::~SlopWindow() {
120 126
     glXDestroyContext( x11->display, context );
121 127
     XUnmapWindow( x11->display, window );
122 128
     XDestroyWindow( x11->display, window );
129
+    glXMakeCurrent( x11->display, None, NULL );
123 130
 }
124 131
 
125 132
 void slop::SlopWindow::display() {
@@ -128,5 +135,5 @@ void slop::SlopWindow::display() {
128 135
 }
129 136
 
130 137
 void slop::SlopWindow::setCurrent() {
131
-    glXMakeCurrent( x11->display, window, context ) ;
138
+    glXMakeCurrent( x11->display, window, context );
132 139
 }