-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3aa73fd
commit 8a58627
Showing
12 changed files
with
394 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "shaders/slipmodeshader.h" | ||
|
||
using namespace mixxx; | ||
|
||
void SlipModeShader::init() { | ||
QString vertexShaderCode = QStringLiteral(R"--( | ||
#version 150 | ||
attribute highp vec4 position; // use vec4 here (will be padded) to assign directly to gl_Position | ||
out highp vec4 vposition; | ||
void main() | ||
{ | ||
vposition = position; | ||
gl_Position = position; | ||
} | ||
)--"); | ||
|
||
QString fragmentShaderCode = QStringLiteral(R"--( | ||
#version 120 | ||
uniform highp vec4 color; | ||
uniform highp vec2 dimension; | ||
in highp vec4 vposition; | ||
void main() | ||
{ | ||
float xBorder = abs(dimension.x*vposition.x); | ||
float yBorder = dimension.y*vposition.y; | ||
gl_FragColor = vec4(0, 0, 0, 0); | ||
if( (xBorder > dimension.x - 10 && yBorder >= 0) || yBorder < 0 || yBorder > dimension.y - 10) | ||
{ | ||
float borderAlpha = max( | ||
yBorder < 0 ? 0 : max(0, xBorder - dimension.x + 10), | ||
yBorder < 0 ? max(0, 10 + yBorder) : max(0, yBorder - dimension.y + 10) | ||
) / 10; | ||
gl_FragColor = vec4(color.xyz, min(color.w, mix(0, 1, borderAlpha))); | ||
} | ||
} | ||
)--"); | ||
|
||
load(vertexShaderCode, fragmentShaderCode); | ||
|
||
m_positionLocation = attributeLocation("position"); | ||
m_dimensionLocation = uniformLocation("dimension"); | ||
m_colorLocation = uniformLocation("color"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "shaders/shader.h" | ||
|
||
namespace mixxx { | ||
class SlipModeShader; | ||
} | ||
|
||
class mixxx::SlipModeShader : public mixxx::Shader { | ||
public: | ||
SlipModeShader() = default; | ||
~SlipModeShader() = default; | ||
void init(); | ||
|
||
int positionLocation() const { | ||
return m_positionLocation; | ||
} | ||
int dimensionLocation() const { | ||
return m_dimensionLocation; | ||
} | ||
int colorLocation() const { | ||
return m_colorLocation; | ||
} | ||
|
||
private: | ||
int m_positionLocation; | ||
int m_dimensionLocation; | ||
int m_colorLocation; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(SlipModeShader) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.