Add stb image library to project

This commit is contained in:
4VRDriver
2020-09-02 00:27:26 +02:00
parent 82a2b88175
commit f8868be702
10 changed files with 7784 additions and 10 deletions

View File

@@ -25,6 +25,7 @@ target_link_libraries(
Fall-Fever PRIVATE
glfw
glad
stb
GL
)

View File

@@ -42,13 +42,11 @@ void Controller::run() {
Vertex vertices[] = {
Vertex{-0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f},
Vertex{0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
Vertex{-0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f},
Vertex{0.5f, 0.5f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f}
Vertex{0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f}
};
uint32_t indices[] = {
0, 1, 2,
1, 2, 3
0, 1, 2
};
uint32_t numVertices = sizeof(vertices) / sizeof(Vertex);
@@ -60,11 +58,14 @@ void Controller::run() {
while(!glfwWindowShouldClose(gameWindow->getGLFWwindow())) {
// Timing
limit_framerate();
#ifdef _DEBUG
static uint8_t frameCount = 250;
if(frameCount++ == 255) {
std::cout << "FPS: " << 1/deltaTime << std::endl;
frameCount = 0;
}
#endif
// Update game
// ...

View File

@@ -13,6 +13,7 @@ public:
void bind();
void unbind();
// May be rewritten...
void setBool(const char *name, bool value) const;
void setInt(const char *name, int value) const;
void setFloat(const char *name, float value) const;

View File

@@ -21,13 +21,13 @@ Window::Window() {
}
#ifdef _DEBUG
std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(openGLDebugCallback, NULL);
#endif
glViewport(0, 0, width, height);
std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
// Tell GLFW which function to call when window is resized
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);

View File

@@ -1,3 +1,2 @@
add_subdirectory(
${CMAKE_CURRENT_SOURCE_DIR}/glad
)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glad)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/stb)

8
lib/stb/CMakeLists.txt Normal file
View File

@@ -0,0 +1,8 @@
# The only purpose of this file is to add stb to the include paths
# stb.c is a wrapper file
add_library(
stb STATIC
stb.c
)
target_include_directories(stb PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

2
lib/stb/stb.c Normal file
View File

@@ -0,0 +1,2 @@
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>

7762
lib/stb/stb_image.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
#include <iostream>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <stb_image.h>
#include "Controller.h"
@@ -10,8 +11,6 @@ int main(int argc, char** argv) {
#ifdef _DEBUG
std::cout << "[Debug Mode]" << std::endl;
#else
std::cout << "[Release Mode]" << std::endl;
#endif
// Create window

View File

@@ -7,5 +7,6 @@ out vec4 v_color;
void main() {
gl_Position = vec4(a_position, 1.0f);
//gl_Position = vec4(a_position.x, -a_position.y, a_position.z, 1.0f);
v_color = a_color;
}