Revision: 49751
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49751
Author:   alexk
Date:     2012-08-10 00:40:10 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Adding gpu_view module.
It has functions like setting the viewport and clearing it.
Afaik it should be compatible with DirectX
We need gpuClear = glClear because calling color with depth clear is more 
efficent.
I will commit most conversions tomorrow.

It is much easier than doing REAL_GL_MODE to each viewport function.

Modified Paths:
--------------
    branches/soc-2012-swiss_cheese/source/blender/gpu/CMakeLists.txt
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_extensions.c

Added Paths:
-----------
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view.c
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view.h
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view_gl.c
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view_gl.h

Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/CMakeLists.txt
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/CMakeLists.txt    
2012-08-10 00:04:15 UTC (rev 49750)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/CMakeLists.txt    
2012-08-10 00:40:10 UTC (rev 49751)
@@ -45,8 +45,8 @@
 )
 
 set(SRC
-    intern/gpu_aspect.c
-    intern/gpu_aspectfuncs.c
+       intern/gpu_aspect.c
+       intern/gpu_aspectfuncs.c
        intern/gpu_buffers.c
        intern/gpu_codegen.c
        intern/gpu_debug.c
@@ -66,6 +66,8 @@
        intern/gpu_object_gles.c
        intern/gpu_object_gl11.c
        intern/gpu_functions.c
+       intern/gpu_view.c
+       intern/gpu_view_gl.c
        
        shaders/gpu_shader_material.glsl.c
        shaders/gpu_shader_vertex.glsl.c
@@ -88,10 +90,10 @@
        GPU_fx.h
 
        intern/gpu_aspect.h
-    intern/gpu_aspectfuncs.h
+       intern/gpu_aspectfuncs.h
        intern/gpu_codegen.h
        intern/gpu_deprecated.h
-    intern/gpu_glew.h
+       intern/gpu_glew.h
        intern/gpu_immediate.h
        intern/gpu_immediate_inline.h
        intern/gpu_immediate_internal.h
@@ -101,7 +103,9 @@
        intern/gpu_object_gles.h
        intern/gpu_object_gl11.h
        intern/gpu_primitives_inline.h
-    intern/gpu_safety.h
+       intern/gpu_safety.h
+       intern/gpu_view.h
+       intern/gpu_view_gl.h
 )
 
 if(WITH_MOD_SMOKE)

Modified: 
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_extensions.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_extensions.c   
2012-08-10 00:04:15 UTC (rev 49750)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_extensions.c   
2012-08-10 00:40:10 UTC (rev 49751)
@@ -126,6 +126,7 @@
 
        glewInit();
        GPU_func_comp_init();
+       gpuInitializeViewFuncs();
        GPU_codegen_init();
 
        /* glewIsSupported("GL_VERSION_2_0") */
@@ -849,7 +850,7 @@
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, tex->fb->object);
 
        /* push matrices and set default viewport and matrix */
-       glViewport(0, 0, w, h);
+       gpuViewport(0, 0, w, h);
        GG.currentfb = tex->fb->object;
 
        gpuMatrixMode(GL_PROJECTION);
@@ -924,7 +925,7 @@
        GPU_shader_bind(blur_shader);
        GPU_shader_uniform_vector(blur_shader, scale_uniform, 2, 1, 
(float*)scaleh);
        GPU_shader_uniform_texture(blur_shader, texture_source_uniform, tex);
-       glViewport(0, 0, GPU_texture_opengl_width(blurtex), 
GPU_texture_opengl_height(blurtex));
+       gpuViewport(0, 0, GPU_texture_opengl_width(blurtex), 
GPU_texture_opengl_height(blurtex));
 
        /* Peparing to draw quad */
        gpuMatrixMode(GL_TEXTURE);
@@ -949,7 +950,7 @@
        /* Blurring vertically */
 
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb->object);
-       glViewport(0, 0, GPU_texture_opengl_width(tex), 
GPU_texture_opengl_height(tex));
+       gpuViewport(0, 0, GPU_texture_opengl_width(tex), 
GPU_texture_opengl_height(tex));
        GPU_shader_uniform_vector(blur_shader, scale_uniform, 2, 1, 
(float*)scalev);
        GPU_shader_uniform_texture(blur_shader, texture_source_uniform, 
blurtex);
        GPU_texture_bind(blurtex, 0);

Added: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view.c         
                (rev 0)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view.c 
