Skip to content

Commit

Permalink
Fixes to get snippets up and running before introducing new OpenGL wi…
Browse files Browse the repository at this point in the history
…dgets
  • Loading branch information
sigurdp committed Jan 11, 2024
1 parent 5cd3cb5 commit f343427
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 192 deletions.
47 changes: 28 additions & 19 deletions Fwk/VizFwk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ cmake_minimum_required(VERSION 3.15)
project(VizFramework)


if (CEE_CEEVIZ_ROOT)
message(STATUS "CEE_CEEVIZ_ROOT: ${CEE_CEEVIZ_ROOT}")
else()
set(CEE_CEEVIZ_ROOT ${PROJECT_SOURCE_DIR})
message(STATUS "Setting CEE_CEEVIZ_ROOT to ${CEE_CEEVIZ_ROOT}")
endif()

# Determine if we're being run stand-alone or invoked from some other project
set(CEE_STAND_ALONE ON)
if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
Expand Down Expand Up @@ -44,7 +51,6 @@ add_subdirectory(ThirdParty/FreeType)
add_subdirectory(LibUtilities)



option(CEE_BUILD_GUI_QT "Build GUI library for Qt" ON)
if (CEE_BUILD_GUI_QT)
option(CEE_USE_QT5 "Use Qt5" ON)
Expand All @@ -53,27 +59,30 @@ endif()


if (CEE_STAND_ALONE)

option(CEE_BUILD_UNIT_TESTS "Build unit tests" ON)
if (CEE_BUILD_UNIT_TESTS)
add_subdirectory(Tests)
endif()
option(CEE_BUILD_TEST_APPS "Build test apps" ON)
endif()

if (CEE_BUILD_UNIT_TESTS OR CEE_BUILD_TEST_APPS)
# Add CeeViz's root source dir as a preprocessor directive so unit tests and test apps can determine where to find the resources they want.
add_definitions(-DCVF_CEEVIZ_ROOT_SOURCE_DIR="${CEE_CEEVIZ_ROOT}")
endif()

option(CEE_BUILD_TEST_APPS "Build test apps" ON)
if (CEE_BUILD_TEST_APPS)
# For now, build the snippet libs here
add_subdirectory(Tests/SnippetsBasis)

if (CEE_BUILD_GUI_QT)
add_subdirectory(TestApps/Qt/QtMinimal_deprecated)
add_subdirectory(TestApps/Qt/QtMultiView_deprecated)
add_subdirectory(TestApps/Qt/QtSnippetRunner)
endif()

if (WIN32)
add_subdirectory(TestApps/Win32/Win32SnippetRunner)
endif()
if (CEE_BUILD_UNIT_TESTS)
add_subdirectory(Tests)
endif()

if (CEE_BUILD_TEST_APPS)
# For now, build the snippet libs here
add_subdirectory(Tests/SnippetsBasis)

if (CEE_BUILD_GUI_QT)
add_subdirectory(TestApps/Qt/QtMinimal_deprecated)
add_subdirectory(TestApps/Qt/QtMultiView_deprecated)
add_subdirectory(TestApps/Qt/QtSnippetRunner)
endif()

if (WIN32)
add_subdirectory(TestApps/Win32/Win32SnippetRunner)
endif()
endif()
10 changes: 10 additions & 0 deletions Fwk/VizFwk/LibRender/cvfShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ bool Shader::compile(OpenGLContext* oglContext)
String errStr = String("Error compiling shader: '%1'\n").arg(m_shaderName);
errStr += "GLSL details:\n";
errStr += shaderInfoLog(oglContext);

// {
// errStr += "Shader prog:\n";
// std::vector<String> progArr = m_source.split("\n");
// for (size_t i = 0; i < progArr.size(); ++i)
// {
// errStr += String("%1: %2\n").arg(static_cast<int>(i + 1), 3).arg(progArr[i]);
// }
// }

CVF_LOG_RENDER_ERROR(oglContext, errStr);
return false;
}
Expand Down
11 changes: 10 additions & 1 deletion Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ QSRStdInclude.cpp
QSRTranslateEvent.cpp
)

set(CEE_HEADER_FILES
QSRCommandLineArgs.h
QSRPropertiesPanel.h
QSRRunPanel.h
QSRSnippetWidget.h
QSRStdInclude.h
QSRTranslateEvent.h
)

