summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
author_Tradam <[email protected]>2024-06-20 19:15:20 -0400
committerGitHub <[email protected]>2024-06-20 19:15:20 -0400
commitf855e58f6b2d4a7d2170fc075b8916f928c12680 (patch)
tree5a1594c2fb93cc18f8bb4929824e0ed7db106ce1
parent3ad66ad26d539b5978651fd79c884399668e18ec (diff)
parent7703f2a74122c771070f19259fc40eb2167df9ac (diff)
downloadraylib-DrawTexturePro-interactive-demo-f855e58f6b2d4a7d2170fc075b8916f928c12680.tar.gz
raylib-DrawTexturePro-interactive-demo-f855e58f6b2d4a7d2170fc075b8916f928c12680.zip
Merge pull request #2 from Peter0x44/masterHEADmaster
Use OpenGL ES3 so repeating textures works
-rw-r--r--Makefile2
-rw-r--r--assets/lavanda.rgsbin4541 -> 0 bytes
-rw-r--r--assets/style_lavanda.rgsbin0 -> 4322 bytes
-rw-r--r--main.c94
m---------raygui0
m---------raylib0
6 files changed, 55 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index aec7883..2444ff5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
desktop:
zig cc -target native main.c -o game -lGL -lm -lpthread -ldl -lrt -lX11 -Iraylib/src -Iraygui/src lib/tux/libraylib.a && ./game
web:
- emcc -Os -Wall main.c -o game -Iraylib/src -Iraygui/src lib/web/libraylib.a -o output/index.html -s USE_GLFW=3 -DPLATFORM_WEB --shell-file raylib/src/minshell.html -s TOTAL_MEMORY=268435456 -s ASYNCIFY --preload-file ./assets
+ emcc -Os -Wall main.c -o game -Iraylib/src -Iraygui/src lib/web/libraylib.a -o output/index.html -s USE_GLFW=3 -s FULL_ES3 -DPLATFORM_WEB --shell-file raylib/src/minshell.html -s TOTAL_MEMORY=268435456 --preload-file ./assets
diff --git a/assets/lavanda.rgs b/assets/lavanda.rgs
deleted file mode 100644
index 3aa3e6f..0000000
--- a/assets/lavanda.rgs
+++ /dev/null
Binary files differ
diff --git a/assets/style_lavanda.rgs b/assets/style_lavanda.rgs
new file mode 100644
index 0000000..4b18673
--- /dev/null
+++ b/assets/style_lavanda.rgs
Binary files differ
diff --git a/main.c b/main.c
index ca0a70d..9d65338 100644
--- a/main.c
+++ b/main.c
@@ -8,6 +8,10 @@
#include "raylib.h"
#include <stdio.h>
+#ifdef __EMSCRIPTEN__
+#include <emscripten/emscripten.h>
+#endif
+
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
@@ -91,8 +95,8 @@ Vector2 dtpOrigin = {
.x = 0,
.y = 0
};
-int predtpRotation;
-int dtpRotation = 0;
+float predtpRotation;
+float dtpRotation = 0;
const int gridSize = 20;
const int gridCenter = 120;
@@ -112,16 +116,36 @@ void DrawOutput();
void HandleDroppedFiles();
+void UpdateDrawFrame()
+{
+ HandleDroppedFiles();
+
+ BeginDrawing();
+ ClearBackground(RAYWHITE);
+
+ DrawElementBorders();
+ SetupDifference();
+ DrawUI();
+ ResolveMouseState();
+ DrawCodeDisplay();
+ CheckDifference();
+ DrawOutput();
+
+ EndDrawing();
+}
+
int main()
{
InitWindow(screenWidth, screenHeight, "DrawTexturePro Example");
SetTargetFPS(60);
- GuiLoadStyle("assets/lavanda.rgs");
+ GuiLoadStyle("assets/style_lavanda.rgs");
sampleSprite = LoadTexture("assets/kenney.png");
sourceCodeFont = LoadFontEx("assets/LiberationMono-Regular.ttf", fontSize, 0, 250);
GuiSetFont(sourceCodeFont);
+ GuiSetStyle(DEFAULT, TEXT_SIZE, fontSize);
+ GuiSetStyle(DEFAULT, TEXT_SPACING, fontSpacing);
for(i = 0; i < 21; i += 1) {
codePreviewHighlight[i] = BEIGE;
@@ -137,24 +161,14 @@ int main()
elementRender.height - 20
);
-
+#ifdef __EMSCRIPTEN__
+ emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
+#else
while (!WindowShouldClose())
{
- HandleDroppedFiles();
-
- BeginDrawing();
- ClearBackground(RAYWHITE);
-
- DrawElementBorders();
- SetupDifference();
- DrawUI();
- ResolveMouseState();
- DrawCodeDisplay();
- CheckDifference();
- DrawOutput();
-
- EndDrawing();
+ UpdateDrawFrame();
}
+#endif
CloseWindow();
return 0;
@@ -330,7 +344,7 @@ void DrawUI() {
);
sprintf(buffer, "%d", (int)dtpSource.x),
- dtpSource.x = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset,
@@ -339,12 +353,12 @@ void DrawUI() {
},
"x",
buffer,
- dtpSource.x,
+ &dtpSource.x,
-192,
192
);
sprintf(buffer, "%d", (int)dtpSource.y),
- dtpSource.y = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset + sliderHeight + sliderSpacing,
@@ -353,12 +367,12 @@ void DrawUI() {
},
"y",
buffer,
- dtpSource.y,
+ &dtpSource.y,
-192,
192
);
sprintf(buffer, "%d", (int)dtpSource.width),
- dtpSource.width = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset + ((sliderHeight + sliderSpacing) * 2),
@@ -367,12 +381,12 @@ void DrawUI() {
},
"Width",
buffer,
- dtpSource.width,
+ &dtpSource.width,
-192,
192
);
sprintf(buffer, "%d", (int)dtpSource.height),
- dtpSource.height = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset + ((sliderHeight + sliderSpacing) * 3),
@@ -381,7 +395,7 @@ void DrawUI() {
},
"Height",
buffer,
- dtpSource.height,
+ &dtpSource.height,
-192,
192
);
@@ -398,7 +412,7 @@ void DrawUI() {
"Dest"
);
sprintf(buffer, "%d", (int)dtpDest.x),
- dtpDest.x = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset,
@@ -407,12 +421,12 @@ void DrawUI() {
},
"x",
buffer,
- dtpDest.x,
+ &dtpDest.x,
-192,
192
);
sprintf(buffer, "%d", (int)dtpDest.y),
- dtpDest.y = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset + sliderHeight + sliderSpacing,
@@ -421,12 +435,12 @@ void DrawUI() {
},
"y",
buffer,
- dtpDest.y,
+ &dtpDest.y,
-192,
192
);
sprintf(buffer, "%d", (int)dtpDest.width),
- dtpDest.width = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset + ((sliderHeight + sliderSpacing) * 2),
@@ -435,12 +449,12 @@ void DrawUI() {
},
"Width",
buffer,
- dtpDest.width,
+ &dtpDest.width,
-192,
192
);
sprintf(buffer, "%d", (int)dtpDest.height),
- dtpDest.height = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset + ((sliderHeight + sliderSpacing) * 3),
@@ -449,7 +463,7 @@ void DrawUI() {
},
"Height",
buffer,
- dtpDest.height,
+ &dtpDest.height,
-192,
192
);
@@ -465,7 +479,7 @@ void DrawUI() {
"Origin"
);
sprintf(buffer, "%d", (int)dtpOrigin.x),
- dtpOrigin.x = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset,
@@ -474,12 +488,12 @@ void DrawUI() {
},
"x",
buffer,
- dtpOrigin.x,
+ &dtpOrigin.x,
-192,
192
);
sprintf(buffer, "%d", (int)dtpOrigin.y),
- dtpOrigin.y = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset + sliderHeight + sliderSpacing,
@@ -488,7 +502,7 @@ void DrawUI() {
},
"y",
buffer,
- dtpOrigin.y,
+ &dtpOrigin.y,
-192,
192
);
@@ -505,7 +519,7 @@ void DrawUI() {
"Rotation"
);
sprintf(buffer, "%d", (int)dtpRotation),
- dtpRotation = GuiSlider(
+ GuiSlider(
(Rectangle) {
.x = elementSliders.x + xOffset,
.y = elementSliders.y + yOffset,
@@ -514,7 +528,7 @@ void DrawUI() {
},
"",
buffer,
- dtpRotation,
+ &dtpRotation,
-360,
360
);
diff --git a/raygui b/raygui
-Subproject 9c826f213f5b287159a0b0e1a0670a27c09dcc7
+Subproject 0f832e6a6edfa77a93c327617468b15755cb05c
diff --git a/raylib b/raylib
-Subproject 3ebfee5dbc1d0de5555105f4989954cd4547baf
+Subproject 52f2a10db610d0e9f619fd7c521db08a876547d