Skip to content

Commit

Permalink
Tweak renderer/vendor strings
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaivel committed Jul 5, 2024
1 parent dd2e18b commit 6c08ba2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions inc/server/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct overlay_context {
clock_t fps;
};

void overlay_set_renderer_string(char *string);
void overlay_enable();
void overlay_stage1(struct overlay_context *ctx);
void overlay_stage2(struct overlay_context *ctx, int *frame, int width, size_t mem_usage);
Expand Down
8 changes: 4 additions & 4 deletions src/client/glimpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,8 +1271,8 @@ const GLubyte *glGetString(GLenum name)
static char version[16] = "X.X.0";
static char glsl_vr[5] = "X.X0";

static char real_vendor[256] = "";
static char real_renderer[256] = "";
static char real_vendor[256] = "SharedGL and ";
static char real_renderer[256] = "SharedGL using ";

if (version[0] == 'X') {
version[0] = '0' + (char)glimpl_major;
Expand Down Expand Up @@ -1303,15 +1303,15 @@ const GLubyte *glGetString(GLenum name)
gl_vendor_override[256] = 0;
strcpy(real_vendor, gl_vendor_override);
} else {
real_glGetString(GL_VENDOR, real_vendor);
real_glGetString(GL_VENDOR, real_vendor + 13);
}

if (gl_renderer_override) {
if (strlen(gl_renderer_override) >= 256)
gl_renderer_override[256] = 0;
strcpy(real_renderer, gl_renderer_override);
} else {
real_glGetString(GL_RENDERER, real_renderer);
real_glGetString(GL_RENDERER, real_renderer + 15);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/server/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
static bool is_vid_init = false;
static int mw = 1920;
static int mh = 1080;
static bool is_overlay_string_init = false;

void sgl_set_max_resolution(int width, int height)
{
Expand Down Expand Up @@ -62,6 +63,12 @@ struct sgl_host_context *sgl_context_create()
}

sgl_set_current(context);

if (!is_overlay_string_init) {
overlay_set_renderer_string((char*)glGetString(GL_RENDERER));
is_overlay_string_init = true;
}

return context;
}

Expand Down
9 changes: 8 additions & 1 deletion src/server/overlay.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <server/overlay.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>

static const unsigned char IBM[4096] =
Expand Down Expand Up @@ -1068,6 +1069,12 @@ static void overlay_draw_text(int *display, int width, char *text, int x, int y,
}

static bool overlay_enabled = false;
static char overlay_string[256] = "SharedGL using ";

void overlay_set_renderer_string(char *string)
{
strcpy(overlay_string + 15, string);
}

void overlay_enable()
{
Expand Down Expand Up @@ -1106,7 +1113,7 @@ void overlay_stage2(struct overlay_context *ctx, int *frame, int width, size_t m
sprintf(str, "FPS: %ld", ctx->fps);
sprintf(mem, "MEM: %.2f %s", usage, is_mb ? "MB" : "KB");

overlay_draw_text(frame, width, "SharedGL Renderer", 0, 0, 0xffffff);
overlay_draw_text(frame, width, overlay_string, 0, 0, 0xffffff);
overlay_draw_text(frame, width, mem, 0, 16, 0xffffff);
overlay_draw_text(frame, width, str, 0, 32, 0xffffff);
}
Expand Down

0 comments on commit 6c08ba2

Please sign in to comment.