Remove todo

This commit is contained in:
Braedon Lewis 2023-04-13 08:28:40 -04:00
parent 9ef6d53382
commit 14a369918c
4 changed files with 92 additions and 24 deletions

View file

@ -4,6 +4,7 @@
# Rider ignored files # Rider ignored files
/projectSettingsUpdater.xml /projectSettingsUpdater.xml
/modules.xml /modules.xml
/.idea.raylib-beef.iml
/contentModel.xml /contentModel.xml
# Editor-based HTTP Client requests # Editor-based HTTP Client requests
/httpRequests/ /httpRequests/

View file

@ -39,13 +39,6 @@ namespace RaylibBeefGenerator
private static string Namespace = "Raylib"; private static string Namespace = "Raylib";
#endregion #endregion
// TODO:
// Defines
// Enums
// Other things like RLGL and stuff.
// Output generated code to actual directory.
// Organize Beef project.
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.WriteLine($"Generating files at {OutputDir}"); Console.WriteLine($"Generating files at {OutputDir}");

View file

@ -3,6 +3,5 @@ Dependencies = {corlib = "*", raylib-beef = "*"}
[Project] [Project]
Name = "example" Name = "example"
TargetType = "BeefGUIApplication"
StartupObject = "raylib_test.Program" StartupObject = "raylib_test.Program"
DefaultNamespace = "raylib_test" DefaultNamespace = "raylib_test"

View file

@ -1,43 +1,118 @@
using System; using System;
using System.Collections;
using Raylib; using Raylib;
namespace raylib_test; namespace raylib_test;
class Program class Program
{ {
struct Bunny
{
public Vector2 position;
public Vector2 speed;
public Color color;
}
public static float Range(int min, int max)
{
var returnC = (float)GetRandomValue(0, max);
if (returnC < max / 2)
returnC = Raymath.Lerp(min, max, Raymath.Normalize(returnC, 0, 125));
else
returnC = Raymath.Lerp(min, max, Raymath.Normalize(returnC, max / 2, 250));
// Console.WriteLine(returnC);
return returnC;
}
public static int Main(String[] args) public static int Main(String[] args)
{ {
SetConfigFlags(4); int screenWidth = 800;
InitWindow(800, 600, "Raylib Beef 4.5"); int screenHeight = 600;
SetConfigFlags((int)ConfigFlags.FLAG_VSYNC_HINT | (int)ConfigFlags.FLAG_WINDOW_RESIZABLE);
InitWindow(screenWidth, screenHeight, "Raylib Beef 4.5");
var texBunny = LoadTexture(@"C:\Users\Braedon\Downloads\wabbit_alpha.png");
var bunnies = new List<Bunny>();
var beefMain = Color(165, 47, 78, 255); var beefMain = Color(165, 47, 78, 255);
var beefOutline = Color(243, 157, 157, 255); var beefOutline = Color(243, 157, 157, 255);
while (!WindowShouldClose()) while (!WindowShouldClose())
{ {
if (IsMouseButtonDown((int)MouseButton.MOUSE_BUTTON_LEFT))
{
for (int i = 0; i < 100; i++)
{
if (bunnies.Count < 50000)
{
var newBunny = Bunny();
newBunny.position = GetMousePosition();
newBunny.speed.x = Range(-250, 250)/60.0f;
newBunny.speed.y = Range(-250, 250)/60.0f;
newBunny.color = Color((uint8)GetRandomValue(50, 240), (uint8)GetRandomValue(80, 240), (uint8)GetRandomValue(100, 240), 255);
bunnies.Add(newBunny);
}
}
}
for (int i = 0; i < bunnies.Count; i++)
{
/*if (((bunnies[i].position.x + texBunny.width/2) > GetScreenWidth()) ||
((bunnies[i].position.x + texBunny.width/2) < 0)) bunnies[i].speed.x *= -1;
if (((bunnies[i].position.y + texBunny.height/2) > GetScreenHeight()) ||
((bunnies[i].position.y + texBunny.height/2 - 40) < 0)) bunnies[i].speed.y *= -1;*/
if (
(bunnies[i].position.x < 0) ||
(bunnies[i].position.x > (GetScreenWidth() - 32)) ||
(bunnies[i].position.y > GetScreenHeight() - 32) ||
(bunnies[i].position.y < 0))
{
bunnies.RemoveAtFast(i);
i--;
continue;
}
bunnies[i].position.x += bunnies[i].speed.x;
bunnies[i].position.y += bunnies[i].speed.y;
}
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawCircle(GetMouseX(), GetMouseY(), 20, beefOutline);
DrawRectangle(GetScreenWidth() / 2 - 128, GetScreenHeight() / 2 - 128, 256, 256, beefOutline); for (int i = 0; i < bunnies.Count; i++)
DrawRectangle(GetScreenWidth() / 2 - 112, GetScreenHeight() / 2 - 112, 224, 224, beefMain); {
// NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS),
// a draw call is launched and buffer starts being filled again;
// before issuing a draw call, updated vertex data from internal CPU buffer is send to GPU...
// Process of sending data is costly and it could happen that GPU data has not been completely
// processed for drawing while new data is tried to be sent (updating current in-use buffers)
// it could generates a stall and consequently a frame drop, limiting the number of drawn bunnies
DrawTexture(texBunny, (int)bunnies[i].position.x, (int)bunnies[i].position.y, bunnies[i].color);
}
DrawCircle(GetMouseX(), GetMouseY(), 10, beefMain);
DrawRectangle(0, 0, GetScreenWidth(), 40, BLACK);
DrawText(scope $"bunnies: {bunnies.Count}", 120, 10, 20, GREEN);
DrawText(scope $"batched draw calls: {1 + bunnies.Count / 50000}", 320, 10, 20, MAROON);
DrawText("raylib", GetScreenWidth() / 2 - 44, GetScreenHeight() / 2, 50, beefOutline); DrawFPS(10, 10);
DrawText("beef", GetScreenWidth() / 2 - 62, GetScreenHeight() / 2 + 46, 50, beefOutline);
DrawRectangle(GetScreenWidth() / 2 + 54, GetScreenHeight() / 2 + 54, 42, 42, beefOutline);
DrawRectangle(GetScreenWidth() / 2 + 62, GetScreenHeight() / 2 + 62, 26, 26, RAYWHITE);
DrawText(scope $"{Raymath.Lerp(0, 20, 10)}", 20, 60, 20, DARKGREEN);
DrawFPS(20, 20);
EndDrawing(); EndDrawing();
} }
delete bunnies;
UnloadTexture(texBunny);
CloseWindow(); CloseWindow();
return 0; return 0;