summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2022-11-19 22:31:13 -0500
committerrealtradam <[email protected]>2022-11-19 22:31:13 -0500
commit0eef3373b58cf2de459578fc94606804d1e778a0 (patch)
tree0c53f9ce2b80823b223b07ae3dbdddb473c94354
parent13432ece9e2a8c6d20158fd6886c6060c8a7bdc9 (diff)
downloadOgle-0eef3373b58cf2de459578fc94606804d1e778a0.tar.gz
Ogle-0eef3373b58cf2de459578fc94606804d1e778a0.zip
Hello Window complete
-rw-r--r--Makefile12
-rw-r--r--src/compile_flags.txt2
-rw-r--r--src/input.cpp8
-rw-r--r--src/input.h4
-rw-r--r--src/main.cpp10
5 files changed, 31 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 6b34a6b..378e74f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,14 @@
-default: src/main.cpp glad.o
- g++ -o build/game src/main.cpp build/glad.o -Iglfw/build/include -Iglad/include glfw/build/lib/libglfw3.a -lGL -lX11 -lpthread -lXrandr -lXi -ldl
+default: src/main.cpp glad.o input.o
+ @mkdir -p build
+ g++ -o build/game src/main.cpp build/glad.o build/input.o -Isrc -Iglfw/build/include -Iglad/include glfw/build/lib/libglfw3.a -lGL -lX11 -lpthread -lXrandr -lXi -ldl
+
+input.o: src/input.cpp src/input.h
+ @mkdir -p build
+ g++ -o build/input.o -c src/input.cpp -Isrc -Iglfw/build/include -Iglad/include -lGL -lX11 -lpthread -lXrandr -lXi -ldl
glad.o: glad/src/glad.c
- g++ -o build/glad.o -c glad/src/glad.c -Iglfw/build/include -Iglad/include -lGL -lX11 -lpthread -lXrandr -lXi -ldl
+ @mkdir -p build
+ g++ -o build/glad.o -c glad/src/glad.c -Isrc -Iglfw/build/include -Iglad/include -lGL -lX11 -lpthread -lXrandr -lXi -ldl
.PHONY: run
run: default
diff --git a/src/compile_flags.txt b/src/compile_flags.txt
index 488bdcb..42dbe59 100644
--- a/src/compile_flags.txt
+++ b/src/compile_flags.txt
@@ -1,3 +1,3 @@
-I../glfw/build/include
-I../glad/include
-
+-I./
diff --git a/src/input.cpp b/src/input.cpp
new file mode 100644
index 0000000..ef5f410
--- /dev/null
+++ b/src/input.cpp
@@ -0,0 +1,8 @@
+#include "input.h"
+#include <GLFW/glfw3.h>
+
+void processInput(GLFWwindow *window)
+{
+ if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
+ glfwSetWindowShouldClose(window, true);
+}
diff --git a/src/input.h b/src/input.h
new file mode 100644
index 0000000..274489c
--- /dev/null
+++ b/src/input.h
@@ -0,0 +1,4 @@
+#pragma once
+#include <GLFW/glfw3.h>
+
+void processInput(GLFWwindow *window);
diff --git a/src/main.cpp b/src/main.cpp
index 05e27da..fd3a460 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,6 +1,8 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
+#include "input.h"
+
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
@@ -14,7 +16,7 @@ int main() {
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- GLFWwindow* window = glfwCreateWindow(800, 600, "Yep", NULL, NULL);
+ GLFWwindow* window = glfwCreateWindow(800, 600, "Ogle", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
@@ -33,8 +35,14 @@ int main() {
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
+ // game loop
while(!glfwWindowShouldClose(window))
{
+ processInput(window);
+
+ glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+
glfwSwapBuffers(window);
glfwPollEvents();
}