diff --git a/ImGuiTestCPP.sln b/KCNet-ImGui-Test.sln similarity index 52% rename from ImGuiTestCPP.sln rename to KCNet-ImGui-Test.sln index 1ca7ac4..439f557 100644 --- a/ImGuiTestCPP.sln +++ b/KCNet-ImGui-Test.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34330.188 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImGuiTestCPP", "ConsoleAppTest.vcxproj", "{6E4373C3-3E97-4007-9B8B-597F55378360}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImGuiTestCPP", "KCNet-ImGui-Test.vcxproj", "{0BED48FD-945D-4084-80AB-20EC84A145DE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,22 +17,22 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug|x64.ActiveCfg = Debug|x64 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug|x64.Build.0 = Debug|x64 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug|x86.ActiveCfg = Debug|Win32 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug|x86.Build.0 = Debug|Win32 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug-Directx9|x64.ActiveCfg = Debug-Directx9|x64 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug-Directx9|x64.Build.0 = Debug-Directx9|x64 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug-Directx9|x86.ActiveCfg = Debug-Directx9|Win32 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug-Directx9|x86.Build.0 = Debug-Directx9|Win32 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug-OpenGL|x64.ActiveCfg = Debug-OpenGL|x64 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug-OpenGL|x64.Build.0 = Debug-OpenGL|x64 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug-OpenGL|x86.ActiveCfg = Debug-OpenGL|Win32 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Debug-OpenGL|x86.Build.0 = Debug-OpenGL|Win32 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Release|x64.ActiveCfg = Release|x64 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Release|x64.Build.0 = Release|x64 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Release|x86.ActiveCfg = Release|Win32 - {6E4373C3-3E97-4007-9B8B-597F55378360}.Release|x86.Build.0 = Release|Win32 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug|x64.ActiveCfg = Debug|x64 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug|x64.Build.0 = Debug|x64 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug|x86.ActiveCfg = Debug|Win32 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug|x86.Build.0 = Debug|Win32 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug-Directx9|x64.ActiveCfg = Debug-Directx9|x64 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug-Directx9|x64.Build.0 = Debug-Directx9|x64 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug-Directx9|x86.ActiveCfg = Debug-Directx9|Win32 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug-Directx9|x86.Build.0 = Debug-Directx9|Win32 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug-OpenGL|x64.ActiveCfg = Debug-OpenGL|x64 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug-OpenGL|x64.Build.0 = Debug-OpenGL|x64 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug-OpenGL|x86.ActiveCfg = Debug-OpenGL|Win32 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Debug-OpenGL|x86.Build.0 = Debug-OpenGL|Win32 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Release|x64.ActiveCfg = Release|x64 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Release|x64.Build.0 = Release|x64 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Release|x86.ActiveCfg = Release|Win32 + {0BED48FD-945D-4084-80AB-20EC84A145DE}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ConsoleAppTest.vcxproj b/KCNet-ImGui-Test.vcxproj similarity index 85% rename from ConsoleAppTest.vcxproj rename to KCNet-ImGui-Test.vcxproj index 4990e13..8d89030 100644 --- a/ConsoleAppTest.vcxproj +++ b/KCNet-ImGui-Test.vcxproj @@ -37,10 +37,10 @@ 17.0 Win32Proj - {6e4373c3-3e97-4007-9b8b-597f55378360} + {0BED48FD-945D-4084-80AB-20EC84A145DE} ConsoleAppTest 10.0 - ImGuiTestCPP + KCNet-ImGui-Test @@ -130,12 +130,15 @@ Level3 true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;_OPENGL;%(PreprocessorDefinitions) true + .\include\GLFW;.\lib\ImGui;%(AdditionalIncludeDirectories) Console true + glfw3.lib;glfw3dll.lib;%(AdditionalDependencies) + .\lib\glfw\lib-vc2022\;%(AdditionalLibraryDirectories) @@ -161,7 +164,7 @@ _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpplatest - lib\imgui\;lib\imgui\backends;include\;%(AdditionalIncludeDirectories) + lib\imgui\;lib\imgui\backends;include\;.\util;.\test;%(AdditionalIncludeDirectories) Console @@ -204,7 +207,7 @@ - lib\imgui\;lib\imgui\backends;%(AdditionalIncludeDirectories) + lib\imgui\;lib\imgui\backends;.\src;%(AdditionalIncludeDirectories) _DIRECTX9 @@ -220,7 +223,7 @@ - + @@ -228,16 +231,32 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -248,15 +267,6 @@ - - - - - - - - - diff --git a/KCNet-ImGui-Test.vcxproj.filters b/KCNet-ImGui-Test.vcxproj.filters new file mode 100644 index 0000000..f6b42a1 --- /dev/null +++ b/KCNet-ImGui-Test.vcxproj.filters @@ -0,0 +1,164 @@ + + + + + src + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\util + + + src\util + + + src\util + + + src\util + + + src\test + + + src\test + + + src\test + + + src\test + + + src\test + + + src\menus + + + src\menus + + + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\lib\ImGui + + + src\util + + + src\util + + + src\util + + + src\util + + + src\test + + + src\test + + + src\test + + + src\test + + + src\test + + + src\test + + + src\menus + + + src\menus + + + src\menus + + + + + {96d2e389-bfd0-443a-af14-d02226755b89} + + + {74c54db3-2a79-45b7-ace5-bcbf01fa1044} + + + {caee360c-2fdb-4dc0-b9d0-11cc1c076d58} + + + {f4aa985e-3c6f-454e-b800-c186b9f15084} + + + {980dc627-529c-4841-abd5-7fa717911800} + + + {91557761-2f06-4a06-b8fa-506b1ae06724} + + + {1804e534-3e6f-47ec-bf39-30070e52ce27} + + + + + src\lib\ImGui + + + \ No newline at end of file diff --git a/Main - Copy.cpp b/Main - Copy.cpp deleted file mode 100644 index ba0d62e..0000000 --- a/Main - Copy.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include - -// Fixes it to where I don't need to use std::cout and std::string -using namespace std; - -int main() -{ - // This is a way to define multiple variables at once - int player1_score = 25, player2_score = 40; - - // Variable declaration - int player3_score; - // Variable initialisation - player3_score = 22; - - // Constants (These can't be changed later) - const string playername = "kelson8"; - - // Pointer test (Both of these are valid) - const int *ptr = &player2_score; - const string* ptr1 = &playername; - - // "endl" makes a new line - // either "cout" or "printf" can be used to output text. - //cout << "Hello " << playername << " welcome to the party!" << endl; - //cout << "Nice, you got a high score of " << player2_score << endl; - - // This needs the * on it or it don't work right since it's a pointer, I still don't fully understand how these work. - cout << *ptr1 << " " << *ptr; - - // Newest C++ preview required for this to work. - //std::print("Hello {}, welcome to the party!", playername); - //std::print("Test"); - - // Why doesn't this printf work right? - //printf("Hello %s welcome to the party", playername); - //printf("Nice, you got a high score of %s", player2_score); - - return 0; -} \ No newline at end of file diff --git a/Main.cpp b/src/Main.cpp similarity index 92% rename from Main.cpp rename to src/Main.cpp index 6fecc34..45eb6c9 100644 --- a/Main.cpp +++ b/src/Main.cpp @@ -1,6 +1,8 @@ // Test main method can go in here, can be useful for quick testing in the console. //#define _TEST +// TODO Fix this to work... It just dies? +// TODO Actually fix Linux support with CMake, make this build on Windows and Linux with CMake. #ifdef _TEST #include #include @@ -22,7 +24,7 @@ int main(int, char**) // I moved the DirectX9 code into the test/directx9_test.cpp file, #ifdef _DIRECTX9 -#include "test/directx9_test.h" +#include "./test/directx9_test.h" #endif //_DIRECTX9 #ifdef _OPENGL @@ -64,6 +66,9 @@ int main(int, char**) #ifdef _TEST1 #ifdef _DIRECTX9 + + // I forgot about making a test DLL for this project. + // DLL initialize HINSTANCE hinstDLL; DLLPROC HelloWorld; BOOL fFreeDLL; @@ -112,6 +117,8 @@ int main(int, char**) fFreeDLL = FreeLibrary(hinstDLL); } + // End DLL initialize + #endif //_DIRECTX9 #endif //_TEST1 diff --git a/menus/main_menu.cpp b/src/menus/main_menu.cpp similarity index 77% rename from menus/main_menu.cpp rename to src/menus/main_menu.cpp index 54099e2..608f255 100644 --- a/menus/main_menu.cpp +++ b/src/menus/main_menu.cpp @@ -4,7 +4,7 @@ #if _WIN32 #include "imgui_impl_win32.h" #include -#include "../util/keystates.h" +#include "./util/keystates.h" #endif #include @@ -14,16 +14,28 @@ #include #include -#include "../util/text_file_functions.h" -#include "../test/directx9_test.h" -#include "../util/text_functions.h" -#include "main_menu.h" + +// Utility functions +#include "./util/text_functions.h" +#include "./util/text_file_functions.h" + +// Test functions +#include "./test/directx9_test.h" +// New test +#include "./test/constructor_test.h" +// OpenGL +#include "./test/opengl_test.h" + +// Menus +#include "./menus/main_menu.h" // https://www.geeksforgeeks.org/macros-and-its-types-in-c-cpp/ // Test macros #define LIMIT 5 // Boolean values +// DirectX9Test + bool DirectX9Test::show_demo_window = false; bool DirectX9Test::button1_clicked = false; bool DirectX9Test::show_app_main_menu_bar = false; @@ -32,17 +44,48 @@ bool DirectX9Test::dark_mode = true; // I have dark mode enabled, I'll leave thi bool DirectX9Test::define_test = false; bool DirectX9Test::list_values = false; + +// OpenGLTest +bool OpenGLTest::show_demo_window = false; // // TODO Setup test for storing an array of pointers // TODO Try to play around with PS3 homebrew or Nintendo Switch homebrew. + +// This doesn't work +#ifdef _TEST1 +/// +/// Testing vsprintf_s +/// https://www.educative.io/answers/what-is-vsprintfs-in-c +/// +/// + +int call_vsprintf_s(char* buffer, size_t numberOfElements, char* format) +{ + int result; + va_list argList; + va_start(argList, format); + result = vsprintf_s(buffer, numberOfElements, format, argList); + va_end(argList); + return result; +} +#endif //_TEST1 + +// Enable this for test constructor once I get it fixed. +//#define _TEST1 + void MainMenu::MainMenuTest() { ImGuiIO& io = ImGui::GetIO(); (void)io; //if (ImGui::Begin("KCNet ImGui", nullptr, ImGuiWindowFlags_MenuBar)) //{ + + // Constructor test, kills ImGui. +#ifdef _TEST1 // TODO Fixme + Car car1("Ford", "Mustang", 1969); +#endif //_TEST1 // Menu bar if (ImGui::BeginMenuBar()) { @@ -60,7 +103,17 @@ void MainMenu::MainMenuTest() { ImGui::BulletText("Hello, this should show up."); ImGui::Separator(); - // This works + + // TODO Fix constructor test to work, this kills it instantly when opening test1. +#ifdef _TEST1 // TODO Fixme + ImGui::BulletText("Car brand: %s, Car type: %s, Car year: %s", car1.brand, car1.model, car1.year); + //ImGui::Text("Car brand: %s, Car type: %s, Car year: %s", car1.brand, car1.model, car1.year); +#endif //_TEST1 + +//#undef _TEST1 + + + // This works, freezes the window until clicked though. if (ImGui::Button("Windows Msg Box")) { MessageBox(NULL, TEXT("Hello From ImGui, a MessageBox"), @@ -127,9 +180,11 @@ void MainMenu::MainMenuTest() { // Dark mode toggle ///////////// +// Is this really needed? #ifndef _TEST #define _TEST #endif + #ifdef _TEST @@ -171,7 +226,14 @@ void MainMenu::MainMenuTest() { #undef _TEST // This works for toggling the demo window on and off +#ifdef _OPENGL + ImGui::Checkbox("Demo window", &OpenGLTest::show_demo_window); +#endif + +#ifdef _DIRECTX9 ImGui::Checkbox("Demo window", &DirectX9Test::show_demo_window); +#endif + // Possibly implement feature to read from a text file and write it to some output box. //ImGui::Text("Test"); @@ -289,7 +351,9 @@ void MainMenu::MainMenuTest() { //#undef _TEST + // Oh this is how I'm doing checkboxes. + // Lists out the values from the charTest ImGui::Checkbox("List values", &DirectX9Test::list_values); if (DirectX9Test::list_values) @@ -305,10 +369,31 @@ void MainMenu::MainMenuTest() { { ImGui::Text("Disabled"); } + // } ImGui::Separator(); + + // New + + const int vsprintBufferSize = 1024; + char* vsPrintBuffer = new char[vsprintBufferSize]; + if (ImGui::CollapsingHeader("test2")) + { + // Disabled, doesn't work. +#ifdef _TEST1 + if (ImGui::Button("Test")) + { + char format[] = "Hello %s"; + std::cout << "Hello" << std::endl; + + call_vsprintf_s(vsPrintBuffer, 15, format); + } +#endif //_TEST1 + } + // + // This works for a column, having multiple items on the same row. ImGui::Columns(2); ImGui::Text("Hello"); @@ -317,4 +402,5 @@ void MainMenu::MainMenuTest() { ImGui::Columns(1); //} -} \ No newline at end of file +} + diff --git a/menus/main_menu.h b/src/menus/main_menu.h similarity index 100% rename from menus/main_menu.h rename to src/menus/main_menu.h diff --git a/menus/pch.h b/src/menus/pch.h similarity index 100% rename from menus/pch.h rename to src/menus/pch.h diff --git a/menus/text_menu.cpp b/src/menus/text_menu.cpp similarity index 84% rename from menus/text_menu.cpp rename to src/menus/text_menu.cpp index c2b4944..5bf3cfd 100644 --- a/menus/text_menu.cpp +++ b/src/menus/text_menu.cpp @@ -4,7 +4,7 @@ #if _WIN32 #include "imgui_impl_win32.h" #include -#include "../util/keystates.h" +#include "./util/keystates.h" #endif #include @@ -14,9 +14,14 @@ #include #include -#include "../util/text_file_functions.h" -#include "../test/directx9_test.h" -#include "text_menu.h" +// Utility functions +#include "./util/text_file_functions.h" + +// Test functions +#include "./test/directx9_test.h" + +// Menus +#include "./menus/text_menu.h" bool show_text = false; diff --git a/menus/text_menu.h b/src/menus/text_menu.h similarity index 100% rename from menus/text_menu.h rename to src/menus/text_menu.h diff --git a/test/constructor_test.cpp b/src/test/constructor_test.cpp similarity index 100% rename from test/constructor_test.cpp rename to src/test/constructor_test.cpp diff --git a/test/constructor_test.h b/src/test/constructor_test.h similarity index 100% rename from test/constructor_test.h rename to src/test/constructor_test.h diff --git a/src/test/defines.h b/src/test/defines.h new file mode 100644 index 0000000..fe59347 --- /dev/null +++ b/src/test/defines.h @@ -0,0 +1,29 @@ +#pragma once + +#if _WIN32 +#include +#endif +// + +#ifdef _WIN32 +class Defines { +private: + // Defining all of these in a private class, they will be called under the public class. + // Kind of mimics my Java Messages file from KBP: https://github.com/kelson8/KBP/blob/master/src/main/java/net/Kelsoncraft/KBP/util/Messages.java + // https://stackoverflow.com/questions/50332569/why-i-am-getting-this-error-constexpr-is-not-valid-here + static constexpr wchar_t* TITLE = L"KCNet ImGui DirectX Test"; + + // TODO Add more of these + static constexpr wchar_t* MAIN_MENU_TITLE_ = L"Main Menu"; + static constexpr char* IMGUI_WINDOW_NAME_ = "KCNet ImGui"; + +public: + const wchar_t* window_title = TITLE; + const wchar_t* main_menu_title = MAIN_MENU_TITLE_; + const char* imgui_window_name = IMGUI_WINDOW_NAME_; +}; + + + + +#endif //_WIN32 \ No newline at end of file diff --git a/test/directx9_test.cpp b/src/test/directx9_test.cpp similarity index 65% rename from test/directx9_test.cpp rename to src/test/directx9_test.cpp index 4825b99..dc98847 100644 --- a/test/directx9_test.cpp +++ b/src/test/directx9_test.cpp @@ -30,7 +30,7 @@ #if _WIN32 #include "imgui_impl_win32.h" #include -#include "../util/keystates.h" +#include "./util/keystates.h" #endif // @@ -42,14 +42,30 @@ #include // Util -#include "../util/text_file_functions.h" -#include "../util/text_functions.h" +#include "./util/text_file_functions.h" +#include "./util/text_functions.h" // // Menus -#include "../menus/main_menu.h" -#include "../menus/text_menu.h" +#include "./menus/main_menu.h" +#include "./menus/text_menu.h" + +// Enums, menu title and etc. +// TODO Move into main source folder +#include "./test/defines.h" + + +#include "./util/helpers.h" + +// TODO Move into ../menus/http_menu.h +#include "./test/http_lib_test.h" // +// Switch to using helpers.cpp for helper functions. +//#define _TEST2 + +// TODO Create src folder for project, move source files into it +// TODO Possibly create headers folder for project. + // https://www.geeksforgeeks.org/macros-and-its-types-in-c-cpp/ // Test macros #define LIMIT 5 @@ -60,15 +76,20 @@ #endif // Data +// TODO Move into helpers.cpp or helpers.h +#ifndef _TEST2 //!_TEST2 static LPDIRECT3D9 g_pD3D = nullptr; static LPDIRECT3DDEVICE9 g_pd3dDevice = nullptr; static UINT g_ResizeWidth = 0, g_ResizeHeight = 0; static D3DPRESENT_PARAMETERS g_d3dpp = {}; +#endif //_!_TEST2 // Forward declarations of helper functions +#ifndef _TEST2 //!_TEST2 bool CreateDeviceD3D(HWND hWnd); void CleanupDeviceD3D(); void ResetDevice(); +#endif //!_TEST2 LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); static void HelpMarker(const char* desc) @@ -149,35 +170,86 @@ static void ShowWindow(bool* p_open) } -// Main code -void DirectX9Test::directX9Test() +static void CreateApplicationWindow() { - // Define custom booleans and features. - TextMenu *textMenu = new TextMenu(); - -#ifdef _TEST - //std::cout << testString1(); -#endif - - // Create application window - //ImGui_ImplWin32_EnableDpiAwareness(); - WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"KCNet ImGui", nullptr }; - ::RegisterClassExW(&wc); - HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"KCNet ImGui", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, nullptr, nullptr, wc.hInstance, nullptr); +} +static void InitializeD3D(HWND hwnd, WNDCLASSEXW wc) +{ // Initialize Direct3D + +#ifndef _TEST2 //!_TEST2 if (!CreateDeviceD3D(hwnd)) +#else + if (!Helpers::CreateDeviceD3D(hwnd)) +#endif //!_TEST2 { +#ifndef _TEST2 //!_TEST2 CleanupDeviceD3D(); +#else + Helpers::CleanupDeviceD3D(); +#endif //!_TEST2 ::UnregisterClassW(wc.lpszClassName, wc.hInstance); //return 1; } + +} + +static void ShowWindow(HWND hwnd) +{ // Show the window ::ShowWindow(hwnd, SW_SHOWDEFAULT); ::UpdateWindow(hwnd); +} +static void Render(ImVec4 clear_color) +{ +#ifndef _TEST2 //!_TEST2 + g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); + g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); + D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x * clear_color.w * 255.0f), (int)(clear_color.y * clear_color.w * 255.0f), (int)(clear_color.z * clear_color.w * 255.0f), (int)(clear_color.w * 255.0f)); + g_pd3dDevice->Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0); + if (g_pd3dDevice->BeginScene() >= 0) + { + ImGui::Render(); + ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); + g_pd3dDevice->EndScene(); + } + HRESULT result = g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr); + + // Handle loss of D3D9 device + if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) + +#else + Helpers::g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); + Helpers::g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); + Helpers::g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); + D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x * clear_color.w * 255.0f), (int)(clear_color.y * clear_color.w * 255.0f), (int)(clear_color.z * clear_color.w * 255.0f), (int)(clear_color.w * 255.0f)); + Helpers::g_pd3dDevice->Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0); + if (Helpers::g_pd3dDevice->BeginScene() >= 0) + { + ImGui::Render(); + ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); + Helpers::g_pd3dDevice->EndScene(); + } + HRESULT result = Helpers::g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr); + + // Handle loss of D3D9 device + if (result == D3DERR_DEVICELOST && Helpers::g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) +#endif //!_TEST2 + +#ifndef _TEST2 //!_TEST2 + ResetDevice(); +#else + Helpers::ResetDevice(); +#endif //_TEST2 +} + +void setupContext() +{ // Setup Dear ImGui context IMGUI_CHECKVERSION(); ImGui::CreateContext(); @@ -185,14 +257,6 @@ void DirectX9Test::directX9Test() io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsLight(); - - // Setup Platform/Renderer backends - ImGui_ImplWin32_Init(hwnd); - ImGui_ImplDX9_Init(g_pd3dDevice); - // Load Fonts // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. @@ -201,13 +265,64 @@ void DirectX9Test::directX9Test() // - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering. // - Read 'docs/FONTS.md' for more instructions and details. // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); + io.Fonts->AddFontDefault(); + io.Fonts->AddFontFromFileTTF("./lib/ImGui/misc/fonts/DroidSans.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf", 18.0f); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, nullptr, io.Fonts->GetGlyphRangesJapanese()); //IM_ASSERT(font != nullptr); +} + + + +// Main code + +// TODO Fix this not to break when imgui_impl_glfw.cpp and imgui_impl_glfw.h is included. +// Found the fix for OpenGL here: https://github.com/ocornut/imgui/issues/1299 +void DirectX9Test::directX9Test() +{ + + // Define custom booleans and features. + TextMenu *textMenu = new TextMenu(); + Defines* defines = new Defines(); + +#ifdef _TEST + //std::cout << testString1(); +#endif + + // Move window title into here. + // TODO Make this grab from a enum or something. + //const wchar_t* window_title = L"KCNet ImGui"; + + // Create application window + //ImGui_ImplWin32_EnableDpiAwareness(); + WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, defines->window_title, nullptr }; + ::RegisterClassExW(&wc); + HWND hwnd = ::CreateWindowW(wc.lpszClassName, defines->window_title, WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, nullptr, nullptr, wc.hInstance, nullptr); + + // Initialize Direct3D + InitializeD3D(hwnd, wc); + + // Show the window + ShowWindow(hwnd); + + // Setup Dear ImGui context + setupContext(); + + // Setup Dear ImGui style + ImGui::StyleColorsDark(); + //ImGui::StyleColorsLight(); + + // Setup Platform/Renderer backends + ImGui_ImplWin32_Init(hwnd); +#ifndef _TEST2 + ImGui_ImplDX9_Init(g_pd3dDevice); +#else + ImGui_ImplDX9_Init(Helpers::g_pd3dDevice); +#endif //!_TEST2 + // Our state //bool show_demo_window = true; @@ -239,13 +354,26 @@ void DirectX9Test::directX9Test() if (done) break; +#ifndef _TEST2 // Handle window resize (we don't resize directly in the WM_SIZE handler) if (g_ResizeWidth != 0 && g_ResizeHeight != 0) { g_d3dpp.BackBufferWidth = g_ResizeWidth; g_d3dpp.BackBufferHeight = g_ResizeHeight; g_ResizeWidth = g_ResizeHeight = 0; +#else + if (Helpers::g_ResizeWidth != 0 && Helpers::g_ResizeHeight != 0) + { + Helpers::g_d3dpp.BackBufferWidth = Helpers::g_ResizeWidth; + Helpers::g_d3dpp.BackBufferHeight = Helpers::g_ResizeHeight; + Helpers::g_ResizeWidth = Helpers::g_ResizeHeight = 0; +#endif //!_TEST2 + +#ifndef _TEST2 ResetDevice(); +#else + Helpers::ResetDevice(); +#endif //!_TEST2 } // Start the Dear ImGui frame @@ -261,9 +389,13 @@ void DirectX9Test::directX9Test() //#define _OLD_CODE - if (ImGui::Begin("KCNet ImGui", nullptr, ImGuiWindowFlags_MenuBar)) +//*************** +// Start of ImGui code +//*************** + //if (ImGui::Begin("KCNet ImGui", nullptr, ImGuiWindowFlags_MenuBar)) + if (ImGui::Begin(defines->imgui_window_name, nullptr, ImGuiWindowFlags_MenuBar)) { - + // Show the main menu MainMenu::MainMenuTest(); @@ -274,6 +406,27 @@ void DirectX9Test::directX9Test() textMenu->TextMainMenu(); } // End Text file functions test menu + + // HTTP Test menu, doesn't work +#ifdef _TEST1 + if (ImGui::CollapsingHeader("Http Test")) { + bool show_html = false; + // TODO Move this to using + // httpTestMenu->HttpTestMainMenu(); + ImGui::Checkbox("Test", &show_html); + + if (show_html) + { + //ImGui::Text(HttpTest::test); + HttpTest::test(); + } + + + + } +#endif //_TEST1 + // End http test menu + //if (ImGui::BeginMenu("My menu")) //{ @@ -288,37 +441,39 @@ void DirectX9Test::directX9Test() // End ImGui ImGui::End(); - // Rendering ImGui::EndFrame(); - g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); - D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x * clear_color.w * 255.0f), (int)(clear_color.y * clear_color.w * 255.0f), (int)(clear_color.z * clear_color.w * 255.0f), (int)(clear_color.w * 255.0f)); - g_pd3dDevice->Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0); - if (g_pd3dDevice->BeginScene() >= 0) - { - ImGui::Render(); - ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); - g_pd3dDevice->EndScene(); - } - HRESULT result = g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr); +//*************** +// End of ImGui code +//*************** - // Handle loss of D3D9 device - if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) - ResetDevice(); + // Rendering + + Render(clear_color); } + // Shutdown ImGui ImGui_ImplDX9_Shutdown(); ImGui_ImplWin32_Shutdown(); + // Destroy ImGui Context ImGui::DestroyContext(); + + // Cleanup D3D Device +#ifndef _TEST2 CleanupDeviceD3D(); +#else + Helpers::CleanupDeviceD3D(); +#endif + ::DestroyWindow(hwnd); ::UnregisterClassW(wc.lpszClassName, wc.hInstance); } +// End Main class + // Helper functions +#ifndef _TEST2 bool CreateDeviceD3D(HWND hWnd) { if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == nullptr) @@ -354,6 +509,8 @@ void ResetDevice() ImGui_ImplDX9_CreateDeviceObjects(); } +#endif //!_TEST2 + // Forward declare message handler from imgui_impl_win32.cpp extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); @@ -372,8 +529,14 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_SIZE: if (wParam == SIZE_MINIMIZED) return 0; +#ifndef _TEST2 g_ResizeWidth = (UINT)LOWORD(lParam); // Queue resize g_ResizeHeight = (UINT)HIWORD(lParam); +#else + Helpers::g_ResizeWidth = (UINT)LOWORD(lParam); // Queue resize + Helpers::g_ResizeHeight = (UINT)HIWORD(lParam); + +#endif //!_TEST2 return 0; case WM_SYSCOMMAND: if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu diff --git a/test/directx9_test.h b/src/test/directx9_test.h similarity index 100% rename from test/directx9_test.h rename to src/test/directx9_test.h diff --git a/test/opengl_test.cpp b/src/test/opengl_test.cpp similarity index 75% rename from test/opengl_test.cpp rename to src/test/opengl_test.cpp index 759118e..da023c2 100644 --- a/test/opengl_test.cpp +++ b/src/test/opengl_test.cpp @@ -3,6 +3,8 @@ // Moving opengl test into this file until I'm ready to mess with it. // 5-25-2024 @ 12:21PM +// TODO Fix this to work on Linux and Windows + // https://www.reddit.com/r/cpp/comments/16scrps/at_what_point_in_your_c_development_do_you/ #ifndef _OPENGL @@ -21,6 +23,7 @@ // - Documentation https://dearimgui.com/docs (same as your local docs/ folder). // - Introduction, links and more at the top of imgui.cpp +// ImGui and GLFW #include "imgui.h" #include "imgui_impl_glfw.h" #include "imgui_impl_opengl3.h" @@ -31,6 +34,19 @@ #endif #include // Will drag system OpenGL headers +// Test + +// This seems to be windows only +#if _WIN32 +#include +#endif //_WIN32 + +#include +#include +#include +// + + // [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers. // To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma. // Your own project should not be affected, as you are likely to link with a newer binary of GLFW that is adequate for your version of Visual Studio. @@ -43,34 +59,77 @@ #include "../libs/emscripten/emscripten_mainloop_stub.h" #endif +// Util +#include "../util/text_file_functions.h" +#include "../util/text_functions.h" +// +// Menus +#include "../menus/main_menu.h" +#include "../menus/text_menu.h" + + static void glfw_error_callback(int error, const char* description) { fprintf(stderr, "GLFW Error %d: %s\n", error, description); } +static void setupGlfw() +{ + +} + +static void Render(GLFWwindow* window, ImVec4 clear_color) +{ + ImGui::Render(); + int display_w, display_h; + glfwGetFramebufferSize(window, &display_w, &display_h); + glViewport(0, 0, display_w, display_h); + glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); + glClear(GL_COLOR_BUFFER_BIT); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + glfwSwapBuffers(window); +} + +static void setupContext() +{ + // Setup Dear ImGui context + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); (void)io; + io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls +} + // Main code void OpenGLTest::openGLTest() { + + // Define custom booleans and features. + TextMenu* textMenu = new TextMenu(); + const char* window_title = "KCNet ImGui OpenGL"; + glfwSetErrorCallback(glfw_error_callback); if (!glfwInit()) - // Decide GL+GLSL versions + + // TODO Fix below to work, for now I have hard-coded "#version 130" into ImGui_ImplOpenGL3_Init + // Decide GL+GLSL versions #if defined(IMGUI_IMPL_OPENGL_ES2) // GL ES 2.0 + GLSL 100 - const char* glsl_version = "#version 100"; + const char* glsl_version = "#version 100"; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); #elif defined(__APPLE__) // GL 3.2 + GLSL 150 - const char* glsl_version = "#version 150"; + const char* glsl_version = "#version 150"; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac #else // GL 3.0 + GLSL 130 - const char* glsl_version = "#version 130"; + const char* glsl_version = "#version 130"; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); //glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only @@ -78,29 +137,31 @@ void OpenGLTest::openGLTest() #endif // Create window with graphics context - GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+OpenGL3 example", nullptr, nullptr); - if (window == nullptr) + //GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+OpenGL3 example", nullptr, nullptr); + GLFWwindow* window = glfwCreateWindow(1280, 720, window_title, nullptr, nullptr); + if (window == nullptr) { + return; + } glfwMakeContextCurrent(window); glfwSwapInterval(1); // Enable vsync - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls + // Setup ImGui Context. + setupContext(); // Setup Dear ImGui style ImGui::StyleColorsDark(); //ImGui::StyleColorsLight(); // Setup Platform/Renderer backends + // Initialize ImGui + ImGui_ImplGlfw_InitForOpenGL(window, true); #ifdef __EMSCRIPTEN__ ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback("#canvas"); #endif //ImGui_ImplOpenGL3_Init(glsl_version); ImGui_ImplOpenGL3_Init("#version 130"); + // // Load Fonts // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. @@ -120,11 +181,13 @@ void OpenGLTest::openGLTest() //IM_ASSERT(font != nullptr); // Our state - bool show_demo_window = true; + //bool show_demo_window = true; bool show_another_window = false; ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); + // Show window // Main loop + bool done = false; #ifdef __EMSCRIPTEN__ // For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file. // You may manually call LoadIniSettingsFromMemory() to load settings from your own storage. @@ -150,6 +213,28 @@ void OpenGLTest::openGLTest() if (show_demo_window) ImGui::ShowDemoWindow(&show_demo_window); + + // TODO Make this part compatible between the OpenGL Test and the + // DirectX9 test, I should be able to put this into a utilites file somewhere. + +#define _TEST + +#ifdef _TEST + if (ImGui::Begin("KCNet ImGui", nullptr, ImGuiWindowFlags_MenuBar)) + { + // Show the main menu + MainMenu::MainMenuTest(); + + // Text file functions test menu + if (ImGui::CollapsingHeader("Text File Functions")) + { + textMenu->TextMainMenu(); + } + } + + // End ImGui + ImGui::End(); +#else // 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window. { static float f = 0.0f; @@ -182,19 +267,24 @@ void OpenGLTest::openGLTest() show_another_window = false; ImGui::End(); } +#endif // Rendering - ImGui::Render(); - int display_w, display_h; - glfwGetFramebufferSize(window, &display_w, &display_h); - glViewport(0, 0, display_w, display_h); - glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); - glClear(GL_COLOR_BUFFER_BIT); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + // Test with local Render function + Render(window, clear_color); - glfwSwapBuffers(window); + //ImGui::Render(); + //int display_w, display_h; + //glfwGetFramebufferSize(window, &display_w, &display_h); + //glViewport(0, 0, display_w, display_h); + //glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); + //glClear(GL_COLOR_BUFFER_BIT); + //ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + //glfwSwapBuffers(window); ImGui::EndFrame(); + + } #ifdef __EMSCRIPTEN__ EMSCRIPTEN_MAINLOOP_END; diff --git a/src/test/opengl_test.h b/src/test/opengl_test.h new file mode 100644 index 0000000..6a03a3d --- /dev/null +++ b/src/test/opengl_test.h @@ -0,0 +1,10 @@ +#pragma once +class OpenGLTest{ +public: + static void openGLTest(); + static bool show_demo_window; + + // To enable OpenGL Test: + // Include these two files into the project: + // imgui_impl_glfw.cpp and imgui_impl_glfw.h +}; \ No newline at end of file diff --git a/src/util/helpers.cpp b/src/util/helpers.cpp new file mode 100644 index 0000000..7bc42c1 --- /dev/null +++ b/src/util/helpers.cpp @@ -0,0 +1,50 @@ +#include "helpers.h" +#include + +#include "imgui.h" +#include "imgui_impl_dx9.h" + +// Data +static LPDIRECT3D9 g_pD3D = nullptr; +static LPDIRECT3DDEVICE9 g_pd3dDevice = nullptr; +static UINT g_ResizeWidth = 0, g_ResizeHeight = 0; +static D3DPRESENT_PARAMETERS g_d3dpp = {}; + +// TODO Figure out if I can move these DirectX helpers into here. +// If I define _TEST2 into directx9_test.cpp it'll switch everything to using this file +// It crashes because g_d3dpp is a nullptr though + +bool Helpers::CreateDeviceD3D(HWND hWnd) +{ + if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == nullptr) + return false; + + // Create the D3DDevice + ZeroMemory(&g_d3dpp, sizeof(g_d3dpp)); + g_d3dpp.Windowed = TRUE; + g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + g_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; // Need to use an explicit format with alpha if needing per-pixel alpha composition. + g_d3dpp.EnableAutoDepthStencil = TRUE; + g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16; + g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // Present with vsync + //g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync, maximum unthrottled framerate + if (g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0) + return false; + + return true; +} + +void Helpers::CleanupDeviceD3D() +{ + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = nullptr; } + if (g_pD3D) { g_pD3D->Release(); g_pD3D = nullptr; } +} + +void Helpers::ResetDevice() +{ + ImGui_ImplDX9_InvalidateDeviceObjects(); + HRESULT hr = g_pd3dDevice->Reset(&g_d3dpp); + if (hr == D3DERR_INVALIDCALL) + IM_ASSERT(0); + ImGui_ImplDX9_CreateDeviceObjects(); +} \ No newline at end of file diff --git a/src/util/helpers.h b/src/util/helpers.h new file mode 100644 index 0000000..5ce9db2 --- /dev/null +++ b/src/util/helpers.h @@ -0,0 +1,32 @@ +#pragma once +#ifdef _WIN32 +#include +#endif //_WIN32 + +// Oops I named the source file with a .c extension instead of .cpp +// No wonder this didn't work. +// https://stackoverflow.com/questions/12524168/resolving-found-at-file-scope-missing-function-header-in-vs2010-c + +class Helpers { +public: +#ifdef _WIN32 + static bool CreateDeviceD3D(HWND hWnd); + static void CleanupDeviceD3D(); + static void Helpers::ResetDevice(); + +#ifdef _TEST2 + static LPDIRECT3D9 g_pD3D; + static LPDIRECT3DDEVICE9 g_pd3dDevice; + static UINT g_ResizeWidth; + static UINT g_ResizeHeight; + static D3DPRESENT_PARAMETERS g_d3dpp; + +#endif //_TEST2 + +#else + // Will this work on Linux or Mac? I don't think DirectX does. + static bool CreateDeviceD3D(); +#endif +}; + + diff --git a/util/keystates.cpp b/src/util/keystates.cpp similarity index 100% rename from util/keystates.cpp rename to src/util/keystates.cpp diff --git a/util/keystates.h b/src/util/keystates.h similarity index 100% rename from util/keystates.h rename to src/util/keystates.h diff --git a/util/text_file_functions.cpp b/src/util/text_file_functions.cpp similarity index 74% rename from util/text_file_functions.cpp rename to src/util/text_file_functions.cpp index c6f2da4..60a2498 100644 --- a/util/text_file_functions.cpp +++ b/src/util/text_file_functions.cpp @@ -62,6 +62,8 @@ void TextFileFunctions::readTextFile(std::string file) // This works // Some code from Google AI:/// + +// TODO Fix this to work on OpenGL test, it only works on the DirectX9 one. void TextFileFunctions::outputTextFileContents(const char* filePath) { std::ifstream myfile(filePath); @@ -87,8 +89,6 @@ void TextFileFunctions::outputTextFileContents(const char* filePath) { } } -// Add test function for this, I need to figure out how to return an array like this. -#ifdef _TEST // This prints the text file output to the console but spams it, I probably won't use this much. void TextFileFunctions::printTextOutput(std::string file) { @@ -127,41 +127,3 @@ void TextFileFunctions::printTextOutput(std::string file) // //} - -#else - -//static std::string testString1(std::string file std::string text) -//std::string TextFileFunctions::testString1(std::string file) - -// This doesn't fully work yet, once I finish it, it'll show up on a ImGui tab. -//std::string TextFileFunctions::printTextOutput(std::string file) -void TextFileFunctions::printTextOutput(std::string file) -{ - std::string line; - std::ifstream myfile(file); - - if (TextFileFunctions::fileExistCheck(file)) - { - if (myfile.is_open()) - { - while (std::getline(myfile, line)) - { - std::cout << line << '\n'; - //return line; - } - - //return line; - myfile.close(); - } - else - { - std::cout << "Unable to open file!"; - } - } - else - { - std::cout << "File doesn't exist!"; - } -} -#endif //_TEST - diff --git a/util/text_file_functions.h b/src/util/text_file_functions.h similarity index 100% rename from util/text_file_functions.h rename to src/util/text_file_functions.h diff --git a/util/text_functions.cpp b/src/util/text_functions.cpp similarity index 100% rename from util/text_functions.cpp rename to src/util/text_functions.cpp diff --git a/util/text_functions.h b/src/util/text_functions.h similarity index 100% rename from util/text_functions.h rename to src/util/text_functions.h diff --git a/test/opengl_test.h b/test/opengl_test.h deleted file mode 100644 index b400ed4..0000000 --- a/test/opengl_test.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -class OpenGLTest{ -public: - static void openGLTest(); -}; \ No newline at end of file