Initial commit
This commit is contained in:
commit
c29245c470
21
.vscode/c_cpp_properties.json
vendored
Normal file
21
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/inc",
|
||||||
|
"${workspaceFolder}/raylib/src"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"GRAPHICS_API_OPENGL_33",
|
||||||
|
"PLATFORM_DESKTOP",
|
||||||
|
"_GNU_SOURCE"
|
||||||
|
],
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "c23",
|
||||||
|
"cppStandard": "gnu++23",
|
||||||
|
"intelliSenseMode": "linux-gcc-x64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
33
.vscode/launch.json
vendored
Normal file
33
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/main",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
49
.vscode/settings.json
vendored
Normal file
49
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"iostream": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp"
|
||||||
|
}
|
||||||
|
}
|
21
.vscode/tasks.json
vendored
Normal file
21
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make",
|
||||||
|
"args": [
|
||||||
|
"main"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "clean",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make",
|
||||||
|
"args": [
|
||||||
|
"clean"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
63
Makefile
Normal file
63
Makefile
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
RAYFLAGS= -D_GNU_SOURCE -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33
|
||||||
|
RAYINCLUDE= -Iraylib/src -Iraylib/src/external/glfw/include -Iraylib/src/external/glfw/deps/mingw
|
||||||
|
RAYOBJECTS= obj/rcore.o obj/rshapes.o obj/rtextures.o obj/rtext.o obj/utils.o obj/rglfw.o obj/rmodels.o obj/raudio.o
|
||||||
|
|
||||||
|
#RAYOPT= -O3
|
||||||
|
RAYOPT= -ggdb
|
||||||
|
|
||||||
|
CPPFLAGS= -std=c++23
|
||||||
|
|
||||||
|
all: setup main run
|
||||||
|
|
||||||
|
setup:
|
||||||
|
if [ ! -d "raylib" ]; then \
|
||||||
|
git clone --depth 1 --branch "5.0" git@github.com:raysan5/raylib.git; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
$(shell mkdir -p obj)
|
||||||
|
|
||||||
|
obj/rcore.o: raylib/src/rcore.c
|
||||||
|
gcc -c $< -o $@ $(RAYOPT) $(RAYFLAGS) $(RAYINCLUDE)
|
||||||
|
|
||||||
|
obj/rshapes.o: raylib/src/rshapes.c
|
||||||
|
gcc -c $< -o $@ $(RAYOPT) $(RAYFLAGS) $(RAYINCLUDE)
|
||||||
|
|
||||||
|
obj/rtextures.o: raylib/src/rtextures.c
|
||||||
|
gcc -c $< -o $@ $(RAYOPT) $(RAYFLAGS) $(RAYINCLUDE)
|
||||||
|
|
||||||
|
obj/rtext.o: raylib/src/rtext.c
|
||||||
|
gcc -c $< -o $@ $(RAYOPT) $(RAYFLAGS) $(RAYINCLUDE)
|
||||||
|
|
||||||
|
obj/utils.o: raylib/src/utils.c
|
||||||
|
gcc -c $< -o $@ $(RAYOPT) $(RAYFLAGS) $(RAYINCLUDE)
|
||||||
|
|
||||||
|
obj/rglfw.o: raylib/src/rglfw.c
|
||||||
|
gcc -c $< -o $@ $(RAYOPT) $(RAYFLAGS) $(RAYINCLUDE)
|
||||||
|
|
||||||
|
obj/rmodels.o: raylib/src/rmodels.c
|
||||||
|
gcc -c $< -o $@ $(RAYOPT) $(RAYFLAGS) $(RAYINCLUDE)
|
||||||
|
|
||||||
|
obj/raudio.o: raylib/src/raudio.c
|
||||||
|
gcc -c $< -o $@ $(RAYOPT) $(RAYFLAGS) $(RAYINCLUDE)
|
||||||
|
|
||||||
|
SRCDIR = src
|
||||||
|
OBJDIR = obj
|
||||||
|
INCLUDE = -Iinc
|
||||||
|
|
||||||
|
SOURCES = $(wildcard $(SRCDIR)/*.cpp)
|
||||||
|
|
||||||
|
OBJECTS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SOURCES))
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
|
||||||
|
$(CC) -c $< -o $@ $(RAYOPT) $(RAYINCLUDE) $(INCLUDE) $(CFLAGS)
|
||||||
|
|
||||||
|
main: main.cpp setup $(RAYOBJECTS) $(OBJECTS)
|
||||||
|
g++ main.cpp $(RAYOBJECTS) $(OBJECTS) -o main $(RAYOPT) $(RAYINCLUDE) $(INCLUDE) $(CFLAGS)
|
||||||
|
|
||||||
|
run: main
|
||||||
|
./main
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf obj
|
||||||
|
rm -rf raylib
|
||||||
|
rm main
|
61
main.cpp
Normal file
61
main.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include <cmath>
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "raymath.h"
|
||||||
|
|
||||||
|
#define MAX_DEPTH 10
|
||||||
|
|
||||||
|
Vector2 draw_line(Vector2 start, float angleDeg, float lenghth)
|
||||||
|
{
|
||||||
|
angleDeg += 180.0f;
|
||||||
|
float angle = (angleDeg * PI) / 180.0f;
|
||||||
|
float nx = lenghth * std::sin(angle);
|
||||||
|
float ny = lenghth * std::cos(angle);
|
||||||
|
Vector2 end = {start.x + nx, start.y + ny};
|
||||||
|
DrawLineEx(start, end, 2.0f, PURPLE);
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_branch(Vector2 start, float angle, float len, int dep)
|
||||||
|
{
|
||||||
|
Vector2 next = draw_line(start, angle, len);
|
||||||
|
|
||||||
|
if (len < MAX_DEPTH)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float next_len = 0.7f;
|
||||||
|
draw_branch(next, angle + 45, len * next_len, dep + 1);
|
||||||
|
draw_branch(next, angle - 45, len * next_len, dep + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 800;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib");
|
||||||
|
|
||||||
|
Camera2D camera = {0};
|
||||||
|
camera.target = (Vector2){0.0f, 0.0f};
|
||||||
|
camera.offset = (Vector2){screenWidth / 2, screenHeight};
|
||||||
|
camera.rotation = 0.0f;
|
||||||
|
camera.zoom = 1.0f;
|
||||||
|
|
||||||
|
SetTargetFPS(60);
|
||||||
|
Vector2 start = {0};
|
||||||
|
while (!WindowShouldClose())
|
||||||
|
{
|
||||||
|
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
BeginMode2D(camera);
|
||||||
|
|
||||||
|
DrawCircle(0, 0, 10.0f, RED);
|
||||||
|
draw_branch(start, 0, screenHeight / 4, 0);
|
||||||
|
|
||||||
|
EndMode2D();
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseWindow();
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user