Add trans mode
This commit is contained in:
		
							parent
							
								
									d05147fa69
								
							
						
					
					
						commit
						2d1ba5b90a
					
				
					 1 changed files with 35 additions and 9 deletions
				
			
		
							
								
								
									
										44
									
								
								src/main.cpp
									
										
									
									
									
								
							
							
						
						
									
										44
									
								
								src/main.cpp
									
										
									
									
									
								
							|  | @ -7,6 +7,7 @@ | |||
| #include <sdbus-c++/Types.h> | ||||
| #define IMGUI_DEFINE_MATH_OPERATORS | ||||
| #include "raylib.h" | ||||
| #include "rlgl.h" | ||||
| #include "raymath.h" | ||||
| #include <optional> | ||||
| #include <unordered_map> | ||||
|  | @ -23,6 +24,7 @@ | |||
| #include <curl/curl.h> | ||||
| #include <fstream> | ||||
| #include <iostream> | ||||
| #include <rlgl.h> | ||||
| #include <sdbus-c++/sdbus-c++.h> | ||||
| #include <string> | ||||
| extern "C" { | ||||
|  | @ -231,14 +233,21 @@ float ScaleToFit(Vector2 src, Vector2 dst) { | |||
|     // return Vector2Scale(src, ratio);
 | ||||
| } | ||||
| 
 | ||||
| void GenCircleOverlay(RenderTexture tex) { | ||||
| void GenCircleOverlay(RenderTexture tex, bool trans) { | ||||
|     BeginTextureMode(tex); | ||||
|     ClearBackground(BLACK); | ||||
|     if (trans) { | ||||
|         ClearBackground(WHITE); | ||||
|     } else { | ||||
|         ClearBackground(BLACK); | ||||
|     } | ||||
|     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(); | ||||
|     EndTextureMode(); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| int main(int argc, char *argv[]) { | ||||
|  | @ -248,11 +257,13 @@ int main(int argc, char *argv[]) { | |||
|     int screenHeight = 800; | ||||
| 
 | ||||
|     // 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"); | ||||
|     SetTargetFPS(244); | ||||
|     rlImGuiSetup(true); | ||||
|     ImGui::GetStyle().AntiAliasedLinesUseTex = false; | ||||
|     //SetWindowState(FLAG_WINDOW_UNDECORATED);
 | ||||
| 
 | ||||
|     TestC(); | ||||
|     TestCPPFunc(); | ||||
|  | @ -272,16 +283,17 @@ int main(int argc, char *argv[]) { | |||
|     DiscObject disc(0); | ||||
|     // Main game loop
 | ||||
|     bool goodstate = false; | ||||
|     bool trans = false; | ||||
| 
 | ||||
|     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
 | ||||
|     { | ||||
|         if (IsWindowResized()) { | ||||
|             UnloadRenderTexture(recordoverlay); | ||||
|             recordoverlay = LoadRenderTexture(GetScreenWidth(), GetScreenHeight()); | ||||
|             GenCircleOverlay(recordoverlay); | ||||
|             GenCircleOverlay(recordoverlay, trans); | ||||
|         } | ||||
|         if (GetTime() > lasttime + 3) { | ||||
|             lasttime = GetTime(); | ||||
|  | @ -289,8 +301,11 @@ int main(int argc, char *argv[]) { | |||
|         } | ||||
| 
 | ||||
|         BeginDrawing(); | ||||
|         ClearBackground(BLACK); | ||||
| 
 | ||||
|         if (trans) { | ||||
|             ClearBackground((Color) {0,0,0,0}); | ||||
|         } else { | ||||
|             ClearBackground(BLACK); | ||||
|         } | ||||
|         Vector2 winwidth = (Vector2){(float)GetScreenWidth(), (float)GetScreenHeight()}; | ||||
|         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 (trans) { | ||||
|                 rlSetBlendFactors(1,1, 0x800B); | ||||
|                 BeginBlendMode(BLEND_CUSTOM); | ||||
|             } | ||||
|             DrawTexture(recordoverlay.texture, 0, 0 , WHITE); | ||||
|             if (trans) { | ||||
|                 EndBlendMode(); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         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)) { | ||||
|                         disc.Activate(); | ||||
|                     } | ||||
|                     if (ImGui::MenuItem("Trans Mode !!", nullptr, trans)) { | ||||
|                         trans = !trans; | ||||
|                         GenCircleOverlay(recordoverlay, trans); | ||||
|                     } | ||||
|                     ImGui::EndMenu(); | ||||
|                 } | ||||
|                 ImGui::EndMainMenuBar(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue