changeset 498:51bf87f76d15

Pull shader file names from config file.
author Mike Pavone <pavone@retrodev.com>
date Mon, 28 Oct 2013 23:59:59 -0700
parents 0820a71b80f3
children 27345a67225d
files default.cfg render_sdl.c tern.c tern.h
diffstat 4 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/default.cfg	Mon Oct 28 23:50:28 2013 -0700
+++ b/default.cfg	Mon Oct 28 23:59:59 2013 -0700
@@ -56,6 +56,8 @@
 
 video {
 	width 640
+	vertex_shader default.v.glsl
+	fragment_shader default.f.glsl
 }
 
 audio {
--- a/render_sdl.c	Mon Oct 28 23:50:28 2013 -0700
+++ b/render_sdl.c	Mon Oct 28 23:59:59 2013 -0700
@@ -181,8 +181,8 @@
 		glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
 		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
 		glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(element_data), element_data, GL_STATIC_DRAW);
-		vshader = load_shader("default.v.glsl", GL_VERTEX_SHADER);
-		fshader = load_shader("default.f.glsl", GL_FRAGMENT_SHADER);
+		vshader = load_shader(tern_find_ptr_default(config, "videovertex_shader", "default.v.glsl"), GL_VERTEX_SHADER);
+		fshader = load_shader(tern_find_ptr_default(config, "videofragment_shader", "default.f.glsl"), GL_FRAGMENT_SHADER);
 		program = glCreateProgram();
 		glAttachShader(program, vshader);
 		glAttachShader(program, fshader);
--- a/tern.c	Mon Oct 28 23:50:28 2013 -0700
+++ b/tern.c	Mon Oct 28 23:59:59 2013 -0700
@@ -1,6 +1,6 @@
 /*
  Copyright 2013 Michael Pavone
- This file is part of BlastEm. 
+ This file is part of BlastEm.
  BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
 */
 #include "tern.h"
@@ -101,13 +101,18 @@
 	return tern_insert(head, key, val);
 }
 
-void * tern_find_ptr(tern_node * head, char * key)
+void * tern_find_ptr_default(tern_node * head, char * key, void * def)
 {
 	tern_val ret;
 	if (tern_find(head, key, &ret)) {
 		return ret.ptrval;
 	}
-	return NULL;
+	return def;
+}
+
+void * tern_find_ptr(tern_node * head, char * key)
+{
+	return tern_find_ptr_default(head, key, NULL);
 }
 
 tern_node * tern_insert_ptr(tern_node * head, char * key, void * value)
--- a/tern.h	Mon Oct 28 23:50:28 2013 -0700
+++ b/tern.h	Mon Oct 28 23:59:59 2013 -0700
@@ -1,6 +1,6 @@
 /*
  Copyright 2013 Michael Pavone
- This file is part of BlastEm. 
+ This file is part of BlastEm.
  BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
 */
 #ifndef TERN_H_
@@ -28,6 +28,7 @@
 tern_node * tern_find_prefix(tern_node * head, char * key);
 intptr_t tern_find_int(tern_node * head, char * key, intptr_t def);
 tern_node * tern_insert_int(tern_node * head, char * key, intptr_t value);
+void * tern_find_ptr_default(tern_node * head, char * key, void * def);
 void * tern_find_ptr(tern_node * head, char * key);
 tern_node * tern_insert_ptr(tern_node * head, char * key, void * value);