Browse Source

Use mix now in shader examples, also replaced a bunch of tabs with spaces to make it consistent

naelstrof 7 years ago
parent
commit
fa10482ead

+ 1
- 1
CMakeLists.txt View File

69
                     ${OPENGL_INCLUDE_DIR})
69
                     ${OPENGL_INCLUDE_DIR})
70
 
70
 
71
 target_link_libraries(${LIBRARY_NAME} ${X11_LIBRARIES}
71
 target_link_libraries(${LIBRARY_NAME} ${X11_LIBRARIES}
72
-				      ${CMAKE_THREAD_LIBS_INIT} 
72
+                                      ${CMAKE_THREAD_LIBS_INIT} 
73
                                       ${GLM_LIBRARIES}
73
                                       ${GLM_LIBRARIES}
74
                                       ${OPENGL_LIBRARIES}
74
                                       ${OPENGL_LIBRARIES}
75
                                       ${GLX_LIBRARY}
75
                                       ${GLX_LIBRARY}

+ 2
- 1
shaderexamples/boxzoom.frag View File

43
         // The desktop texture is upside-down due to X11
43
         // The desktop texture is upside-down due to X11
44
         vec2 zoomedUVFlipped = vec2( zoomedUV.x, -zoomedUV.y );
44
         vec2 zoomedUVFlipped = vec2( zoomedUV.x, -zoomedUV.y );
45
         // Then change the color to the desktop color to draw, then add on our rectangle on top.
45
         // Then change the color to the desktop color to draw, then add on our rectangle on top.
46
-        color = texture2D( desktop, zoomedUVFlipped ) + texture2D( texture, zoomedUV );
46
+        vec4 rectColor = texture2D( texture, zoomedUV );
47
+        color = mix( texture2D( desktop, zoomedUVFlipped ), rectColor, rectColor.a );
47
       }
48
       }
48
     // Then check if we're in our border size.
49
     // Then check if we're in our border size.
49
     } else if( uvCoord.x <= mpos.x+boxOffset.x+boxSize.x+borderSize.x &&
50
     } else if( uvCoord.x <= mpos.x+boxOffset.x+boxSize.x+borderSize.x &&

+ 1
- 1
shaderexamples/crosshair.frag View File

34
             vec2 upsideDown = c/magnifyNerf*t*t+b;
34
             vec2 upsideDown = c/magnifyNerf*t*t+b;
35
 
35
 
36
             vec4 textureColor = texture2D( texture, upsideDown );
36
             vec4 textureColor = texture2D( texture, upsideDown );
37
-            color = texture2D( desktop, vec2(upsideDown.x, -upsideDown.y) )*(1-textureColor.a) + textureColor;
37
+            color = mix( texture2D( desktop, vec2(upsideDown.x, -upsideDown.y) ), textureColor, textureColor.a );
38
         }
38
         }
39
     } else if ( dr < circleSize+borderSize ) {
39
     } else if ( dr < circleSize+borderSize ) {
40
         color = borderColor;
40
         color = borderColor;

+ 1
- 1
src/framebuffer.cpp View File

105
     glActiveTexture(GL_TEXTURE0);
105
     glActiveTexture(GL_TEXTURE0);
106
     glBindTexture( GL_TEXTURE_2D, image );
106
     glBindTexture( GL_TEXTURE_2D, image );
107
     if ( shader->hasParameter( "desktop" ) ) {
107
     if ( shader->hasParameter( "desktop" ) ) {
108
-		shader->setParameter( "desktop", 1 );
108
+        shader->setParameter( "desktop", 1 );
109
         glActiveTexture(GL_TEXTURE0 + 1);
109
         glActiveTexture(GL_TEXTURE0 + 1);
110
         glBindTexture( GL_TEXTURE_2D, desktopImage );
110
         glBindTexture( GL_TEXTURE_2D, desktopImage );
111
     }
111
     }

+ 5
- 5
src/mouse.cpp View File

66
 }
66
 }
67
 
67
 
68
 slop::Mouse::~Mouse() {
68
 slop::Mouse::~Mouse() {
69
-	XUngrabPointer( x11->display, CurrentTime );
69
+    XUngrabPointer( x11->display, CurrentTime );
70
 }
70
 }
71
 
71
 