2012-08-10 00:40:10 UTC (rev 49751)
@@ -0,0 +1,50 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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 2
+ * 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Alexandr Kuznetsov
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#define GPU_VIEW_INTERN
+#include "gpu_view.h"
+#include "gpu_view_gl.h"
+
+
+void gpuInitializeViewFuncs(void)
+{
+
+gpuColorAndClear = gpuColorAndClear_gl;
+gpuSetClearColor = gpuSetClearColor_gl;
+
+gpuColorAndClearvf = gpuColorAndClearvf_gl;
+gpuSetClearColorvf = gpuSetClearColorvf_gl;
+
+
+gpuViewport = gpuViewport_gl;
+gpuScissor = gpuScissor_gl;
+gpuViewportScissor = gpuViewportScissor_gl;
+gpuGetScissorBox = gpuGetScissorBox_gl;
+
+gpuClear = gpuClear_gl;
+
+}

Added: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view.h         
                (rev 0)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view.h 
2012-08-10 00:40:10 UTC (rev 49751)
@@ -0,0 +1,63 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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 2
+ * 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Alexandr Kuznetsov
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#if !defined(GPU_VIEW_H) || defined(GPU_VIEW_INTERN)
+#define GPU_VIEW_H
+
+#ifndef GPU_VIEW_INTERN
+#define GPU_VIEW_FUNC extern
+#else
+#define GPU_VIEW_FUNC
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void gpuInitializeViewFuncs(void);
+
+GPU_VIEW_FUNC void (* gpuColorAndClear)(float r, float g, float b, float a);
+GPU_VIEW_FUNC void (* gpuSetClearColor)(float r, float g, float b, float a);
+
+GPU_VIEW_FUNC void (* gpuColorAndClearvf)(float c[3], float a);
+GPU_VIEW_FUNC void (* gpuSetClearColorvf)(float c[3], float a);
+
+GPU_VIEW_FUNC void (* gpuClear)(int mask);
+
+GPU_VIEW_FUNC void (* gpuViewport)(int x, int y, unsigned int width, unsigned 
int height);
+GPU_VIEW_FUNC void (* gpuScissor)(int x, int y, unsigned int width, unsigned 
int height);
+GPU_VIEW_FUNC void (* gpuViewportScissor)(int x, int y, unsigned int width, 
unsigned int height);
+
+GPU_VIEW_FUNC void (*gpuGetScissorBox)(int *box);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
\ No newline at end of file

Added: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view_gl.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view_gl.c      
                        (rev 0)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view_gl.c      
2012-08-10 00:40:10 UTC (rev 49751)
@@ -0,0 +1,90 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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 2
+ * 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Alexandr Kuznetsov
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "gpu_glew.h"
+#include "gpu_view_gl.h"
+#include REAL_GL_MODE
+#include <stdlib.h>
+void gpuColorAndClear_gl(float r, float g, float b, float a)
+{
+       gpuSetClearColor_gl(r, g, b, a);
+       glClear(GL_COLOR_BUFFER_BIT);
+
+}
+
+void gpuSetClearColor_gl(float r, float g, float b, float a)
+{
+       glClearColor(r, g, b, a);
+       
//glClearColor((float)rand()/RAND_MAX,(float)rand()/RAND_MAX,(float)rand()/RAND_MAX,0);
+
+}
+
+void gpuColorAndClearvf_gl(float c[3], float a)
+{
+       gpuSetClearColorvf_gl(c, a);
+       glClear(GL_COLOR_BUFFER_BIT);
+}
+
+void gpuSetClearColorvf_gl(float c[3], float a)
+{
+       glClearColor(c[0], c[1], c[2], a);
+       
//glClearColor((float)rand()/RAND_MAX,(float)rand()/RAND_MAX,(float)rand()/RAND_MAX,0);
+
+}
+
+
+void gpuViewport_gl(int x, int y, unsigned int width, unsigned int height)
+{
+       glViewport(x, y, width, height);
+
+}
+
+
+void gpuScissor_gl(int x, int y, unsigned int width, unsigned int height)
+{
+glEnable(GL_SCISSOR_TEST);
+       glScissor(x, y, width, height);
+       
//gpuColorAndClear_gl((float)rand()/RAND_MAX,(float)rand()/RAND_MAX,(float)rand()/RAND_MAX,0);
+       
//gpuSetClearColor_gl((float)rand()/RAND_MAX,(float)rand()/RAND_MAX,(float)rand()/RAND_MAX,0);
+}
+
+void gpuGetScissorBox_gl(int *box)
+{
+       glGetIntegerv(GL_SCISSOR_BOX, box);
+}
+
+void gpuViewportScissor_gl(int x, int y, unsigned int width, unsigned int 
height)
+{
+       gpuViewport_gl(x, y, width, height);
+       gpuScissor_gl(x, y, width, height);
+}
+
+
+void gpuClear_gl(int mask)
+{
+       glClear(mask);
+}

Added: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view_gl.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view_gl.h      
                        (rev 0)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_view_gl.h      
2012-08-10 00:40:10 UTC (rev 49751)
@@ -0,0 +1,45 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to