summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorSchark <jordan@schark.online>2023-05-11 22:42:54 -0700
committerSchark <jordan@schark.online>2023-05-11 22:42:54 -0700
commitdc8ad2d7f67e47b00ed0ecb77fae976275fc7a16 (patch)
tree3be5cac6b1c12fe2981f3b72e51279e7c9806b4a /src/main.c
parent622604ab99f53a891700919268e34ab679c96330 (diff)
downloadgamedev-dc8ad2d7f67e47b00ed0ecb77fae976275fc7a16.tar.gz
gamedev-dc8ad2d7f67e47b00ed0ecb77fae976275fc7a16.zip
Fullscreen, for now
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c15
1 files changed, 9 insertions, 6 deletions
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);