72
 void slop::Mouse::update() {
72
 void slop::Mouse::update() {
73
     XEvent event;
73
     XEvent event;
74
     while ( XCheckTypedEvent( x11->display, ButtonPress, &event ) ) {
74
     while ( XCheckTypedEvent( x11->display, ButtonPress, &event ) ) {
75
 		setButton( event.xbutton.button, 1 );
75
 		setButton( event.xbutton.button, 1 );
76
-	}
76
+    }
77
     bool findNewWindow = false;
77
     bool findNewWindow = false;
78
     while ( XCheckTypedEvent( x11->display, MotionNotify, &event ) ) {
78
     while ( XCheckTypedEvent( x11->display, MotionNotify, &event ) ) {
79
         findNewWindow = true;
79
         findNewWindow = true;
80
-	}
80
+    }
81
     if ( findNewWindow ) {
81
     if ( findNewWindow ) {
82
         hoverWindow = findWindow(x11->root);
82
         hoverWindow = findWindow(x11->root);
83
     }
83
     }
84
     while ( XCheckTypedEvent( x11->display, ButtonRelease, &event ) ) {
84
     while ( XCheckTypedEvent( x11->display, ButtonRelease, &event ) ) {
85
 		setButton( event.xbutton.button, 0 );
85
 		setButton( event.xbutton.button, 0 );
86
-	}
86
+    }
87
     while ( XCheckTypedEvent( x11->display, EnterNotify, &event ) ) {
87
     while ( XCheckTypedEvent( x11->display, EnterNotify, &event ) ) {
88
         hoverWindow = event.xcrossing.window;
88
         hoverWindow = event.xcrossing.window;
89
-	}
89
+    }
90
 }
90
 }
91
 
91
 
92
 Window slop::Mouse::findWindow( Window foo ) {
92
 Window slop::Mouse::findWindow( Window foo ) {

+ 2
- 2
src/mouse.hpp View File

40
     int nodecorations;
40
     int nodecorations;
41
     Window ignoreWindow;
41
     Window ignoreWindow;
42
 public:
42
 public:
43
-	Window hoverWindow;
44
-	void update();
43
+    Window hoverWindow;
44
+    void update();
45
     Mouse( X11* x11, int nodecorations, Window ignoreWindow );
45
     Mouse( X11* x11, int nodecorations, Window ignoreWindow );
46
     ~Mouse();
46
     ~Mouse();
47
     void setCursor( int cursor );
47
     void setCursor( int cursor );

+ 14
- 14
src/slopstates.cpp View File

115
     }
115
     }
116
     if ( keyboard ) {
116
     if ( keyboard ) {
117
         int arrows[2];
117
         int arrows[2];
118
-        arrows[0] = keyboard->getKey(XK_Down)-keyboard->getKey(XK_Up);		
119
-        arrows[1] = keyboard->getKey(XK_Right)-keyboard->getKey(XK_Left);		
120
-        if ( arrows[0] || arrows[1] ) {		
121
-            if ( repeatTimer == 0 || repeatTimer > .4 ) {		
122
-                startPoint.y += arrows[0]*multiplier;		
123
-                startPoint.x += arrows[1]*multiplier;		
124
-            }		
125
-            if ( repeatTimer > 1 ) {		
126
-                multiplier += dt*2;		
127
-            }		
128
-            repeatTimer += dt;		
129
-        } else {		
130
-            repeatTimer = 0;		
131
-            multiplier = 1;		
118
+        arrows[0] = keyboard->getKey(XK_Down)-keyboard->getKey(XK_Up);
119
+        arrows[1] = keyboard->getKey(XK_Right)-keyboard->getKey(XK_Left);
120
+        if ( arrows[0] || arrows[1] ) {
121
+            if ( repeatTimer == 0 || repeatTimer > .4 ) {
122
+                startPoint.y += arrows[0]*multiplier;
123
+                startPoint.x += arrows[1]*multiplier;
124
+            }
125
+            if ( repeatTimer > 1 ) {
126
+                multiplier += dt*2;
127
+            }
128
+            repeatTimer += dt;
129
+        } else {
130
+            repeatTimer = 0;
131
+            multiplier = 1;
132
         }
132
         }
133
     }
133
     }
134
 }
134
 }

+ 1
- 1
src/xshaperectangle.cpp View File

55
     if ( createdWindow ) {
55
     if ( createdWindow ) {
56
         return;
56
         return;
57
     }
57
     }
58
-	XMapWindow( x11->display, window );
58
+    XMapWindow( x11->display, window );
59
     createdWindow = true;
59
     createdWindow = true;
60
 }
60
 }
61
 
61