Something

wow-commits
Peter Nelson 2023-08-05 18:54:11 +01:00
parent 86dfa2637d
commit 6dfc0cc5dd
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
5 changed files with 58 additions and 53 deletions

View File

@ -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 $@

View File

@ -1,4 +1,4 @@
#include <GL/glfw.h>
#include <GLFW/glfw3.h>
#include <FTGL/ftgl.h>
#include <math.h>
#include <stdio.h>

103
lfsdash.c
View File

@ -1,9 +1,11 @@
#include <GL/glfw.h>
#include <GLFW/glfw3.h>
#include <FTGL/ftgl.h>
#include <SOIL/SOIL.h>
#include <pthread.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#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;

BIN
symbtols512.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

2
text.c
View File

@ -1,4 +1,4 @@
#include <GL/glfw.h>
#include <GLFW/glfw3.h>
#include <FTGL/ftgl.h>
#include "text.h"