Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ x86/
bld/
[Oo]bj/

#Cmake ignore
build/
*/build/ #Make more restricted if a /build/ folder needs to be included

# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "dependencies/glfw-source"]
path = dependencies/glfw-source
url = https://github.com/glfw/glfw.git
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(aieBootstrapProject)

#TODO: Update to use the target_complile_requires
set(CMAKE_CXX_STANDARD 14)

find_package(OpenGL REQUIRED)


#add build glfw
option(GLFW_BUILD_EXAMPLES NO)
option(GLFW_BUILD_TESTS NO)
add_subdirectory(${PROJECT_SOURCE_DIR}/dependencies/glfw-source)

add_subdirectory(bootstrap)


#PROJECT TO BUILD
add_subdirectory(project3D)
6 changes: 5 additions & 1 deletion bootstrap/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ void Application::setVSync(bool enable) {
}

void Application::setShowCursor(bool visible) {
ShowCursor(visible);
#ifdef _MSC_VER
ShowCursor(visible);
#else
glfwSetInputMode(m_window, GLFW_CURSOR, visible ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_HIDDEN);
#endif
}

unsigned int Application::getWindowWidth() const {
Expand Down
29 changes: 29 additions & 0 deletions bootstrap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(aieBootstrap)

add_library(${PROJECT_NAME}
Application.cpp
Font.cpp
Gizmos.cpp
Input.cpp
Renderer2D.cpp
Texture.cpp
gl_core_4_4.c
imgui_glfw3.cpp
${CMAKE_SOURCE_DIR}/dependencies/imgui/imgui_draw.cpp
${CMAKE_SOURCE_DIR}/dependencies/imgui/imgui.cpp
)

target_link_libraries(${PROJECT_NAME}
glfw
${OPENGL_gl_LIBRARY}
)

target_include_directories(${PROJECT_NAME} PUBLIC
${PROJECT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/dependencies/glm
${CMAKE_SOURCE_DIR}/dependencies/imgui
${CMAKE_SOURCE_DIR}/dependencies/stb
${CMAKE_SOURCE_DIR}/dependencies/glfw/include
${CMAKE_SOURCE_DIR}/dependencies/openal/include
)
8 changes: 6 additions & 2 deletions bootstrap/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ Font::Font(const char* trueTypeFontFile, unsigned short fontHeight)
m_textureHeight(0) {

FILE* file = nullptr;
#ifdef _MSC_VER
fopen_s(&file, trueTypeFontFile, "rb");
if (file != nullptr) {
#else
file = fopen(trueTypeFontFile, "rb");
#endif
if (file != nullptr) {

unsigned char* ttf_buffer = new unsigned char[4096 * 1024];

Expand Down Expand Up @@ -168,4 +172,4 @@ void Font::getStringRectangle(const char* str, float& x0, float& y0, float& x1,
y1 *= -1;
}

} // namepace aie
} // namepace aie
14 changes: 11 additions & 3 deletions bootstrap/Renderer2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Renderer2D::Renderer2D() {
m_fontTexture[i] = 0;
}

char* vertexShader = "#version 150\n \
const char* vertexShader = "#version 150\n \
in vec4 position; \
in vec4 colour; \
in vec2 texcoord; \
Expand All @@ -45,7 +45,7 @@ Renderer2D::Renderer2D() {
void main() { vColour = colour; vTexCoord = texcoord; vTextureID = position.w; \
gl_Position = projectionMatrix * vec4(position.x, position.y, position.z, 1.0f); }";

char* fragmentShader = "#version 150\n \
const char* fragmentShader = "#version 150\n \
in vec4 vColour; \
in vec2 vTexCoord; \
in float vTextureID; \
Expand Down Expand Up @@ -97,7 +97,11 @@ Renderer2D::Renderer2D() {
// set texture locations
char buf[32];
for (int i = 0; i < TEXTURE_STACK_SIZE; ++i) {
#ifdef _MSC_VER
sprintf_s(buf, "textureStack[%i]", i);
#else
sprintf(buf, "textureStack[%i]", i);
#endif
glUniform1i(glGetUniformLocation(m_shader, buf), i);
}

Expand Down Expand Up @@ -649,7 +653,11 @@ void Renderer2D::flushBatch() {
return; char buf[32];

for (int i = 0; i < TEXTURE_STACK_SIZE; ++i) {
#ifdef _MSC_VER
sprintf_s(buf, "isFontTexture[%i]", i);
#else
sprintf(buf, "isFontTexture[%i]", i);
#endif
glUniform1i(glGetUniformLocation(m_shader, buf), m_fontTexture[i]);
}

Expand Down Expand Up @@ -732,4 +740,4 @@ void Renderer2D::rotateAround(float inX, float inY, float& outX, float& outY, fl
outY = inX * sin + inY * cos;
}

} // namespace aie
} // namespace aie
1 change: 1 addition & 0 deletions dependencies/glfw-source
Submodule glfw-source added at 0be4f3
7 changes: 6 additions & 1 deletion project2D/Application2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Texture.h"
#include "Font.h"
#include "Input.h"
#include <cmath>

Application2D::Application2D() {

Expand Down Expand Up @@ -96,10 +97,14 @@ void Application2D::draw() {

// output some text, uses the last used colour
char fps[32];
#ifdef _MSC_VER
sprintf_s(fps, 32, "FPS: %i", getFPS());
#else
sprintf(fps, "FPS: %i", getFPS());
#endif
m_2dRenderer->drawText(m_font, fps, 0, 720 - 32);
m_2dRenderer->drawText(m_font, "Press ESC to quit!", 0, 720 - 64);

// done drawing sprites
m_2dRenderer->end();
}
}
8 changes: 8 additions & 0 deletions project2D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(project2D)

add_executable(${PROJECT_NAME}
main.cpp
Application2D.cpp
)
target_link_libraries(${PROJECT_NAME} aieBootstrap)
8 changes: 8 additions & 0 deletions project3D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(project3D)

add_executable(${PROJECT_NAME}
main.cpp
Application3D.cpp
)
target_link_libraries(${PROJECT_NAME} aieBootstrap)