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
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#version 130
|
#version 120
|
||||||
|
|
||||||
// Shader types
|
// Shader types
|
||||||
const int SHADER_FILLED_CIRCLE = 2;
|
const float SHADER_FILLED_CIRCLE = 2.0;
|
||||||
const int SHADER_STROKED_CIRCLE = 3;
|
const float SHADER_STROKED_CIRCLE = 3.0;
|
||||||
const int SHADER_FONT = 4;
|
const float SHADER_FONT = 4.0;
|
||||||
const int SHADER_LINE_A = 5;
|
const float SHADER_LINE_A = 5.0;
|
||||||
const int SHADER_LINE_B = 6;
|
const float SHADER_LINE_B = 6.0;
|
||||||
const int SHADER_LINE_C = 7;
|
const float SHADER_LINE_C = 7.0;
|
||||||
const int SHADER_LINE_D = 8;
|
const float SHADER_LINE_D = 8.0;
|
||||||
const int SHADER_LINE_E = 9;
|
const float SHADER_LINE_E = 9.0;
|
||||||
const int SHADER_LINE_F = 10;
|
const float SHADER_LINE_F = 10.0;
|
||||||
|
|
||||||
// Minimum line width
|
// Minimum line width
|
||||||
const float MIN_WIDTH = 1.0;
|
const float MIN_WIDTH = 1.0;
|
||||||
|
@ -83,7 +83,7 @@ uniform float worldPixelSize;
|
||||||
|
|
||||||
void computeLineCoords( bool posture, vec2 offset, vec2 texcoord, vec2 dir )
|
void computeLineCoords( bool posture, vec2 offset, vec2 texcoord, vec2 dir )
|
||||||
{
|
{
|
||||||
float w = length(offset);
|
float w = length( offset );
|
||||||
|
|
||||||
if( w > worldPixelSize )
|
if( w > worldPixelSize )
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ void computeLineCoords( bool posture, vec2 offset, vec2 texcoord, vec2 dir )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vec4 pos = gl_Vertex;
|
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;
|
gl_Position = gl_ModelViewProjectionMatrix * pos;
|
||||||
shaderParams[0] = SHADER_LINE_B;
|
shaderParams[0] = SHADER_LINE_B;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ void computeLineCoords( bool posture, vec2 offset, vec2 texcoord, vec2 dir )
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
int mode = int( attrShaderParams[0] );
|
float mode = attrShaderParams[0];
|
||||||
|
|
||||||
// Pass attributes to the fragment shader
|
// Pass attributes to the fragment shader
|
||||||
shaderParams = attrShaderParams;
|
shaderParams = attrShaderParams;
|
||||||
|
@ -113,50 +113,51 @@ void main()
|
||||||
vec2 vp = vec2(-vs.y, vs.x);
|
vec2 vp = vec2(-vs.y, vs.x);
|
||||||
bool posture = abs( vs.x ) < abs(vs.y);
|
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;
|
// Compute relative circle coordinates basing on indices
|
||||||
case SHADER_LINE_B: computeLineCoords( posture, -vp - vs, vec2( -aspect, 1 ), vec2(1,0) ); break;
|
// Circle
|
||||||
case SHADER_LINE_C: computeLineCoords( posture, -vp + vs, vec2( aspect, 1 ), vec2(1,0) ); break;
|
if( shaderParams[1] == 1.0 )
|
||||||
case SHADER_LINE_D: computeLineCoords( posture, -vp + vs, vec2( -aspect, -1), vec2(1,0) ); break;
|
circleCoords = vec2( -sqrt( 3.0 ), -1.0 );
|
||||||
case SHADER_LINE_E: computeLineCoords( posture, vp + vs, vec2( -aspect, 1 ), vec2(-1,0) ); break;
|
else if( shaderParams[1] == 2.0 )
|
||||||
case SHADER_LINE_F: computeLineCoords( posture, vp - vs, vec2( aspect, 1 ), vec2(-1,0) ); break;
|
circleCoords = vec2( sqrt( 3.0 ), -1.0 );
|
||||||
case SHADER_STROKED_CIRCLE:
|
else if( shaderParams[1] == 3.0 )
|
||||||
case SHADER_FILLED_CIRCLE:
|
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
|
// Semicircle
|
||||||
else if( shaderParams[1] == 4.0 )
|
else if( shaderParams[1] == 4.0 )
|
||||||
circleCoords = vec2( -3.0 / sqrt( 3.0 ), 0.0 );
|
circleCoords = vec2( -3.0 / sqrt( 3.0 ), 0.0 );
|
||||||
else if( shaderParams[1] == 5.0 )
|
else if( shaderParams[1] == 5.0 )
|
||||||
circleCoords = vec2( 3.0 / sqrt( 3.0 ), 0.0 );
|
circleCoords = vec2( 3.0 / sqrt( 3.0 ), 0.0 );
|
||||||
else if( shaderParams[1] == 6.0 )
|
else if( shaderParams[1] == 6.0 )
|
||||||
circleCoords = vec2( 0.0, 2.0 );
|
circleCoords = vec2( 0.0, 2.0 );
|
||||||
|
|
||||||
// Make the line appear to be at least 1 pixel wide
|
// Make the line appear to be at least 1 pixel wide
|
||||||
float lineWidth = shaderParams[3];
|
float lineWidth = shaderParams[3];
|
||||||
float worldScale = abs( gl_ModelViewMatrix[0][0] );
|
float worldScale = abs( gl_ModelViewMatrix[0][0] );
|
||||||
|
|
||||||
if( worldScale * lineWidth < MIN_WIDTH )
|
if( worldScale * lineWidth < MIN_WIDTH )
|
||||||
shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth );
|
shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth );
|
||||||
|
|
||||||
gl_Position = ftransform();
|
gl_Position = ftransform();
|
||||||
|
}
|
||||||
break;
|
else
|
||||||
}
|
{
|
||||||
default:
|
// Pass through the coordinates like in the fixed pipeline
|
||||||
{
|
gl_Position = ftransform();
|
||||||
gl_Position = ftransform();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FrontColor = gl_Color;
|
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
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#version 130
|
#version 120
|
||||||
|
|
||||||
// Multi-channel signed distance field
|
// Multi-channel signed distance field
|
||||||
#define USE_MSDF
|
#define USE_MSDF
|
||||||
|
@ -223,7 +224,7 @@ void filledCircle( vec2 aCoord )
|
||||||
|
|
||||||
float pixelSegDistance( vec2 aCoord )
|
float pixelSegDistance( vec2 aCoord )
|
||||||
{
|
{
|
||||||
if (shaderParams[0] == SHADER_LINE_B)
|
if( shaderParams[0] == SHADER_LINE_B )
|
||||||
{
|
{
|
||||||
gl_FragColor = gl_Color;
|
gl_FragColor = gl_Color;
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
@ -231,15 +232,15 @@ float pixelSegDistance( vec2 aCoord )
|
||||||
|
|
||||||
float aspect = shaderParams[1];
|
float aspect = shaderParams[1];
|
||||||
float dist;
|
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 )
|
if( v.x <= 0.0 )
|
||||||
{
|
{
|
||||||
dist = abs(aCoord.t);
|
dist = abs( aCoord.t );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dist = length(v);
|
dist = length( v );
|
||||||
}
|
}
|
||||||
|
|
||||||
return dist;
|
return dist;
|
||||||
|
@ -247,7 +248,7 @@ float pixelSegDistance( vec2 aCoord )
|
||||||
|
|
||||||
int isPixelInSegment( 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
|
double OPENGL_GAL::getWorldPixelSize() const
|
||||||
{
|
{
|
||||||
auto matrix = GetScreenWorldMatrix();
|
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()
|
void OPENGL_GAL::BeginDrawing()
|
||||||
|
@ -1160,7 +1160,7 @@ void OPENGL_GAL::DrawGrid()
|
||||||
compositor->SetBuffer( mainBuffer );
|
compositor->SetBuffer( mainBuffer );
|
||||||
|
|
||||||
// sub-pixel lines all render the same
|
// 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;
|
double majorLineWidth = minorLineWidth * 2.0;
|
||||||
|
|
||||||
// Draw the axis and grid
|
// Draw the axis and grid
|
||||||
|
@ -1222,7 +1222,7 @@ void OPENGL_GAL::DrawGrid()
|
||||||
glStencilFunc( GL_ALWAYS, 1, 1 );
|
glStencilFunc( GL_ALWAYS, 1, 1 );
|
||||||
glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
|
glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
|
||||||
glColor4d( 0.0, 0.0, 0.0, 0.0 );
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -1316,7 +1316,7 @@ void OPENGL_GAL::DrawGrid()
|
||||||
|| gridScreenSizeDense > gridThreshold )
|
|| gridScreenSizeDense > gridThreshold )
|
||||||
{
|
{
|
||||||
VECTOR2D a ( x, gridStartY * gridSize.y + gridOrigin.y );
|
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 );
|
DrawLine( a, b );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <gal/opengl/shader.h>
|
#include <gal/opengl/shader.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace KIGFX;
|
using namespace KIGFX;
|
||||||
|
|
||||||
|
@ -258,7 +259,19 @@ bool SHADER::loadShaderFromStringArray( SHADER_TYPE aShaderType, const char** aA
|
||||||
if( status != GL_TRUE )
|
if( status != GL_TRUE )
|
||||||
{
|
{
|
||||||
shaderInfo( shaderNumber );
|
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 );
|
glAttachShader( programNumber, shaderNumber );
|
||||||
|
|
|
@ -108,7 +108,7 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void )
|
||||||
|
|
||||||
void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
|
void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
|
||||||
{
|
{
|
||||||
wxWindowUpdateLocker dummy( this );
|
//wxWindowUpdateLocker dummy( this );
|
||||||
wxStaticText* text;
|
wxStaticText* text;
|
||||||
|
|
||||||
if( !m_auxiliaryToolBar )
|
if( !m_auxiliaryToolBar )
|
||||||
|
|
|
@ -177,10 +177,10 @@ public:
|
||||||
* @param aParam2 is the optional parameter for a shader.
|
* @param aParam2 is the optional parameter for a shader.
|
||||||
* @param aParam3 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 )
|
GLfloat aParam2 = 0.0f, GLfloat aParam3 = 0.0f )
|
||||||
{
|
{
|
||||||
m_shader[0] = (float) aShaderType;
|
m_shader[0] = aShaderType;
|
||||||
m_shader[1] = aParam1;
|
m_shader[1] = aParam1;
|
||||||
m_shader[2] = aParam2;
|
m_shader[2] = aParam2;
|
||||||
m_shader[3] = aParam3;
|
m_shader[3] = aParam3;
|
||||||
|
|
|
@ -234,7 +234,7 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
||||||
wxWindowUpdateLocker dummy( this );
|
//wxWindowUpdateLocker dummy( this );
|
||||||
|
|
||||||
if( m_mainToolBar )
|
if( m_mainToolBar )
|
||||||
m_mainToolBar->Clear();
|
m_mainToolBar->Clear();
|
||||||
|
@ -337,7 +337,7 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::ReCreateOptToolbar()
|
void PCB_EDIT_FRAME::ReCreateOptToolbar()
|
||||||
{
|
{
|
||||||
wxWindowUpdateLocker dummy( this );
|
//wxWindowUpdateLocker dummy( this );
|
||||||
|
|
||||||
if( m_optionsToolBar )
|
if( m_optionsToolBar )
|
||||||
m_optionsToolBar->Clear();
|
m_optionsToolBar->Clear();
|
||||||
|
@ -425,7 +425,7 @@ void PCB_EDIT_FRAME::ReCreateOptToolbar()
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::ReCreateVToolbar()
|
void PCB_EDIT_FRAME::ReCreateVToolbar()
|
||||||
{
|
{
|
||||||
wxWindowUpdateLocker dummy( this );
|
//wxWindowUpdateLocker dummy( this );
|
||||||
|
|
||||||
if( m_drawToolBar )
|
if( m_drawToolBar )
|
||||||
m_drawToolBar->Clear();
|
m_drawToolBar->Clear();
|
||||||
|
@ -516,7 +516,7 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
|
||||||
*/
|
*/
|
||||||
void PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar()
|
void PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar()
|
||||||
{
|
{
|
||||||
wxWindowUpdateLocker dummy(this);
|
//wxWindowUpdateLocker dummy(this);
|
||||||
|
|
||||||
if( m_microWaveToolBar )
|
if( m_microWaveToolBar )
|
||||||
m_microWaveToolBar->Clear();
|
m_microWaveToolBar->Clear();
|
||||||
|
@ -559,7 +559,7 @@ void PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar()
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar()
|
void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar()
|
||||||
{
|
{
|
||||||
wxWindowUpdateLocker dummy( this );
|
//wxWindowUpdateLocker dummy( this );
|
||||||
|
|
||||||
if( m_auxiliaryToolBar )
|
if( m_auxiliaryToolBar )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue