Add initial ogltest tool for user testing
This tool is currently very rudimentary. I pushed it because I need to collect responses from it from users with diverse graphics configurations, so I want the tool to be in the nightly builds. This affects no KiCad code.
This commit is contained in:
parent
8f3423b803
commit
c8ef5208ee
|
@ -4,6 +4,7 @@ if( COMPILER_SUPPORTS_WSHADOW )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory( idftools )
|
add_subdirectory( idftools )
|
||||||
|
add_subdirectory( kicad-ogltest )
|
||||||
|
|
||||||
if( KICAD_USE_OCE )
|
if( KICAD_USE_OCE )
|
||||||
add_subdirectory( kicad2step )
|
add_subdirectory( kicad2step )
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
include_directories( BEFORE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_SOURCE_DIR}/include
|
||||||
|
${OPENGL_INCLUDE_DIR}
|
||||||
|
${Boost_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories( SYSTEM
|
||||||
|
)
|
||||||
|
|
||||||
|
set( OGLTEST_FILES
|
||||||
|
kicad-ogltest.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable( kicad-ogltest ${OGLTEST_FILES} )
|
||||||
|
|
||||||
|
target_link_libraries( kicad-ogltest ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} )
|
||||||
|
|
||||||
|
if( APPLE )
|
||||||
|
# puts binaries into the *.app bundle while linking
|
||||||
|
set_target_properties( kicad-ogltest PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
install( TARGETS kicad-ogltest
|
||||||
|
DESTINATION ${KICAD_BIN}
|
||||||
|
COMPONENT binary )
|
||||||
|
endif()
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This executable tests for OpenGL compatibility. This is done in a separate
|
||||||
|
* process to contain any crashes.
|
||||||
|
*
|
||||||
|
* Early version, intended just for user testing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/app.h>
|
||||||
|
#include <wx/debug.h>
|
||||||
|
#include <wx/settings.h>
|
||||||
|
#include <wx/glcanvas.h>
|
||||||
|
#include <wx/frame.h>
|
||||||
|
#include <wx/regex.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
// Required OpenGL version
|
||||||
|
#define REQUIRED_MAJOR 2L
|
||||||
|
#define REQUIRED_MINOR 1L
|
||||||
|
|
||||||
|
static wxRegEx OGLVersionRegex( R"(^(\d+)\.(\d+))", wxRE_ADVANCED );
|
||||||
|
|
||||||
|
static const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 8, 0 };
|
||||||
|
|
||||||
|
|
||||||
|
class OGLTEST_APP : public wxApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool OnInit() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
wxIMPLEMENT_APP( OGLTEST_APP );
|
||||||
|
|
||||||
|
|
||||||
|
class WX_QUIET
|
||||||
|
{
|
||||||
|
wxLogLevel m_old_level;
|
||||||
|
wxAssertHandler_t m_old_handler;
|
||||||
|
|
||||||
|
public:
|
||||||
|
WX_QUIET()
|
||||||
|
{
|
||||||
|
m_old_level = wxLog::GetLogLevel();
|
||||||
|
m_old_handler = wxTheAssertHandler;
|
||||||
|
wxTheAssertHandler = nullptr;
|
||||||
|
wxLog::SetLogLevel( wxLOG_FatalError );
|
||||||
|
}
|
||||||
|
|
||||||
|
~WX_QUIET()
|
||||||
|
{
|
||||||
|
wxLog::SetLogLevel( m_old_level );
|
||||||
|
wxTheAssertHandler = m_old_handler;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bool OGLTEST_APP::OnInit()
|
||||||
|
{
|
||||||
|
WX_QUIET be_quiet;
|
||||||
|
|
||||||
|
auto frame = new wxFrame( nullptr, wxID_ANY, "OpenGL test", wxDefaultPosition, wxDefaultSize,
|
||||||
|
wxTOPLEVEL_EX_DIALOG );
|
||||||
|
auto canvas = new wxGLCanvas( frame, wxID_ANY, &glAttributes[0] );
|
||||||
|
auto context = new wxGLContext( canvas );
|
||||||
|
|
||||||
|
frame->Show();
|
||||||
|
canvas->SetCurrent( *context );
|
||||||
|
|
||||||
|
printf( "INFO: Instantiated GL window\n" );
|
||||||
|
|
||||||
|
char* pversion = (char*) glGetString( GL_VERSION );
|
||||||
|
|
||||||
|
if( !pversion )
|
||||||
|
{
|
||||||
|
printf( "FAIL: Cannot get OpenGL version\n" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString version = wxString::FromUTF8( pversion );
|
||||||
|
|
||||||
|
if( !OGLVersionRegex.Matches( version ) )
|
||||||
|
{
|
||||||
|
printf( "FAIL: Cannot interpret OpenGL version\n" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString smajor = OGLVersionRegex.GetMatch( version, 1 );
|
||||||
|
wxString sminor = OGLVersionRegex.GetMatch( version, 2 );
|
||||||
|
|
||||||
|
long major, minor;
|
||||||
|
|
||||||
|
smajor.ToLong( &major );
|
||||||
|
sminor.ToLong( &minor );
|
||||||
|
|
||||||
|
if( major < REQUIRED_MAJOR || ( major == REQUIRED_MAJOR && minor < REQUIRED_MINOR ) )
|
||||||
|
{
|
||||||
|
printf( "FAIL: Found OpenGL version %ld.%ld, required at least %ld.%ld\n",
|
||||||
|
major, minor, REQUIRED_MAJOR, REQUIRED_MINOR );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf( "INFO: Found OpenGL version %ld.%ld\n", major, minor );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool supported = wxGLCanvas::IsDisplaySupported( &glAttributes[0] );
|
||||||
|
|
||||||
|
if( supported )
|
||||||
|
printf( "PASS\n" );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf( "FAIL: Display settings not supported\n" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
Loading…
Reference in New Issue