summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/main/engine/engine.c34
-rw-r--r--src/main/engine/engine.h25
-rw-r--r--src/main/main.c6
4 files changed, 67 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c27a87a..91f0290 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,8 @@ add_executable(tris
src/main/ui/ui.h
src/main/ui/x11/ui.c
src/main/util.h
- src/main/util.c)
+ src/main/util.c
+ src/main/engine/engine.h
+ src/main/engine/engine.c)
target_link_libraries(tris PRIVATE X11 GL GLX)
diff --git a/src/main/engine/engine.c b/src/main/engine/engine.c
new file mode 100644
index 0000000..d7e0f9c
--- /dev/null
+++ b/src/main/engine/engine.c
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (C) 2025 Alessandro Iezzi <aiezzi AT alessandroiezzi PERIOD it>
+ *
+ * This file is part of Tris Game.
+ *
+ * Tris Game is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tris Game is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tris Game. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "../ui/ui.h"
+
+#define RANGE_GL 2.0f
+
+float xstep;
+float ystep;
+
+void
+engine_init(int width, int height)
+{
+ ui_init(width, height);
+
+ xstep = RANGE_GL / (float) width;
+ ystep = RANGE_GL / (float) height;
+}
diff --git a/src/main/engine/engine.h b/src/main/engine/engine.h
new file mode 100644
index 0000000..83b8367
--- /dev/null
+++ b/src/main/engine/engine.h
@@ -0,0 +1,25 @@
+/*-
+ * Copyright (C) 2025 Alessandro Iezzi <aiezzi AT alessandroiezzi PERIOD it>
+ *
+ * This file is part of Tris Game.
+ *
+ * Tris Game is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tris Game is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tris Game. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __ENGINE_H__
+#define __ENGINE_H__
+
+void engine_init(int width, int height);
+
+#endif /* __ENGINE_H__ */
diff --git a/src/main/main.c b/src/main/main.c
index 59c76b6..5ac3698 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -19,9 +19,13 @@
#include <stdio.h>
#include "ui/ui.h"
+#include "engine/engine.h"
+
+#define WIDTH 640
+#define HEIGHT 480
int main(void) {
- ui_init(640, 640);
+ engine_init(WIDTH, HEIGHT);
ui_set_title("Tris Game");
return EXIT_SUCCESS;