Compare commits

...

6 Commits

Author SHA1 Message Date
c53fa52f6f FreeType2 2024-06-29 15:07:02 -04:00
7fa75cac54 initial 2024-06-29 12:37:16 -04:00
Redacted
d5f9eaa5a8 Update CMakeLists.txt 2024-06-26 23:30:40 -04:00
dead018993 Update CMakeLists.txt 2024-06-18 14:43:56 -04:00
Redacted
e9a339182b Update CMakeLists.txt 2024-06-18 14:22:10 -04:00
Redacted
076398b290 Update CMakeLists.txt 2024-06-18 14:19:45 -04:00
4 changed files with 80 additions and 40 deletions

View File

@@ -9,50 +9,88 @@ if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
endif()
set(CMAKE_CXX_STANDARD 20)
if (WIN32)
set(CMAKE_CXX_FLAGS "-municode")
endif(WIN32)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Enable Package Managers
include(cmake/CPM.cmake)
CPMAddPackage(
NAME J3ML
URL https://git.redacted.cc/josh/j3ml/archive/Release-6.zip
URL https://git.redacted.cc/josh/j3ml/archive/Release-2.2.zip
)
CPMAddPackage(
NAME ReWindow
URL https://git.redacted.cc/Redacted/ReWindow/archive/vA0.2.30.zip
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-3.zip
)
CPMAddPackage(
NAME GLAD
URL https://git.redacted.cc/Redacted/glad/archive/v2.1ext_mt.zip
)
CPMAddPackage(
NAME jlog
URL https://git.redacted.cc/josh/jlog/Prerelease-9.zip
)
CPMAddPackage(
NAME Event
URL https://git.redacted.cc/josh/Event/archive/Release-6.zip
)
if (WIN32)
#CPMAddPackage(
#NAME harfbuzz
#URL https://github.com/harfbuzz/harfbuzz/archive/refs/tags/9.0.0.zip
#)
CPMAddPackage(
NAME freetype
URL https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-2.zip
)
endif()
file(COPY "assets" DESTINATION "${PROJECT_BINARY_DIR}")
file(GLOB_RECURSE ASSETS "assets/*")
file(GLOB_RECURSE HEADERS "include/*.h" "include/*.hpp")
file(GLOB_RECURSE SOURCES "src/*.c" "src/*.cpp" )
file(GLOB_RECURSE ASSETS "assets/*")
add_library(JGL SHARED ${SOURCES})
set_target_properties(JGL PROPERTIES LINKER_LANGUAGE CXX)
find_package(OpenGL REQUIRED)
find_package(Freetype REQUIRED)
if (UNIX AND NOT APPLE)
find_package(Freetype REQUIRED)
add_library(JGL SHARED ${SOURCES})
endif()
if (WIN32)
add_library(JGL STATIC ${SOURCES})
endif()
set_target_properties(JGL PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(JGL PUBLIC
${PROJECT_SOURCE_DIR}/include
${OPENGL_INCLUDE_DIRS}
${J3ML_SOURCE_DIR}/include
${Event_SOURCE_DIR}/include
${ReWindow_SOURCE_DIR}/include
${glad_SOURCE_DIR}/include
${jlog_SOURCE_DIR}/include
)
add_executable(JGL_Demo main.cpp)
set_target_properties(JGL_Demo PROPERTIES LINK_FLAGS "-Wl,-rpath,./lib")
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${OPENGL_INCLUDE_DIRS})
include_directories(${J3ML_SOURCE_DIR}/include)
include_directories(${ReWindow_SOURCE_DIR}/include)
include_directories(${glad_SOURCE_DIR}/include)
#set_target_properties(JGL_Demo PROPERTIES LINK_FLAGS "-Wl,-rpath,./lib")
target_include_directories(JGL PRIVATE ${FREETYPE_INCLUDE_DIRS})
target_link_libraries(JGL PRIVATE ${FREETYPE_LIBRARIES})
target_include_directories(JGL PRIVATE ${FREETYPE_INCLUDE_DIRS})
target_link_libraries(JGL_Demo PUBLIC JGL ${OPENGL_LIBRARIES} J3ML ReWindowLibrary glad)
if (UNIX AND NOT APPLE)
target_include_directories(JGL PRIVATE ${FREETYPE_INCLUDE_DIRS})
target_link_libraries(JGL PRIVATE ${FREETYPE_LIBRARIES})
target_link_libraries(JGL PUBLIC ${OPENGL_LIBRARIES} J3ML ReWindowLibrary glad jlog Event)
endif()
if (WIN32)
target_include_directories(JGL PRIVATE ${freetype_SOURCE_DIR}/include)
target_link_libraries(JGL PRIVATE freetype)
target_link_libraries(JGL PUBLIC ${OPENGL_LIBRARIES} J3ML ReWindowLibrary glad jlog Event)
endif()
target_link_libraries(JGL_Demo PUBLIC JGL)

