Browse Source

add initial GL vertex buffer code

jp9000 12 years ago
parent
commit
1b3b177583

+ 1 - 1
libobs-opengl/gl-shader.c

@@ -96,7 +96,7 @@ static inline bool gl_add_params(struct gs_shader *shader,
 static void gl_add_sampler(struct gs_shader *shader,
 		struct shader_sampler *sampler)
 {
-	struct gs_sampler new_sampler = {0};
+	struct gs_sampler_state new_sampler = {0};
 	struct gs_sampler_info info;
 
 	shader_sampler_convert(sampler, &info);

+ 7 - 17
libobs-opengl/gl-subsystem.c

@@ -17,7 +17,7 @@
 
 #include "gl-subsystem.h"
 
-void convert_sampler_info(struct gs_sampler *sampler,
+void convert_sampler_info(struct gs_sampler_state *sampler,
 		struct gs_sampler_info *info)
 {
 	convert_filter(info->filter, &sampler->min_filter,
@@ -103,11 +103,13 @@ texture_t device_create_volumetexture(device_t device, uint32_t width,
 samplerstate_t device_create_samplerstate(device_t device,
 		struct gs_sampler_info *info)
 {
-}
+	struct gs_sampler_state *sampler;
 
-vertbuffer_t device_create_vertexbuffer(device_t device,
-		struct vb_data *data, uint32_t flags)
-{
+	sampler = bmalloc(sizeof(struct gs_sampler_state));
+	memset(sampler, 0, sizeof(struct gs_sampler_state));
+
+	convert_sampler_info(sampler, info);
+	return sampler;
 }
 
 indexbuffer_t device_create_indexbuffer(device_t device,
@@ -357,18 +359,6 @@ void samplerstate_destroy(samplerstate_t samplerstate)
 {
 }
 
-void vertexbuffer_destroy(vertbuffer_t vertbuffer)
-{
-}
-
-void vertexbuffer_flush(vertbuffer_t vertbuffer, bool rebuild)
-{
-}
-
-struct vb_data *vertexbuffer_getdata(vertbuffer_t vertbuffer)
-{
-}
-
 void indexbuffer_destroy(indexbuffer_t indexbuffer)
 {
 }

+ 21 - 7
libobs-opengl/gl-subsystem.h

@@ -181,10 +181,10 @@ static inline GLint convert_address_mode(enum gs_address_mode mode)
 	}
 }
 
-extern void convert_sampler_info(struct gs_sampler *sampler,
+extern void convert_sampler_info(struct gs_sampler_state *sampler,
 		struct gs_sampler_info *info);
 
-struct gs_sampler {
+struct gs_sampler_state {
 	GLint min_filter;
 	GLint mag_filter;
 	GLint address_u;
@@ -209,15 +209,29 @@ struct shader_param {
 };
 
 struct gs_shader {
-	device_t         device;
-	enum shader_type type;
-	GLuint           program;
+	device_t            device;
+	enum shader_type    type;
+	GLuint              program;
 
 	struct shader_param *viewproj;
 	struct shader_param *world;
 
-	DARRAY(struct gs_sampler)   samplers;
-	DARRAY(struct shader_param) params;
+	DARRAY(struct gs_sampler_state) samplers;
+	DARRAY(struct shader_param)     params;
+};
+
+struct gs_vertex_buffer {
+	GLuint               vertex_buffer;
+	GLuint               normal_buffer;
+	GLuint               tangent_buffer;
+	GLuint               color_buffer;
+	DARRAY(GLuint)       uv_buffers;
+
+	device_t             device;
+	bool                 dyanmic;
+	struct vb_data       *vbd;
+	size_t               num_verts;
+	DARRAY(size_t)       uv_sizes;
 };
 
 struct gs_texture {

+ 35 - 0
libobs-opengl/gl-vertexbuffer.c

@@ -0,0 +1,35 @@
+/******************************************************************************
+    Copyright (C) 2013 by Hugh Bailey <[email protected]>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+******************************************************************************/
+
+#include "gl-subsystem.h"
+
+vertbuffer_t device_create_vertexbuffer(device_t device,
+		struct vb_data *data, uint32_t flags)
+{
+}
+
+void vertexbuffer_destroy(vertbuffer_t vertbuffer)
+{
+}
+
+void vertexbuffer_flush(vertbuffer_t vertbuffer, bool rebuild)
+{
+}
+
+struct vb_data *vertexbuffer_getdata(vertbuffer_t vertbuffer)
+{
+}