Browse Source

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

naelstrof 7 years ago
parent
commit
66237354da
4 changed files with 15 additions and 5 deletions
  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 View File

21
 
21
 
22
 include_directories("${PROJECT_BINARY_DIR}")
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
 # The names have to be unique unfortunately.
26
 # The names have to be unique unfortunately.
27
 set(EXECUTABLE_NAME "slop")
27
 set(EXECUTABLE_NAME "slop")

+ 0
- 1
src/framebuffer.cpp View File

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

+ 4
- 0
src/slop.cpp View File

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

+ 10
- 3
src/window.cpp View File

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