View File

@@ -10,9 +10,7 @@
#include <iostream>
#include <JGL/Color3.h>
#include <J3ML/Geometry/Sphere.h>
#include <J3ML/Geometry/OBB.h>
#include <J3ML/Geometry/Capsule.h>
#include <J3ML/Geometry/Plane.h>
#include <J3ML/Geometry/TriangleMesh.h>
// OpenGL Wrapper for rendering 2D graphics primitives in both a 2D and 3D context

View File

@@ -6,10 +6,6 @@
using J3ML::LinearAlgebra::Vector2;
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#endif
struct Character
{
unsigned int TextureID; // ID handle of the glyph texture
@@ -109,7 +105,7 @@ int main(int argc, char** argv)
window->setRenderer(RenderingAPI::OPENGL);
window->Open();
window->initGL();
window->setResizable(true);
window->setResizable(false);
while (window->isAlive())
{
window->pollEvents();

View File

@@ -5,10 +5,17 @@
#include <vector>
#include <glad/glad.h>
#include <JGL/JGL.h>
#include <freetype2/ft2build.h>
#include FT_FREETYPE_H
#include <JGL/Color3.h>
#include <iostream>
#if __linux__
#include <freetype2/ft2build.h>
#include FT_FREETYPE_H
#endif
#if _WIN32
#include <ft2build.h>
#include FT_FREETYPE_H
#endif
GLuint program;
@@ -155,7 +162,7 @@ namespace JGL
FT_Set_Pixel_Sizes(face, 0, size);
GLuint textures[text.size()];
std::vector<GLuint> textures(text.length());
for (int i = 0; i < text.length(); i++)
{
if (FT_Load_Char(face, text.c_str()[i], FT_LOAD_RENDER))
@@ -166,7 +173,7 @@ namespace JGL
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &textures[i]);
glGenTextures(1, &textures.at(i));
glBindTexture(GL_TEXTURE_2D, textures[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
@@ -206,8 +213,8 @@ namespace JGL
x += (g->advance.x >> 6) * scale;
y += (g->advance.y >> 6) * scale;
}
for (auto& t : textures)
glDeleteTextures(1, &t);
for (unsigned int& texture : textures)
glDeleteTextures(1, &texture);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
@@ -235,7 +242,7 @@ namespace JGL
float y = pos.y;
float z = pos.z;
GLfloat currentColor[4];
GLuint textures[text.size()];
std::vector<GLuint> textures(text.length());;
glGetFloatv(GL_CURRENT_COLOR, currentColor);
glUseProgram(0); // Fixed-function pipeline.
glColor4f(color.r, color.g, color.b, 1.0f);
@@ -253,7 +260,7 @@ namespace JGL
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &textures[i]);
glGenTextures(1, &textures.at(i));
glBindTexture(GL_TEXTURE_2D, textures[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
@@ -296,8 +303,9 @@ namespace JGL
}
for (auto& t : textures)
glDeleteTextures(1, &t);
for (unsigned int& texture : textures)
glDeleteTextures(1, &texture);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, 0); // Unbind texture