Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
Disabled requirements for pack to have main shader,
Replaced exit(0) with exitApp(); exit(0) to dispose resources and call repaintDesktop(),
deleted Release directories
  • Loading branch information
bitrate16 committed Feb 20, 2022
1 parent b164309 commit c16fcdf
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 91 deletions.
Binary file removed Vebro/Release/x64/Vebro_x64.exe
Binary file not shown.
Binary file removed Vebro/Release/x64/freeglut.dll
Binary file not shown.
Binary file removed Vebro/Release/x64/glew32.dll
Binary file not shown.
1 change: 0 additions & 1 deletion Vebro/Release/x64/run.bat

This file was deleted.

Binary file removed Vebro/Release/x86/Vebro_x86.exe
Binary file not shown.
Binary file removed Vebro/Release/x86/freeglut.dll
Binary file not shown.
Binary file removed Vebro/Release/x86/glew32.dll
Binary file not shown.
174 changes: 84 additions & 90 deletions Vebro/Vebro/Vebro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,7 @@ void reloadPack() {
return;
}

// Not error, however..
if (mainShader["inputs"].size() < 4 || mainShader["inputs"].size() > 4)
std::wcout << "Warning :: JSON :: Main Shader has " << mainShader["inputs"].size() << " inputs, but 4 required :: " << scPackPath << std::endl;

