[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48550] branches/soc-2012-swiss_cheese/ source/blender/gpu: Adding GPU object:
Alexander Kuznetsov
kuzsasha at gmail.com
Tue Jul 3 18:15:03 CEST 2012
Revision: 48550
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48550
Author: alexk
Date: 2012-07-03 16:15:02 +0000 (Tue, 03 Jul 2012)
Log Message:
-----------
Adding GPU object:
Handles Vertex and Normal drawings as they are different between ES and desktop version.
In future, it should handle color, textures, maybe effects.
How it does it:
Desktop version:
* Calls usual gl functions for doing these things. For example glVertexPointer
ES version:
* Gets location of corresponding attributes at shader creation.
* Also stores matrixes' locations
* Before drawing, we select corresponding storage to the shader/object
* When we call functions, we set attribute to given pointer at recorded location
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/source/blender/gpu/CMakeLists.txt
Added Paths:
-----------
branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_object.h
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object.c
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gl11.c
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gl11.h
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gles.c
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gles.h
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/CMakeLists.txt
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/CMakeLists.txt 2012-07-03 16:04:26 UTC (rev 48549)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/CMakeLists.txt 2012-07-03 16:15:02 UTC (rev 48550)
@@ -57,9 +57,9 @@
intern/gpu_material.c
intern/gpu_matrix.c
intern/gpu_primitives.c
- #intern/gpu_object.c
- #intern/gpu_object_gles.c
- #intern/gpu_object_gl11.c
+ intern/gpu_object.c
+ intern/gpu_object_gles.c
+ intern/gpu_object_gl11.c
intern/gpu_functions.c
shaders/gpu_shader_material.glsl.c
@@ -79,7 +79,7 @@
GPU_matrix.h
GPU_lighting.h
GPU_primitives.h
- #GPU_object.h
+ GPU_object.h
GPU_functions.h
intern/gpu_codegen.h
@@ -87,8 +87,8 @@
intern/gpu_immediate.h
intern/gpu_immediate_inline.h
intern/gpu_immediate_internal.h
- #intern/gpu_object_gles.h
- #intern/gpu_object_gl11.h
+ intern/gpu_object_gles.h
+ intern/gpu_object_gl11.h
intern/gpu_primitives_inline.h
)
Added: branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_object.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_object.h (rev 0)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_object.h 2012-07-03 16:15:02 UTC (rev 48550)
@@ -0,0 +1,24 @@
+typedef struct GPU_object_func
+{
+ void (*gpuVertexPointer)(int size, int type, int stride, const void *pointer);
+ void (*gpuNormalPointer)( int type, int stride, const void *pointer);
+ void (*gpuColorPointer )(int size, int type, int stride, const void *pointer);
+
+
+
+
+
+} GPU_object_func;
+
+extern GPU_object_func gpugameobj;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GPU_init_object_func(void);
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
Added: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object.c (rev 0)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object.c 2012-07-03 16:15:02 UTC (rev 48550)
@@ -0,0 +1,31 @@
+#include "GPU_object.h"
+#ifdef GLES
+#include "gpu_object_gles.h"
+#else
+#include "gpu_object_gl11.h"
+#endif
+
+GPU_object_func gpugameobj = {0};
+
+
+void GPU_init_object_func(void)
+{
+#ifdef GLES
+
+gpugameobj.gpuVertexPointer = gpuVertexPointer_gles;
+gpugameobj.gpuNormalPointer = gpuNormalPointer_gles;
+gpugameobj.gpuColorPointer = gpuColorPointer_gles;
+
+
+#else
+
+gpugameobj.gpuVertexPointer = gpuVertexPointer_gl11;
+gpugameobj.gpuNormalPointer = gpuNormalPointer_gl11;
+gpugameobj.gpuColorPointer = gpuColorPointer_gl11;
+
+#endif
+
+
+
+
+}
Added: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gl11.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gl11.c (rev 0)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gl11.c 2012-07-03 16:15:02 UTC (rev 48550)
@@ -0,0 +1,31 @@
+
+#ifndef GLES
+
+#include "GL/glew.h"
+
+
+
+
+
+void gpuVertexPointer_gl11(int size, int type, int stride, const void *pointer)
+{
+ glVertexPointer(size, type, stride, pointer);
+}
+
+void gpuNormalPointer_gl11(int type, int stride, const void *pointer)
+{
+ glNormalPointer(type, stride, pointer);
+
+}
+
+void gpuColorPointer_gl11 (int size, int type, int stride, const void *pointer)
+{
+
+
+
+
+
+
+}
+
+#endif
Added: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gl11.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gl11.h (rev 0)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gl11.h 2012-07-03 16:15:02 UTC (rev 48550)
@@ -0,0 +1,7 @@
+#ifndef GLES
+
+void gpuVertexPointer_gl11(int size, int type, int stride, const void *pointer);
+void gpuNormalPointer_gl11( int type, int stride, const void *pointer);
+void gpuColorPointer_gl11 (int size, int type, int stride, const void *pointer);
+
+#endif
Added: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gles.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gles.c (rev 0)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gles.c 2012-07-03 16:15:02 UTC (rev 48550)
@@ -0,0 +1,63 @@
+
+#ifdef GLES
+
+#include <GLES2/gl2.h>
+#include "gpu_object_gles.h"
+
+#include "GPU_functions.h"
+
+#include REAL_GL_MODE
+struct GPUGLSL_ES_info *curglslesi = 0;
+
+
+
+void gpuVertexPointer_gles(int size, int type, int stride, const void *pointer)
+{
+ if(curglslesi && (curglslesi->vertexloc!=-1))
+ {
+ glEnableVertexAttribArray(curglslesi->vertexloc);
+ glVertexAttribPointer(curglslesi->vertexloc, size, type, 0, stride, pointer);
+ }
+}
+
+void gpuNormalPointer_gles(int type, int stride, const void *pointer)
+{
+
+ if(curglslesi && (curglslesi->normalloc!=-1))
+ {
+ glEnableVertexAttribArray(curglslesi->normalloc);
+ glVertexAttribPointer(curglslesi->normalloc, 3, type, 0, stride, pointer);
+ }
+}
+
+void gpuColorPointer_gles (int size, int type, int stride, const void *pointer)
+{
+
+
+
+
+
+
+}
+
+void gpu_set_shader_es(struct GPUGLSL_ES_info * s, int update)
+{
+ curglslesi = s;
+// if(update)
+// GPU_matrix_forced_update();
+}
+
+
+void gpu_assign_gles_loc(GPUGLSL_ES_info * glslesinfo, unsigned int program)
+{
+ glslesinfo->normalmatloc = gpuGetUniformLocation(program, "b_NormalMatrix");
+ glslesinfo->viewmatloc = gpuGetUniformLocation(program, "b_ModelViewMatrix");
+ glslesinfo->projectionmatloc = gpuGetUniformLocation(program, "b_ProjectionMatrix");
+
+ glslesinfo->vertexloc = gpuGetAttribLocation(program, "b_Vertex");
+ glslesinfo->normalloc = gpuGetAttribLocation(program, "b_Normal");
+}
+
+
+
+#endif
Added: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gles.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gles.h (rev 0)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gles.h 2012-07-03 16:15:02 UTC (rev 48550)
@@ -0,0 +1,34 @@
+#ifdef GLES
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct GPUGLSL_ES_info
+{
+ int viewmatloc;
+ int normalmatloc;
+ int projectionmatloc;
+
+
+ int vertexloc;
+ int normalloc;
+
+
+} GPUGLSL_ES_info;
+
+extern struct GPUGLSL_ES_info *curglslesi;
+
+void gpu_assign_gles_loc(struct GPUGLSL_ES_info * glslesinfo, unsigned int program);
+
+void gpu_set_shader_es(struct GPUGLSL_ES_info * s, int update);
+
+void gpuVertexPointer_gles(int size, int type, int stride, const void *pointer);
+void gpuNormalPointer_gles( int type, int stride, const void *pointer);
+void gpuColorPointer_gles (int size, int type, int stride, const void *pointer);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
More information about the Bf-blender-cvs
mailing list