Show compile errors and go back to GLSL V120.

This commit is contained in:
Jeff Young 2018-10-13 12:39:09 +01:00
parent 9df7626e31
commit 6a5744adb1
6 changed files with 85 additions and 71 deletions

View File

@ -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;
@ -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,16 +113,20 @@ void main()
vec2 vp = vec2(-vs.y, vs.x);
bool posture = abs( vs.x ) < abs(vs.y);
switch( mode )
{
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:
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 )
{
// Compute relative circle coordinates basing on indices
// Circle
@ -149,14 +153,11 @@ void main()
shaderParams[3] = shaderParams[3] / ( worldScale * lineWidth );
gl_Position = ftransform();
break;
}
default:
else
{
// Pass through the coordinates like in the fixed pipeline
gl_Position = ftransform();
break;
}
}
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

View File

@ -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 );

View File

@ -108,7 +108,7 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void )
void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
{
wxWindowUpdateLocker dummy( this );
//wxWindowUpdateLocker dummy( this );
wxStaticText* text;
if( !m_auxiliaryToolBar )

View File

@ -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;

View File

@ -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 )
{