Expand Down Expand Up @@ -1676,6 +1677,7 @@ void savePack() {
if (scPackPath == L"")
return;

/*
if (glMainShaderPath == L"") {
std::wcout << "To JSON :: Pack should have a Main Shader :: " << scPackPath << std::endl;
Expand All @@ -1688,57 +1690,62 @@ void savePack() {
return;
}
*/

std::filesystem::path basePackPath = std::filesystem::path(std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(scPackPath)).parent_path();

nlohmann::json j;

j["Main"]["path"] = std::filesystem::relative(std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(glMainShaderPath), basePackPath).string();

j["Main"]["inputs"] = nlohmann::json::array();
// Main shader is not required, however..
if (glMainShaderPath != L"") {
j["Main"]["path"] = std::filesystem::relative(std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(glMainShaderPath), basePackPath).string();

for (int i = 0; i < 4; ++i) {
if (scMainShaderInputs[i] == -1)
j["Main"]["inputs"][i] = nullptr;
else {
if (scResources[scMainShaderInputs[i]].empty)
std::wcout << "To JSON :: Main Shader input " << i << " is empty, scResources corrupt" << std::endl;
j["Main"]["inputs"] = nlohmann::json::array();

for (int i = 0; i < 4; ++i) {
if (scMainShaderInputs[i] == -1)
continue;
//j["Main"]["inputs"][i] = nullptr;
else {
switch (scResources[scMainShaderInputs[i]].resource.type) {
case IMAGE_TEXTURE: {
j["Main"]["inputs"][i]["type"] = "Image";
j["Main"]["inputs"][i]["path"] = std::filesystem::relative(std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(scResources[scMainShaderInputs[i]].resource.path), basePackPath).string();
break;
}
if (scResources[scMainShaderInputs[i]].empty)
std::wcout << "To JSON :: Main Shader input " << i << " is empty, scResources corrupt" << std::endl;
else {
switch (scResources[scMainShaderInputs[i]].resource.type) {
case IMAGE_TEXTURE: {
j["Main"]["inputs"][i]["type"] = "Image";
j["Main"]["inputs"][i]["path"] = std::filesystem::relative(std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(scResources[scMainShaderInputs[i]].resource.path), basePackPath).string();
break;
}

case AUDIO_TEXTURE: { // TODO: Save media resources
std::wcout << "To JSON :: Main Shader :: Incomplete :: Audio" << std::endl;
break;
}
case AUDIO_TEXTURE: { // TODO: Save media resources
std::wcout << "To JSON :: Main Shader :: Incomplete :: Audio" << std::endl;
break;
}

case VIDEO_TEXTURE: {
std::wcout << "To JSON :: Main Shader :: Incomplete :: Video" << std::endl;
break;
}
case VIDEO_TEXTURE: {
std::wcout << "To JSON :: Main Shader :: Incomplete :: Video" << std::endl;
break;
}

case MIC_TEXTURE: {
std::wcout << "To JSON :: Main Shader :: Incomplete :: Microphone" << std::endl;
break;
}
case MIC_TEXTURE: {
std::wcout << "To JSON :: Main Shader :: Incomplete :: Microphone" << std::endl;
break;
}

case WEB_TEXTURE: {
std::wcout << "To JSON :: Main Shader :: Incomplete :: Webcam" << std::endl;
break;
}
case WEB_TEXTURE: {
std::wcout << "To JSON :: Main Shader :: Incomplete :: Webcam" << std::endl;
break;
}

case KEYBOARD_TEXTURE: {
std::wcout << "To JSON :: Main Shader :: Incomplete :: Keyboard" << std::endl;
break;
}
case KEYBOARD_TEXTURE: {
std::wcout << "To JSON :: Main Shader :: Incomplete :: Keyboard" << std::endl;
break;
}

case FRAME_BUFFER: {
j["Main"]["inputs"][i]["type"] = std::string("Buffer") + "ABCD"[scResources[scMainShaderInputs[i]].resource.buffer_id];
break;
case FRAME_BUFFER: {
j["Main"]["inputs"][i]["type"] = std::string("Buffer") + "ABCD"[scResources[scMainShaderInputs[i]].resource.buffer_id];
break;
}
}
}
}
Expand All @@ -1747,17 +1754,19 @@ void savePack() {

// Do the same for buffers
for (int k = 0; k < 4; ++k) {
std::string bufferKey = std::string("Buffer") + "ABCD"[k];

if (glBufferShaderPath[k] == L"")
continue;

std::string bufferKey = std::string("Buffer") + "ABCD"[k];

j[bufferKey]["path"] = std::filesystem::relative(std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(glBufferShaderPath[k]), basePackPath).string();
j[bufferKey]["inputs"] = nlohmann::json::array();

for (int i = 0; i < 4; ++i) {
if (scBufferShaderInputs[k][i] == -1)
j[bufferKey]["inputs"][i] = nullptr;
continue;
//j[bufferKey]["inputs"][i] = nullptr;
else {
if (scResources[scBufferShaderInputs[k][i]].empty)
std::wcout << "To JSON :: Buffer " << ("ABCD"[k]) << " Shader input " << i << " is empty, scResources corrupt" << std::endl;
Expand Down Expand Up @@ -2441,8 +2450,10 @@ void exitApp() {

// Wait for rendering thread to exit
appExiting = TRUE;
renderThread->join();
delete renderThread;
if (renderThread) {
renderThread->join();
delete renderThread;
}

// Tray icon delete
Shell_NotifyIcon(NIM_DELETE, &trayNID);
Expand Down Expand Up @@ -4214,7 +4225,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,

#endif

// Parse commandline options
// Change output mode to Unicode text
int _sm = _setmode(_fileno(stdout), _O_U16TEXT);


// Parse first portion of arguments

// Help message
if (cmdOptionExists(__wargv, __wargv + __argc, L"-h") || cmdOptionExists(__wargv, __wargv + __argc, L"--help")) {
std::wcout << "help for commandline options (use separately)" << std::endl;
std::wcout << " -h, --help display help" << std::endl;
Expand Down Expand Up @@ -4341,8 +4358,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
// Moise input
scMouseEnabled = cmdOptionExists(__wargv, __wargv + __argc, L"--mouse");

// Change output mode to Unicode text
int _sm = _setmode(_fileno(stdout), _O_U16TEXT);

// Create Windows & GL Context

// Create Tray menu
if (createTrayMenu(hInstance)) {
Expand All @@ -4369,12 +4386,12 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
// Release OpenGL context for this thread
wglMakeCurrent(NULL, NULL);

// Load shaders and packs after GL context initialized and exit on failture
bool initFailture = 0;

// Acquire GL context
wglMakeCurrent(glDevice, glContext);


// Parse rest of arguments (Textures, inputs)

// Pack path
if (argi = getCmdOptionIndex(__wargv, __wargv + __argc, L"--pack")) {
if (argi + 1 >= __argc) {
Expand All @@ -4383,7 +4400,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}

try {
Expand All @@ -4399,7 +4416,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}
}

Expand All @@ -4411,7 +4428,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}

try {
Expand All @@ -4424,7 +4441,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}
}

Expand All @@ -4436,7 +4453,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}

std::wstring arg = __wargv[argi];
Expand All @@ -4456,7 +4473,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}
} else if (arg == L"a") {
SCResource input;
Expand Down Expand Up @@ -4490,7 +4507,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}
}
}
Expand All @@ -4506,7 +4523,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}

try {
Expand All @@ -4519,7 +4536,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}
}

Expand All @@ -4531,7 +4548,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}

std::wstring arg = __wargv[argi];
Expand All @@ -4551,7 +4568,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp();
}
} else if (arg == L"a") {
SCResource input;
Expand Down Expand Up @@ -4585,47 +4602,24 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
if (useDebugConsole)
system("PAUSE");

exit(0);
exitApp(); exit(0);
}
}
}
}








// Instead of exit(0) call exitAPp()

















// Finally, start rendering if everything was ok
// However..

// Release GL context
wglMakeCurrent(NULL, NULL);

if (!initFailture) {
// Start new thread for render
startRenderThread();
// Start new thread for render
startRenderThread();

// Enter message dispatching loop
enterDispatchLoop();
}
// Enter message dispatching loop
enterDispatchLoop();

// After dispatch loop: exit and dispose
exitApp();
Expand Down

0 comments on commit c16fcdf

Please sign in to comment.