From 4b8f28f70e8fcb4c47808ed150c1acbfb63f2ab0 Mon Sep 17 00:00:00 2001 From: ktyl Date: Sat, 31 Jul 2021 18:59:41 +0100 Subject: [PATCH] support nvidia prime gpu offloading --- launch | 12 ++++++++++++ makefile | 3 ++- src/gfx.c | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100755 launch diff --git a/launch b/launch new file mode 100755 index 0000000..11dc6e1 --- /dev/null +++ b/launch @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +executable="$1" +prime="prime-run" + +if command -v $prime &> /dev/null +then + echo "launching $executable with nvidia prime offloading" + $prime $executable +else + $executable +fi diff --git a/makefile b/makefile index 133c486..7eff1c0 100644 --- a/makefile +++ b/makefile @@ -17,6 +17,7 @@ SHADER_INCLUDES = $(shell find $(SHADER_INCLUDE_DIR) -name *.glsl) SHADER_TARGETS = $(SHADERS:$(SHADER_ROOT_DIR)/%.glsl=$(SHADER_TARGET_DIR)/%.compute) TARGET = $(BIN_DIR)/oglc +LAUNCH = "./launch" CC = gcc LIBS = `pkg-config --static --libs glew sdl2 cglm` @@ -47,6 +48,6 @@ clean: -rm */*.o run: $(TARGET) - $(TARGET) + $(LAUNCH) $(TARGET) .PHONY: run clean diff --git a/src/gfx.c b/src/gfx.c index dbb3ec8..d65cf05 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -48,9 +48,11 @@ SDL_Window* gfxInit(int width, int height) // intiliased opengl + printf("%s\n", glGetString(GL_RENDERER)); + int availableAttributes; glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &availableAttributes); - //printf("max vertex attributes %d\n", availableAttributes); + printf("max vertex attributes %d\n", availableAttributes); return sdlWindow; }