summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--readme3
-rw-r--r--src/main.c15
2 files changed, 11 insertions, 7 deletions
diff --git a/readme b/readme
index 574668e..715db26 100644
--- a/readme
+++ b/readme
@@ -2,7 +2,8 @@ Current Todo:
- Actually update README
- Use mouse to look around, as opposed to keys
- Y-Shearing eventually, but probably following refactor
- - Adjustable window size
+ - Adjustable window size*
+ * Currently fullscreen, add options later
- Create bounds so player cannot enter undefined areas (outer walls, inner structures)
- Experiment with warp-wrapping, just for fun :)
- Move FPS counter from window title to rendered in-game (low priority)
diff --git a/src/main.c b/src/main.c
index 180c955..0ea84d4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,9 +35,9 @@ typedef struct {
} ColorRGB;
// honest- this function can from chatgpt- cross-reference this with other raycasting guides
-void raycast(Player *player) {
- int screen_width = 800;
- int screen_height = 600;
+void raycast(Player *player, int width, int height) {
+ int screen_width = width;
+ int screen_height = height;
for (int x = 0; x < screen_width; ++x) {
// Calculate ray position and direction
@@ -173,7 +173,10 @@ int main(int argc, char *argv[]) {
}
// create glfw window
- window = glfwCreateWindow(800, 600, "raycaster", NULL, NULL);
+ GLFWmonitor* primary = glfwGetPrimaryMonitor();
+ const GLFWvidmode* mode = glfwGetVideoMode(primary);
+ //window = glfwCreateWindow(800, 600, "raycaster", NULL, NULL);
+ window = glfwCreateWindow(mode->width, mode->height, "raycaster", primary, NULL);
if (!window){
printf("Failed to create GLFW window.\n");
glfwTerminate();
@@ -186,7 +189,7 @@ int main(int argc, char *argv[]) {
// setup orthographic projection camera
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0.0, 800, 600, 0.0, -1.0, 1.0);
+ glOrtho(0.0, mode->width, mode->height, 0.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
// TODO: move timers into a header
@@ -212,7 +215,7 @@ int main(int argc, char *argv[]) {
glLoadIdentity();
// main raycast function
- raycast(&player);
+ raycast(&player, mode->width, mode->height);
move_player(&player, window);
glfwSwapBuffers(window);