# Headers that need MOCing
set(MOC_HEADER_FILES
QSRMainWindow.h
Expand All @@ -57,5 +66,5 @@ if (CMAKE_COMPILER_IS_GNUCXX)
set(SYSTEM_LIBRARIES -lrt -lpthread)
endif(CMAKE_COMPILER_IS_GNUCXX)

add_executable(${PROJECT_NAME} ${CEE_SOURCE_FILES} ${MOC_SOURCE_FILES})
add_executable(${PROJECT_NAME} ${CEE_SOURCE_FILES} ${CEE_HEADER_FILES} ${MOC_SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${CEE_LIBS} ${OPENGL_LIBRARIES} ${QT_LIBRARIES} ${SYSTEM_LIBRARIES})
9 changes: 6 additions & 3 deletions Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/QSRMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ int main(int argc, char *argv[])
// On Linux, Qt will use the system locale, force number formatting settings back to "C" locale
setlocale(LC_NUMERIC,"C");

// These directories are correct when running from within visual studio
cvf::String testDataDir = "../../../Tests/TestData/";
cvf::String shaderDir = "../../../Tests/SnippetsBasis/Shaders/";
cvf::String testDataDir = "";
cvf::String shaderDir = "";
#ifdef CVF_CEEVIZ_ROOT_SOURCE_DIR
testDataDir = CVF_CEEVIZ_ROOT_SOURCE_DIR "/Tests/TestData/";
shaderDir = CVF_CEEVIZ_ROOT_SOURCE_DIR "/Tests/SnippetsBasis/Shaders/";
#endif

{
QSRCommandLineArgs cmdLineArgs;
Expand Down
2 changes: 0 additions & 2 deletions Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/TriggerTBBCopy.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm
UNREFERENCED_PARAMETER(lpCmdLine);

cvf::ShaderSourceProvider* shaderProvider = cvf::ShaderSourceProvider::instance();
shaderProvider->setSourceRepository(new cvf::ShaderSourceRepositoryFile("../../../LibRender/glsl/"));
shaderProvider->addFileSearchDirectory("../../../Tests/SnippetsBasis/Shaders/");
shaderProvider->setSourceRepository(new cvf::ShaderSourceRepositoryFile(CVF_CEEVIZ_ROOT_SOURCE_DIR "/LibRender/glsl/"));
shaderProvider->addFileSearchDirectory(CVF_CEEVIZ_ROOT_SOURCE_DIR "/Tests/SnippetsBasis/Shaders/");
shaderProvider->addFileSearchDirectory("./");

const cvf::String testDataDir = "../../../Tests/TestData/";
const cvf::String testDataDir = CVF_CEEVIZ_ROOT_SOURCE_DIR "/Tests/TestData/";

cvfu::SnippetFactory* factoryBasis = new SnippetFactoryBasis;
factoryBasis->setTestDataDir(testDataDir);
Expand Down Expand Up @@ -168,7 +168,8 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
{
//ref<cvfu::TestSnippet> snippet = SnippetRegistry::instance()->createSnippet("snip::MinimalModel");
//ref<cvfu::TestSnippet> snippet = SnippetRegistry::instance()->createSnippet("snip::Highlight");
ref<cvfu::TestSnippet> snippet = SnippetRegistry::instance()->createSnippet("snip::Stencil");
//ref<cvfu::TestSnippet> snippet = SnippetRegistry::instance()->createSnippet("snip::Stencil");
ref<cvfu::TestSnippet> snippet = SnippetRegistry::instance()->createSnippet("snip::TransparentWeightedAverage");
sl_snippetWnd = new Win32SnippetWindow;
sl_snippetWnd->create(hWnd, snippet.p());
SetFocus(sl_snippetWnd->windowHandle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "cvfBase.h"

#include "gtest/gtest.h"
#include "gtest/cvftestUtils.h"

#include <stdio.h>


Expand All @@ -54,7 +54,5 @@ int main(int argc, char **argv)

testing::InitGoogleTest(&argc, argv);

cvftest::TestDataDir::initializeInstance(cvftest::TestDataDir::DEFAULT_DEFINE_THEN_VIZ_FRAMEWORK, true);

return RUN_ALL_TESTS();
}
8 changes: 4 additions & 4 deletions Fwk/VizFwk/Tests/LibUtilities_UnitTests/cvfuImageTga-Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ using namespace cvfu;
//--------------------------------------------------------------------------------------------------
TEST(ImageTgaTest, LoadUncompressed24bit)
{
String fullFileName = cvftest::TestDataDir::instance()->dataDir() + "TgaTestSuite/UTC24.TGA";
String fullFileName = cvftest::Utils::getTestDataDir() + "TgaTestSuite/UTC24.TGA";
cvf::Trace::show("FN: %s\n", fullFileName.toAscii().ptr());
ref<TextureImage> img = ImageTga::loadImage(fullFileName);
ASSERT_TRUE(img.notNull());
Expand All @@ -68,7 +68,7 @@ TEST(ImageTgaTest, LoadUncompressed24bit)
//--------------------------------------------------------------------------------------------------
TEST(ImageTgaTest, LoadCompressed24bit)
{
String fullFileName = cvftest::TestDataDir::instance()->dataDir() + "TgaTestSuite/CTC24.TGA";
String fullFileName = cvftest::Utils::getTestDataDir() + "TgaTestSuite/CTC24.TGA";
cvf::Trace::show("FN: %s\n", fullFileName.toAscii().ptr());
ref<TextureImage> img = ImageTga::loadImage(fullFileName);
ASSERT_TRUE(img.notNull());
Expand All @@ -85,7 +85,7 @@ TEST(ImageTgaTest, LoadCompressed24bit)
//--------------------------------------------------------------------------------------------------
TEST(ImageTgaTest, LoadUncompressed32bit)
{
String fullFileName = cvftest::TestDataDir::instance()->dataDir() + "TgaTestSuite/UTC32.TGA";
String fullFileName = cvftest::Utils::getTestDataDir() + "TgaTestSuite/UTC32.TGA";
ref<TextureImage> img = ImageTga::loadImage(fullFileName);
ASSERT_TRUE(img.notNull());

Expand All @@ -101,7 +101,7 @@ TEST(ImageTgaTest, LoadUncompressed32bit)
//--------------------------------------------------------------------------------------------------
TEST(ImageTgaTest, LoadCompressed32bit)
{
String fullFileName = cvftest::TestDataDir::instance()->dataDir() + "TgaTestSuite/CTC32.TGA";
String fullFileName = cvftest::Utils::getTestDataDir() + "TgaTestSuite/CTC32.TGA";
ref<TextureImage> img = ImageTga::loadImage(fullFileName);
ASSERT_TRUE(img.notNull());

Expand Down
14 changes: 7 additions & 7 deletions Fwk/VizFwk/Tests/SnippetsBasis/snipTextDrawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@ ref<Part> TextDrawing::createTextPart()
m_textDrawable->setFont(NULL);
m_textDrawable->setTextColor(Color3::RED);

// m_textDrawable->addText(L"Text:", cvf::Vec3f(50, 200, 0));
// m_textDrawable->addText(L" ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ", cvf::Vec3f(50, 170, 0));
// m_textDrawable->addText(L" abcdefghijklmnopqrstuvwxyzæøå", cvf::Vec3f(50, 140, 0));
// m_textDrawable->addText(L" 0123456789 0123456789 0123456789", cvf::Vec3f(50, 110, 0));
// m_textDrawable->addText(L" !\"#¤%&/()=?`^*@£$€{[]}´~¨',;.:+-_<>><VAWAVAA", cvf::Vec3f(50, 80, 0));
// m_textDrawable->addText(L" Unicode1: \x03B1\x03B2\x03B3\x03B4\x03B5", cvf::Vec3f(50, 50, 0));
// m_textDrawable->addText(L" Unicode2: 不仅是因为这两种语言截然不同", cvf::Vec3f(50, 20, 0));
m_textDrawable->addText(L"Text:", cvf::Vec3f(50, 200, 0));
m_textDrawable->addText(L" ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ", cvf::Vec3f(50, 170, 0));
m_textDrawable->addText(L" abcdefghijklmnopqrstuvwxyzæøå", cvf::Vec3f(50, 140, 0));
m_textDrawable->addText(L" 0123456789 0123456789 0123456789", cvf::Vec3f(50, 110, 0));
m_textDrawable->addText(L" !\"#¤%&/()=?`^*@£$€{[]}´~¨',;.:+-_<>><VAWAVAA", cvf::Vec3f(50, 80, 0));
m_textDrawable->addText(L" Unicode1: \x03B1\x03B2\x03B3\x03B4\x03B5", cvf::Vec3f(50, 50, 0));
m_textDrawable->addText(L" Unicode2: 不仅是因为这两种语言截然不同", cvf::Vec3f(50, 20, 0));

// Set up transparency
ref<RenderStateBlending> blending = new RenderStateBlending;
Expand Down
Loading

0 comments on commit f343427

Please sign in to comment.