I had some difficulty getting your simple.c to build & run on ubuntu; however, after some hacking I came up with these changes (I'm not sure how to push a branch up to your repository).
4 files changed, 36 insertions(+), 13 deletions(-)
CMakeLists.txt | 19 +++++++++++++++++++
examples/gltext.c | 7 +++++++
examples/simple.c | 15 ++++++---------
gltext.h | 8 ++++----
new file CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 3.12...3.18 FATAL_ERROR)
+project (Test)
+
+set(CMAKE_C_STANDARD 99)
+
+find_package(OpenGL REQUIRED)
+find_package(glfw3 3.3 REQUIRED)
+
+set(CMAKE_EXPORT_COMPILE_COMMANDS Y)
+
+add_executable (Test examples/simple.c examples/gltext.c)
+target_include_directories(Test PUBLIC .)
+
+target_link_libraries(Test
+ PUBLIC
+ m
+ glfw
+ OpenGL::GL
+)
new file examples/gltext.c
@@ -0,0 +1,7 @@
+// For building implementations for gltext functions
+#include <GL/gl.h>
+
+#include <GLES3/gl3.h>
+
+#define GLT_IMPLEMENTATION
+#include "gltext.h"
modified examples/simple.c
@@ -11,13 +11,10 @@
#include <math.h>
-#include <glad/glad.h> /* https://github.com/Dav1dde/glad */
#include <GLFW/glfw3.h> /* https://github.com/glfw/glfw */
-#define GLT_IMPLEMENTATION
#include "gltext.h" /* https://github.com/vallentin/glText */
-
int main(int argc, char *argv[])
{
if (!glfwInit())
@@ -52,12 +49,12 @@ int main(int argc, char *argv[])
glfwShowWindow(window);
glfwMakeContextCurrent(window);
- if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
- {
- fprintf(stderr, "Failed to load OpenGL functions and extensions\n");
- glfwTerminate();
- return EXIT_FAILURE;
- }
+ /* if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) */
+ /* { */
+ /* fprintf(stderr, "Failed to load OpenGL functions and extensions\n"); */
+ /* glfwTerminate(); */
+ /* return EXIT_FAILURE; */
+ /* } */
glfwSwapInterval(1);
modified gltext.h
@@ -83,13 +83,13 @@ extern "C" {
#define GLT_NULL 0
#define GLT_NULL_HANDLE 0
-#ifdef GLT_IMPORTS
+#ifndef GLT_IMPLEMENTATION
# define GLT_API extern
#else
# ifndef GLT_STATIC
# define GLT_STATIC
# endif
-# define GLT_API static
+# define GLT_API
#endif
#define GLT_LEFT 0
@@ -956,7 +956,7 @@ GLT_API GLboolean _gltCreateText2DShader(void)
glBindAttribLocation(_gltText2DShader, _GLT_TEXT2D_POSITION_LOCATION, "position");
glBindAttribLocation(_gltText2DShader, _GLT_TEXT2D_TEXCOORD_LOCATION, "texCoord");
- glBindFragDataLocation(_gltText2DShader, 0, "fragColor");
+ // glBindFragDataLocation(_gltText2DShader, 0, "fragColor");
glLinkProgram(_gltText2DShader);
@@ -1336,4 +1336,4 @@ GLT_API GLboolean _gltCreateText2DFontTexture(void)
}
#endif
-#endif
\ No newline at end of file
+#endif
I had some difficulty getting your simple.c to build & run on ubuntu; however, after some hacking I came up with these changes (I'm not sure how to push a branch up to your repository).
Major issues I had: