diff --git a/Makefile b/Makefile index 78d6e80..d62d6c3 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ SRCS += worker.c OBJS := $(SRCS:.c=.o) -CFLAGS += `pkg-config libglfw ftgl openal --cflags` -g -LDFLAGS += `pkg-config libglfw ftgl openal --libs` -g +CFLAGS += `pkg-config freetype2 glfw3 ftgl openal opengl --cflags` -g +LDFLAGS += -lm -lpthread -lSOIL `pkg-config freetype2 glfw3 ftgl openal opengl --libs` lfsdash: $(OBJS) $(CC) $(LDFLAGS) $(OBJS) -o $@ diff --git a/gauge.c b/gauge.c index 1e15437..4b30e14 100644 --- a/gauge.c +++ b/gauge.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/lfsdash.c b/lfsdash.c index 57700bb..209c13c 100644 --- a/lfsdash.c +++ b/lfsdash.c @@ -1,9 +1,11 @@ -#include +#include #include +#include #include #include #include #include +#include #include "outgauge.h" #include "cars.h" #include "config.h" @@ -157,16 +159,17 @@ int main(int argc, char **argv) insim_init(insim_host, g_insim_port); init_cars(); - glfwInit(); - glfwWindowHint(GLFW_SAMPLES, 1); - GLFWwindow *window = glfwCreateWindow(width, height, "GL LFS Dashboard", fullscreen ? glfwGetPrimaryMonitor() : NULL, NULL); - if (window == NULL) - { - glfwTerminate(); - return 0; - } + glfwInit(); + glfwWindowHint(GLFW_SAMPLES, 1); + GLFWwindow *window = glfwCreateWindow(width, height, "GL LFS Dashboard", fullscreen ? glfwGetPrimaryMonitor() : NULL, NULL); + if (window == NULL) + { + printf("Could not create window\n"); + glfwTerminate(); + return 0; + } - glfwSetWindowTitle(window, "GL LFS Dashboard"); + glfwSetWindowTitle(window, "GL LFS Dashboard"); audio_init(); @@ -403,24 +406,27 @@ int main(int argc, char **argv) pthread_t thread; pthread_create(&thread, NULL, &socket_run, NULL); - FTGLfont *font = ftglCreateTextureFont("arialbd.ttf"); //"Arial.ttf");//"/usr/share/fonts/truetype/msttcorefonts/Arial.ttf"); + FTGLfont *font = ftglCreateOutlineFont("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"); //"Arial.ttf");//"/usr/share/fonts/truetype/msttcorefonts/Arial.ttf"); // DS_DIGII - if (!font) + if (!font) { + fprintf(stderr, "Unable to open font\n"); return 0; + } - ftglSetFontFaceSize(font, TEXT_SIZE, TEXT_SIZE); + ftglSetFontFaceSize(font, TEXT_SIZE, 0); - glGenTextures(1, s_symbols); - glBindTexture(GL_TEXTURE_2D, s_symbols[0]); -// glfwLoadTexture2D("symbols512.tga", GLFW_BUILD_MIPMAPS_BIT); + glGenTextures(1, s_symbols); + glBindTexture(GL_TEXTURE_2D, s_symbols[0]); + SOIL_load_OGL_texture("symbols512.png", 0, 1, SOIL_FLAG_MIPMAPS); + // glfwLoadTexture2D("symbols512.tga", GLFW_BUILD_MIPMAPS_BIT); + // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, ) - - // Use trilinear interpolation for minification - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - // Use bilinear interpolation for magnification - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); - // Enable texturing - //glEnable(GL_TEXTURE_2D); + // Use trilinear interpolation for minification + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + // Use bilinear interpolation for magnification + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); + // Enable texturing + // glEnable(GL_TEXTURE_2D); int s1 = FX_OFF; int s2 = FX_OFF; @@ -558,19 +564,18 @@ int main(int argc, char **argv) }*/ } - - glfwGetFramebufferSize(window, &width, &height); - height = height > 0 ? height : 1; - glViewport(0, 0, width, height); - glClearColor(0.0, 0.0, 0.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_ALPHA_TEST); - glEnable(GL_LINE_SMOOTH); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, width, 0, height, -100, 100); + glfwGetFramebufferSize(window, &width, &height); + height = height > 0 ? height : 1; + glViewport(0, 0, width, height); + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_ALPHA_TEST); + glEnable(GL_LINE_SMOOTH); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, width, 0, height, -100, 100); // socket_run(); @@ -1038,23 +1043,23 @@ int main(int argc, char **argv) glEnd(); } - glfwSwapBuffers(window); - glfwPollEvents(); + glfwSwapBuffers(window); + glfwPollEvents(); // printf("%f\n", g_outgauge.speed * 2.23693629); - running = !glfwGetKey(window, GLFW_KEY_ESCAPE) && glfwGetWindowAttrib( GLFW_OPENED) && !glfwGetMouseButton(1); -/* - int wheel = glfwGetMouseWheel(); - if (wheel >= 1) { - zoom = 65536.0 * wheel; - } else { - zoom = 65536 / (-wheel + 2); - } -*/ - //printf("%u %u %u\n", g_outgauge.flags, g_outgauge.dashlights, g_outgauge.showlights); + running = !glfwGetKey(window, GLFW_KEY_ESCAPE) && !glfwWindowShouldClose(window) && !glfwGetMouseButton(window, 1); + /* + int wheel = glfwGetMouseWheel(); + if (wheel >= 1) { + zoom = 65536.0 * wheel; + } else { + zoom = 65536 / (-wheel + 2); + } + */ + // printf("%u %u %u\n", g_outgauge.flags, g_outgauge.dashlights, g_outgauge.showlights); - usleep(100); + usleep(1000); } s_running = 0; diff --git a/symbtols512.png b/symbtols512.png new file mode 100644 index 0000000..843a757 Binary files /dev/null and b/symbtols512.png differ diff --git a/text.c b/text.c index 9a03127..9a6abed 100644 --- a/text.c +++ b/text.c @@ -1,4 +1,4 @@ -#include +#include #include #include "text.h"