Add trans mode

This commit is contained in:
IXtreme 2025-01-02 00:54:02 -05:00
parent d05147fa69
commit 2d1ba5b90a

View file

@ -7,6 +7,7 @@
#include <sdbus-c++/Types.h> #include <sdbus-c++/Types.h>
#define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS
#include "raylib.h" #include "raylib.h"
#include "rlgl.h"
#include "raymath.h" #include "raymath.h"
#include <optional> #include <optional>
#include <unordered_map> #include <unordered_map>
@ -23,6 +24,7 @@
#include <curl/curl.h> #include <curl/curl.h>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <rlgl.h>
#include <sdbus-c++/sdbus-c++.h> #include <sdbus-c++/sdbus-c++.h>
#include <string> #include <string>
extern "C" { extern "C" {
@ -231,14 +233,21 @@ float ScaleToFit(Vector2 src, Vector2 dst) {
// return Vector2Scale(src, ratio); // return Vector2Scale(src, ratio);
} }
void GenCircleOverlay(RenderTexture tex) { void GenCircleOverlay(RenderTexture tex, bool trans) {
BeginTextureMode(tex); BeginTextureMode(tex);
ClearBackground(BLACK); if (trans) {
ClearBackground(WHITE);
} else {
ClearBackground(BLACK);
}
BeginBlendMode(BLEND_SUBTRACT_COLORS); BeginBlendMode(BLEND_SUBTRACT_COLORS);
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, std::min(GetScreenWidth()/2, GetScreenHeight()/2), (Color{0,0,0,0})); if (trans) {
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, std::min(GetScreenWidth()/2, GetScreenHeight()/2), WHITE);
} else {
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, std::min(GetScreenWidth()/2, GetScreenHeight()/2), (Color{0,0,0,0}));
}
EndBlendMode(); EndBlendMode();
EndTextureMode(); EndTextureMode();
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
@ -248,11 +257,13 @@ int main(int argc, char *argv[]) {
int screenHeight = 800; int screenHeight = 800;
// SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE); // SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE);
SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE); //SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE);
SetConfigFlags(FLAG_WINDOW_TRANSPARENT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE);
InitWindow(screenWidth, screenHeight, "raylib-Extras [ImGui] example - Docking"); InitWindow(screenWidth, screenHeight, "raylib-Extras [ImGui] example - Docking");
SetTargetFPS(244); SetTargetFPS(244);
rlImGuiSetup(true); rlImGuiSetup(true);
ImGui::GetStyle().AntiAliasedLinesUseTex = false; ImGui::GetStyle().AntiAliasedLinesUseTex = false;
//SetWindowState(FLAG_WINDOW_UNDECORATED);
TestC(); TestC();
TestCPPFunc(); TestCPPFunc();
@ -272,16 +283,17 @@ int main(int argc, char *argv[]) {
DiscObject disc(0); DiscObject disc(0);
// Main game loop // Main game loop
bool goodstate = false; bool goodstate = false;
bool trans = false;
RenderTexture recordoverlay = LoadRenderTexture(screenWidth, screenHeight); RenderTexture recordoverlay = LoadRenderTexture(screenWidth, screenHeight);
GenCircleOverlay(recordoverlay); GenCircleOverlay(recordoverlay, trans);
while (!WindowShouldClose() && run) // Detect window close button or ESC key, or a quit from the menu while (!WindowShouldClose() && run) // Detect window close button or ESC key, or a quit from the menu
{ {
if (IsWindowResized()) { if (IsWindowResized()) {
UnloadRenderTexture(recordoverlay); UnloadRenderTexture(recordoverlay);
recordoverlay = LoadRenderTexture(GetScreenWidth(), GetScreenHeight()); recordoverlay = LoadRenderTexture(GetScreenWidth(), GetScreenHeight());
GenCircleOverlay(recordoverlay); GenCircleOverlay(recordoverlay, trans);
} }
if (GetTime() > lasttime + 3) { if (GetTime() > lasttime + 3) {
lasttime = GetTime(); lasttime = GetTime();
@ -289,8 +301,11 @@ int main(int argc, char *argv[]) {
} }
BeginDrawing(); BeginDrawing();
ClearBackground(BLACK); if (trans) {
ClearBackground((Color) {0,0,0,0});
} else {
ClearBackground(BLACK);
}
Vector2 winwidth = (Vector2){(float)GetScreenWidth(), (float)GetScreenHeight()}; Vector2 winwidth = (Vector2){(float)GetScreenWidth(), (float)GetScreenHeight()};
Vector2 imagesize = (Vector2){(float)current_player.tex.tex.width, (float)current_player.tex.tex.height}; Vector2 imagesize = (Vector2){(float)current_player.tex.tex.width, (float)current_player.tex.tex.height};
@ -370,7 +385,14 @@ int main(int argc, char *argv[]) {
} }
if (disc.active) { if (disc.active) {
if (trans) {
rlSetBlendFactors(1,1, 0x800B);
BeginBlendMode(BLEND_CUSTOM);
}
DrawTexture(recordoverlay.texture, 0, 0 , WHITE); DrawTexture(recordoverlay.texture, 0, 0 , WHITE);
if (trans) {
EndBlendMode();
}
} }
if (IsKeyPressed(KEY_SLASH) || IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) { if (IsKeyPressed(KEY_SLASH) || IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) {
@ -408,6 +430,10 @@ int main(int argc, char *argv[]) {
if (ImGui::MenuItem("Record Spin !!", nullptr, disc.active)) { if (ImGui::MenuItem("Record Spin !!", nullptr, disc.active)) {
disc.Activate(); disc.Activate();
} }
if (ImGui::MenuItem("Trans Mode !!", nullptr, trans)) {
trans = !trans;
GenCircleOverlay(recordoverlay, trans);
}
ImGui::EndMenu(); ImGui::EndMenu();
} }
ImGui::EndMainMenuBar(); ImGui::EndMainMenuBar();