Show compile errors and go back to GLSL V120.
This commit is contained in:
parent
9df7626e31
commit
6a5744adb1
|
@ -60,18 +60,18 @@ const char kicad_vertex_shader[] = R"SHADER_SOURCE(
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#version 130
|
||||
#version 120
|
||||
|
||||
// Shader types
|
||||
const int SHADER_FILLED_CIRCLE = 2;
|
||||
const int SHADER_STROKED_CIRCLE = 3;
|
||||
const int SHADER_FONT = 4;
|
||||
const int SHADER_LINE_A = 5;
|
||||
const int SHADER_LINE_B = 6;
|
||||
const int SHADER_LINE_C = 7;
|
||||
const int SHADER_LINE_D = 8;
|
||||
const int SHADER_LINE_E = 9;
|
||||
const int SHADER_LINE_F = 10;
|
||||
const float SHADER_FILLED_CIRCLE = 2.0;
|
||||
const float SHADER_STROKED_CIRCLE = 3.0;
|
||||
const float SHADER_FONT = 4.0;
|
||||
const float SHADER_LINE_A = 5.0;
|
||||
const float SHADER_LINE_B = 6.0;
|
||||
const float SHADER_LINE_C = 7.0;
|
||||
const float SHADER_LINE_D = 8.0;
|
||||
const float SHADER_LINE_E = 9.0;
|
||||
const float SHADER_LINE_F = 10.0;
|
||||
|
||||
// Minimum line width
|
||||
const float MIN_WIDTH = 1.0;
|
||||
|
@ -83,7 +83,7 @@ uniform float worldPixelSize;
|
|||
|
||||
void computeLineCoords( bool posture, vec2 offset, vec2 texcoord, vec2 dir )
|
||||
{
|
||||
float w = length(offset);
|
||||
float w = length( offset );
|
||||
|
||||
if( w > worldPixelSize )
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ void computeLineCoords( bool posture, vec2 offset, vec2 texcoord, vec2 dir )
|
|||
else
|
||||
{
|
||||
vec4 pos = gl_Vertex;
|
||||
pos.xy += (posture ? dir : dir.yx ) * worldPixelSize / 2.0;
|
||||
pos.xy += ( posture ? dir : dir.yx ) * worldPixelSize / 2.0;
|
||||
gl_Position = gl_ModelViewProjectionMatrix * pos;
|
||||
shaderParams[0] = SHADER_LINE_B;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ void computeLineCoords( bool posture, vec2 offset, vec2 texcoord, vec2 dir )
|
|||
|
||||
void main()
|
||||
{
|
||||
int mode = int( attrShaderParams[0] );
|
||||
float mode = attrShaderParams[0];
|
||||
|
||||
// Pass attributes to the fragment shader
|
||||
shaderParams = attrShaderParams;
|
||||
|
@ -113,50 +113,51 @@ void main()
|
|||
vec2 vp = vec2(-vs.y, vs.x);
|
||||
bool posture = abs( vs.x ) < abs(vs.y);
|
||||
|
||||
switch( mode )
|
||||
if( mode == SHADER_LINE_A )
|
||||
computeLineCoords( posture, vp - vs, vec2( -aspect, -1 ), vec2( -1, 0 ) );
|
||||
else if( mode == SHADER_LINE_B )
|
||||
computeLineCoords( posture, -vp - vs, vec2( -aspect, 1 ), vec2( 1, 0 ) );
|
||||
else if( mode == SHADER_LINE_C )
|
||||
computeLineCoords( posture, -vp + vs, vec2( aspect, 1 ), vec2( 1, 0 ) );
|
||||
else if( mode == SHADER_LINE_D )
|
||||
computeLineCoords( posture, -vp + vs, vec2( -aspect, -1 ), vec2( 1, 0 ) );
|
||||
else if( mode == SHADER_LINE_E )
|
||||
computeLineCoords( posture, vp + vs, vec2( -aspect, 1 ), vec2( -1, 0 ) );
|
||||
else if( mode == SHADER_LINE_F )
|
||||
computeLineCoords( posture, vp - vs, vec2( aspect, 1 ), vec2( -1, 0 ) );
|
||||
else if( mode == SHADER_STROKED_CIRCLE ||
|
||||
mode == SHADER_FILLED_CIRCLE )
|
||||
{
|
||||
case SHADER_LINE_A: computeLineCoords( posture, vp - vs, vec2( -aspect, -1 ), vec2(-1,0) ); break;
|
||||
case SHADER_LINE_B: computeLineCoords( posture, -vp - vs, vec2( -aspect, 1 ), vec2(1,0) ); break;
|
||||
case SHADER_LINE_C: computeLineCoords( posture, -vp + vs, vec2( aspect, 1 ), vec2(1,0) ); break;
|
||||
case SHADER_LINE_D: computeLineCoords( posture, -vp + vs, vec2( -aspect, -1), vec2(1,0) ); break;
|
||||
case SHADER_LINE_E: computeLineCoords( posture, vp + vs, vec2( -aspect, 1 ), vec2(-1,0) ); break;
|
||||
case SHADER_LINE_F: computeLineCoords( posture, vp - vs, vec2( aspect, 1 ), vec2(-1,0) ); break;
|
||||
case SHADER_STROKED_CIRCLE:
|
||||
case SHADER_FILLED_CIRCLE:
|
||||
{
|
||||
// Compute relative circle coordinates basing on indices
|
||||
// Circle
|
||||
if( shaderParams[1] == 1.0 )
|
||||
circleCoords = vec2( -sqrt( 3.0 ), -1.0 );
|
||||
else if( shaderParams[1] == 2.0 )
|
||||
circleCoords = vec2( sqrt( 3.0 ), -1.0 );
|
||||
else if( shaderParams[1] == 3.0 )
|
||||
circleCoords = vec2( 0.0, 2.0 );
|
||||
// Compute relative circle coordinates basing on indices
|
||||
// Circle
|
||||
if( shaderParams[1] == 1.0 )
|
||||
circleCoords = vec2( -sqrt( 3.0 ), -1.0 );
|
||||
else if( shaderParams[1] == 2.0 )
|
||||
circleCoords = vec2( sqrt( 3.0 ), -1.0 );
|
||||
else if( shaderParams[1] == 3.0 )
|
||||
circleCoords = vec2( 0.0, 2.0 );
|
||||
|
||||
// Semicircle
|
||||
else if( shaderParams[1] == 4.0 )
|
||||
circleCoords = vec2( -3.0 / sqrt( 3.0 ), 0.0 );
|
||||
else if( shaderParams[1] == 5.0 )
|
||||
circleCoords = vec2( 3.0 / sqrt( 3.0 ), 0.0 );
|
||||
else if( shaderParams[1] == 6.0 )
|
||||
circleCoords = vec2( 0.0, 2.0 );
|
||||
// Semicircle
|
||||
else if( shaderParams[1] == 4.0 )
|
||||
circleCoords = vec2( -3.0 / sqrt( 3.0 ), 0.0 );
|
||||
else if( shaderParams[1] == 5.0 )
|
||||
circleCoords = vec2( 3.0 / sqrt( 3.0 ), 0.0 );
|
||||
else if( shaderParams[1] == 6.0 )
|
||||
circleCoords = vec2( 0.0, 2.0 );
|
||||
|
||||
// Make the line appear to be at least 1 pixel wide
|
||||
float lineWidth = shaderParams[3];
|
||||
float worldScale = abs( gl_ModelViewMatrix[0][0] );
|
||||
// Make the line appear to be at least 1 pixel wide
|
||||
float lineWidth = shaderParams[3];
|
||||
float worldScale = abs( gl_ModelViewMatrix[0][0] );
|
||||
|
||||
if( worldScale * lineWidth < MIN_WIDTH )
|
||||
shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth );
|
||||
if( worldScale * lineWidth < MIN_WIDTH )
|
||||
shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth );
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
gl_Position = ftransform();
|
||||
break;
|
||||
}
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pass through the coordinates like in the fixed pipeline
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
||||
gl_FrontColor = gl_Color;
|
||||
|
@ -193,7 +194,7 @@ const char kicad_fragment_shader[] = R"SHADER_SOURCE(
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#version 130
|
||||
#version 120
|
||||
|
||||
// Multi-channel signed distance field
|
||||
#define USE_MSDF
|
||||
|
@ -223,7 +224,7 @@ void filledCircle( vec2 aCoord )
|
|||
|
||||
float pixelSegDistance( vec2 aCoord )
|
||||
{
|
||||
if (shaderParams[0] == SHADER_LINE_B)
|
||||
if( shaderParams[0] == SHADER_LINE_B )
|
||||
{
|
||||
gl_FragColor = gl_Color;
|
||||
return 0.0;
|
||||
|
@ -231,15 +232,15 @@ float pixelSegDistance( vec2 aCoord )
|
|||
|
||||
float aspect = shaderParams[1];
|
||||
float dist;
|
||||
vec2 v = vec2( 1.0 - (aspect - abs(aCoord.s)), aCoord.t);
|
||||
vec2 v = vec2( 1.0 - ( aspect - abs( aCoord.s ) ), aCoord.t );
|
||||
|
||||
if( v.x <= 0.0 )
|
||||
{
|
||||
dist = abs(aCoord.t);
|
||||
dist = abs( aCoord.t );
|
||||
}
|
||||
else
|
||||
{
|
||||
dist = length(v);
|
||||
dist = length( v );
|
||||
}
|
||||
|
||||
return dist;
|
||||
|
@ -247,7 +248,7 @@ float pixelSegDistance( vec2 aCoord )
|
|||
|
||||
int isPixelInSegment( vec2 aCoord )
|
||||
{
|
||||
return pixelSegDistance(aCoord) <= 1.0 ? 1 : 0;
|
||||
return pixelSegDistance( aCoord ) <= 1.0 ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -322,7 +322,7 @@ bool OPENGL_GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions )
|
|||
double OPENGL_GAL::getWorldPixelSize() const
|
||||
{
|
||||
auto matrix = GetScreenWorldMatrix();
|
||||
return std::min(std::abs(matrix.GetScale().x), std::abs(matrix.GetScale().y ) );
|
||||
return std::min( std::abs( matrix.GetScale().x ), std::abs( matrix.GetScale().y ) );
|
||||
}
|
||||
|
||||
void OPENGL_GAL::BeginDrawing()
|
||||
|
@ -1160,7 +1160,7 @@ void OPENGL_GAL::DrawGrid()
|
|||
compositor->SetBuffer( mainBuffer );
|
||||
|
||||
// sub-pixel lines all render the same
|
||||
double minorLineWidth = std::max(1.0, gridLineWidth) * getWorldPixelSize();
|
||||
double minorLineWidth = std::max( 1.0, gridLineWidth ) * getWorldPixelSize();
|
||||
double majorLineWidth = minorLineWidth * 2.0;
|
||||
|
||||
// Draw the axis and grid
|
||||
|
@ -1222,7 +1222,7 @@ void OPENGL_GAL::DrawGrid()
|
|||
glStencilFunc( GL_ALWAYS, 1, 1 );
|
||||
glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
|
||||
glColor4d( 0.0, 0.0, 0.0, 0.0 );
|
||||
SetStrokeColor( COLOR4D(0.0, 0.0, 0.0, 0.0 ) );
|
||||
SetStrokeColor( COLOR4D( 0.0, 0.0, 0.0, 0.0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1316,7 +1316,7 @@ void OPENGL_GAL::DrawGrid()
|
|||
|| gridScreenSizeDense > gridThreshold )
|
||||
{
|
||||
VECTOR2D a ( x, gridStartY * gridSize.y + gridOrigin.y );
|
||||
VECTOR2D b ( x, gridEndY * gridSize.y + gridOrigin.y );
|
||||
VECTOR2D b ( x, gridEndY * gridSize.y + gridOrigin.y );
|
||||
DrawLine( a, b );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <cassert>
|
||||
|
||||
#include <gal/opengl/shader.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace KIGFX;
|
||||
|
||||
|
@ -258,7 +259,19 @@ bool SHADER::loadShaderFromStringArray( SHADER_TYPE aShaderType, const char** aA
|
|||
if( status != GL_TRUE )
|
||||
{
|
||||
shaderInfo( shaderNumber );
|
||||
throw std::runtime_error( "Shader compilation error" );
|
||||
|
||||
GLint maxLength = 0;
|
||||
glGetShaderiv( shaderNumber, GL_INFO_LOG_LENGTH, &maxLength );
|
||||
|
||||
// The maxLength includes the NULL character
|
||||
std::vector<GLchar> errorLog( (size_t) maxLength );
|
||||
glGetShaderInfoLog( shaderNumber, maxLength, &maxLength, &errorLog[0] );
|
||||
|
||||
// Provide the infolog in whatever manor you deem best.
|
||||
// Exit with failure.
|
||||
glDeleteShader( shaderNumber ); // Don't leak the shader.
|
||||
|
||||
throw std::runtime_error( &errorLog[0] );
|
||||
}
|
||||
|
||||
glAttachShader( programNumber, shaderNumber );
|
||||
|
|
|
@ -108,7 +108,7 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void )
|
|||
|
||||
void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
|
||||
{
|
||||
wxWindowUpdateLocker dummy( this );
|
||||
//wxWindowUpdateLocker dummy( this );
|
||||
wxStaticText* text;
|
||||
|
||||
if( !m_auxiliaryToolBar )
|
||||
|
|
|
@ -177,10 +177,10 @@ public:
|
|||
* @param aParam2 is the optional parameter for a shader.
|
||||
* @param aParam3 is the optional parameter for a shader.
|
||||
*/
|
||||
inline void Shader( int aShaderType, GLfloat aParam1 = 0.0f,
|
||||
inline void Shader( GLfloat aShaderType, GLfloat aParam1 = 0.0f,
|
||||
GLfloat aParam2 = 0.0f, GLfloat aParam3 = 0.0f )
|
||||
{
|
||||
m_shader[0] = (float) aShaderType;
|
||||
m_shader[0] = aShaderType;
|
||||
m_shader[1] = aParam1;
|
||||
m_shader[2] = aParam2;
|
||||
m_shader[3] = aParam3;
|
||||
|
|
|
@ -234,7 +234,7 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
|
|||
{
|
||||
wxString msg;
|
||||
|
||||
wxWindowUpdateLocker dummy( this );
|
||||
//wxWindowUpdateLocker dummy( this );
|
||||
|
||||
if( m_mainToolBar )
|
||||
m_mainToolBar->Clear();
|
||||
|
@ -337,7 +337,7 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
|
|||
|
||||
void PCB_EDIT_FRAME::ReCreateOptToolbar()
|
||||
{
|
||||
wxWindowUpdateLocker dummy( this );
|
||||
//wxWindowUpdateLocker dummy( this );
|
||||
|
||||
if( m_optionsToolBar )
|
||||
m_optionsToolBar->Clear();
|
||||
|
@ -425,7 +425,7 @@ void PCB_EDIT_FRAME::ReCreateOptToolbar()
|
|||
|
||||
void PCB_EDIT_FRAME::ReCreateVToolbar()
|
||||
{
|
||||
wxWindowUpdateLocker dummy( this );
|
||||
//wxWindowUpdateLocker dummy( this );
|
||||
|
||||
if( m_drawToolBar )
|
||||
m_drawToolBar->Clear();
|
||||
|
@ -516,7 +516,7 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
|
|||
*/
|
||||
void PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar()
|
||||
{
|
||||
wxWindowUpdateLocker dummy(this);
|
||||
//wxWindowUpdateLocker dummy(this);
|
||||
|
||||
if( m_microWaveToolBar )
|
||||
m_microWaveToolBar->Clear();
|
||||
|
@ -559,7 +559,7 @@ void PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar()
|
|||
|
||||
void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar()
|
||||
{
|
||||
wxWindowUpdateLocker dummy( this );
|
||||
//wxWindowUpdateLocker dummy( this );
|
||||
|
||||
if( m_auxiliaryToolBar )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue