Compare commits

..

No commits in common. "fc4a02835ad190a90443644ed83f539f6659de26" and "ccf325d8fbba68f5f43124690ffd9657f1a3deb8" have entirely different histories.

7 changed files with 51 additions and 101 deletions

View file

@ -30,21 +30,17 @@ source_group("shaders" FILES ${PROJECT_SHADERS})
source_group("sources" FILES ${PROJECT_SOURCES}) source_group("sources" FILES ${PROJECT_SOURCES})
source_group("vendors" FILES ${VENDORS_SOURCES}) source_group("vendors" FILES ${VENDORS_SOURCES})
find_package(Boost 1.56 REQUIRED COMPONENTS
program_options)
set(EXE_1_NAME loader) set(EXE_1_NAME loader)
file( file(
GLOB EXE_1_SOURCES GLOB EXE_1_SOURCES
src/main.cpp src/main.cpp
src/graphics.hpp
include/glad/glad.h include/glad/glad.h
) )
set(CMAKE_BINARY_DIR "bin") set(CMAKE_BINARY_DIR "bin")
add_executable(${EXE_1_NAME} ${EXE_1_SOURCES} ${PROJECT_HEADERS} add_executable(${EXE_1_NAME} ${EXE_1_SOURCES} ${PROJECT_HEADERS}
${PROJECT_SHADERS} ${VENDORS_SOURCES}) ${PROJECT_SHADERS} ${VENDORS_SOURCES})
target_link_libraries(${EXE_1_NAME} glfw ${GLAD_LIBRARIES} Boost::program_options) target_link_libraries(${EXE_1_NAME} glfw ${GLAD_LIBRARIES})
target_include_directories(${EXE_1_NAME} PRIVATE include) target_include_directories(${EXE_1_NAME} PRIVATE include)
set_target_properties(${EXE_1_NAME} PROPERTIES set_target_properties(${EXE_1_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${EXE_1_NAME}) RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${EXE_1_NAME})

View file

@ -9,7 +9,7 @@ For Fedora Systems, you can the dependencies like this:
```bash ```bash
sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel extra-cmake-modules \ sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel extra-cmake-modules \
libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel boost boost-doc boost-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel
``` ```
Optional, but recommended Packages: Optional, but recommended Packages:
@ -22,4 +22,3 @@ sudo dnf install glfw-devel glfw glfw-doc glad
Your editor might need help to find the `include/` directory. If you are using Your editor might need help to find the `include/` directory. If you are using
clangd, you can use the `.clangd` file in this repo. Just adjust the path to clangd, you can use the `.clangd` file in this repo. Just adjust the path to
what you need (it needs to be absolute). what you need (it needs to be absolute).

View file

@ -3,6 +3,4 @@ set -e
flags="-DGLFW_USE_WAYLAND=ON" # compile glfw for wayland instead of X11 flags="-DGLFW_USE_WAYLAND=ON" # compile glfw for wayland instead of X11
cmake $flags . cmake $flags .
cmake --build . cmake --build .
echo -e "running the program, passing the given args" ./bin/loader/loader
echo -e "========================================"
./run.sh $@

3
run.sh
View file

@ -1,3 +0,0 @@
#!/bin/bash
set -e
./bin/loader/loader $@

View file

@ -1,58 +0,0 @@
#include "graphics.hpp"
#include <iostream>
#include <unistd.h>
int mainWindow() {
/* graphics stuff */
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
GLFWwindow *window = glfwCreateWindow(800, 600, "Shader Loader", NULL, NULL);
if (window == NULL) {
printf("Failed to create GLFW window\n");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
printf("Failed to initialize GLAD\n");
return -1;
}
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
float vertices[] = {-0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f, 0.0f, 0.5f, 0.0f};
unsigned int VBO;
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
while (!glfwWindowShouldClose(window)) {
processInput(window);
glClearColor(0.8f, 0.4f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
}
void processInput(GLFWwindow *window) {
// if user presses ESC, close the window
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
}
void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
glViewport(0, 0, width, height);
}

View file

@ -1,6 +0,0 @@
#include <glad/glad.c>
#include <GLFW/glfw3.h>
void framebuffer_size_callback(GLFWwindow *window, int width, int height);
void processInput(GLFWwindow *window);
int mainWindow();

View file

@ -1,38 +1,62 @@
#include <boost/program_options.hpp> #include <glad/glad.c>
#include <GLFW/glfw3.h>
#include <iostream> #include <iostream>
#include <unistd.h>
#include "graphics.hpp" void framebuffer_size_callback(GLFWwindow *window, int width, int height);
void processInput(GLFWwindow *window);
namespace po = boost::program_options;
int main(int argc, char **argv) { int main(int argc, char **argv) {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
printf("argc:\t\t%d\n", argc); GLFWwindow *window = glfwCreateWindow(800, 600, "Shader Loader", NULL, NULL);
for (int i = 0; i < argc; i++) { if (window == NULL) {
printf("argv[%d]:\t%s\n", i, argv[i]); printf("Failed to create GLFW window\n");
glfwTerminate();
return -1;
} }
std::cout << std::endl; glfwMakeContextCurrent(window);
po::options_description desc("Allowed options"); if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
desc.add_options()("help", "produce help message")( printf("Failed to initialize GLAD\n");
"compression", po::value<int>(), "set compression level"); return -1;
po::variables_map vm;
/* po::store(po::parse_command_line(ac, av, desc), vm); */
po::notify(vm);
if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
} }
if (vm.count("compression")) { glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
std::cout << "Compression level was set to " << vm["compression"].as<int>()
<< ".\n"; float vertices[] = {-0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f, 0.0f, 0.5f, 0.0f};
} else {
std::cout << "Compression level was not set.\n"; unsigned int VBO;
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
while (!glfwWindowShouldClose(window)) {
processInput(window);
glClearColor(0.8f, 0.4f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
} }
glfwTerminate();
return 0; return 0;
} }
void processInput(GLFWwindow *window) {
// if user presses ESC, close the window
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
}
void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
glViewport(0, 0, width, height);
}