(Feat): Demo dmx engine
This commit is contained in:
parent
f8341ff8f2
commit
6e0cc49826
77
src/main.cpp
77
src/main.cpp
@ -2,20 +2,35 @@
|
||||
#include "rlImGui.h"
|
||||
#include "panel.h"
|
||||
#include "imgui.h"
|
||||
#include "dmx.h"
|
||||
#include "DmxWriter.h"
|
||||
#include "BasicLogger.h"
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
|
||||
void DrawImGui();
|
||||
|
||||
int main() {
|
||||
DMXEngine dmxEngine("\\\\.\\COM3");
|
||||
dmxEngine.start();
|
||||
DmxWriter dmxWriter(dmxEngine);
|
||||
|
||||
// Initialize random seed
|
||||
srand(static_cast<unsigned int>(time(0)));
|
||||
|
||||
const int screenWidth = 1920;
|
||||
const int screenHeight = 1080;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "DMX Raylib UI");
|
||||
SetTargetFPS(60);
|
||||
SetTargetFPS(165);
|
||||
|
||||
rlImGuiSetup(true); // Use true for dark theme, false for light theme
|
||||
rlImGuiSetup(true);
|
||||
|
||||
Panel timelinePanel = {{0, 0, screenWidth * 0.75f, screenHeight * 0.6f}, "Timeline", LIGHTGRAY, DARKGRAY, true};
|
||||
Panel propertiesPanel = {{screenWidth * 0.75f, 0, screenWidth * 0.25f, screenHeight}, "Properties", LIGHTGRAY, DARKGRAY, true};
|
||||
|
||||
std::string randomColors;
|
||||
|
||||
while (!WindowShouldClose()) {
|
||||
timelinePanel.Update();
|
||||
propertiesPanel.Update();
|
||||
@ -23,20 +38,68 @@ int main() {
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
rlImGuiBegin();
|
||||
bool open = true;
|
||||
ImGui::ShowDemoWindow(&open);
|
||||
rlImGuiEnd();
|
||||
|
||||
if (timelinePanel.isVisible) timelinePanel.Draw();
|
||||
if (propertiesPanel.isVisible) propertiesPanel.Draw();
|
||||
|
||||
rlImGuiBegin();
|
||||
|
||||
ImGui::Begin("Random Color Clicker");
|
||||
if (ImGui::Button("Random Color!")) {
|
||||
unsigned char r = static_cast<unsigned char>(rand() % 256);
|
||||
unsigned char g = static_cast<unsigned char>(rand() % 256);
|
||||
unsigned char b = static_cast<unsigned char>(rand() % 256);
|
||||
|
||||
dmxWriter.setChannel(0, r);
|
||||
dmxWriter.setChannel(1, g);
|
||||
dmxWriter.setChannel(2, b);
|
||||
|
||||
randomColors = "Sent DMX Color - R: " + std::to_string(r) +
|
||||
", G: " + std::to_string(g) +
|
||||
", B: " + std::to_string(b);
|
||||
}
|
||||
ImGui::Text("%s", randomColors.c_str());
|
||||
|
||||
// End the window
|
||||
ImGui::End();
|
||||
|
||||
rlImGuiEnd();
|
||||
|
||||
// Draw FPS on the screen
|
||||
DrawFPS(3, screenHeight - 20);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
|
||||
BasicLogger::Log(DebugP, "Stopping DMX Engine...");
|
||||
dmxEngine.stop();
|
||||
|
||||
BasicLogger::Log(DebugP, "Shutting down rlImGui...");
|
||||
rlImGuiShutdown();
|
||||
|
||||
BasicLogger::Log(DebugP, "Closing Window...");
|
||||
CloseWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DrawImGui() {
|
||||
rlImGuiBegin();
|
||||
|
||||
// Begin a new window with a title
|
||||
ImGui::Begin("My Custom Window");
|
||||
|
||||
// Add a button with a label
|
||||
if (ImGui::Button("Click Me"))
|
||||
{
|
||||
// Action to be performed when the button is clicked
|
||||
ImGui::Text("Button Clicked!");
|
||||
}
|
||||
|
||||
// End the window
|
||||
ImGui::End();
|
||||
|
||||
// bool open = true;
|
||||
// ImGui::ShowDemoWindow(&open);
|
||||
|
||||
rlImGuiEnd();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user