Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/bad_level_call_stubs/stubs.c39
-rw-r--r--source/blender/blenkernel/intern/sca.c3
-rw-r--r--source/blender/blenloader/intern/readfile.c4
-rw-r--r--source/blender/blenloader/intern/writefile.c3
-rw-r--r--source/blender/include/blendef.h1
-rw-r--r--source/blender/makesdna/DNA_actuator_types.h33
-rw-r--r--source/blender/src/buttons_logic.c60
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp10
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp10
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h7
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp83
-rw-r--r--source/gameengine/GameLogic/CMakeLists.txt1
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.cpp118
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.h44
-rw-r--r--source/gameengine/GameLogic/SConscript1
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.cpp10
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.h6
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp6
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp12
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.h4
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.cpp340
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.h91
-rw-r--r--source/gameengine/Rasterizer/RAS_IRenderTools.h16
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h54
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h54
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h53
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h44
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h44
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h56
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h61
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h44
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h55
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h60
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp77
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h12
35 files changed, 1463 insertions, 53 deletions
diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c
index 1bcbed1efb1..0421b5cadca 100644
--- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c
+++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c
@@ -57,8 +57,6 @@ struct RenderResult;
struct Object;
struct bPythonConstraint;
struct bConstraintOb;
-struct bConstraintTarget;
-struct ListBase;
char *getIpoCurveName( struct IpoCurve * icu );
void insert_vert_icu(struct IpoCurve *icu, float x, float y, short fast);
@@ -130,12 +128,16 @@ int BPY_button_eval(char *expr, double *value)
}
/* PyConstraints - BPY_interface.c */
-void BPY_pyconstraint_eval(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets)
+void BPY_pyconstraint_eval(struct bPythonConstraint *con, float ownermat[][4], float targetmat[][4])
{
}
-void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct)
+void BPY_pyconstraint_driver(struct bPythonConstraint *con, struct bConstraintOb *cob, struct Object *target, char subtarget[])
{
}
+int BPY_pyconstraint_targets(struct bPythonConstraint *con, float targetmat[][4])
+{
+ return 0;
+}
/* writefile.c */
@@ -208,9 +210,6 @@ void IK_FreeSolver(IK_Solver *solver) {};
void IK_SolverAddGoal(IK_Solver *solver, IK_Segment *tip, float goal[3], float weight) {}
void IK_SolverAddGoalOrientation(IK_Solver *solver, IK_Segment *tip, float goal[][3], float weight) {}
-void IK_SolverSetPoleVectorConstraint(IK_Solver *solver, IK_Segment *tip, float goal[3], float polegoal[3], float poleangle, int getangle) {}
-float IK_SolverGetPoleAngle(IK_Solver *solver) { return 0.0f; }
-
int IK_Solve(IK_Solver *solver, float tolerance, int max_iterations) { return 0; }
/* exotic.c */
@@ -246,8 +245,6 @@ void fluidsimSettingsCopy(struct FluidsimSettings* sb) {}
/*new render funcs */
int externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta) { return 0; }
-void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg, int blendtype) {}
-float texture_value_blend(float tex, float out, float fact, float facg, int blendtype, int flip) { return 0; }
void RE_FreeRenderResult(struct RenderResult *rr) {}
void RE_GetResultImage(struct Render *re, struct RenderResult *rr) {}
@@ -262,7 +259,7 @@ void RE_FreeRender(Render *re) {}
void RE_shade_external(Render *re, ShadeInput *shi, ShadeResult *shr) {}
void RE_DataBase_GetView(Render *re, float mat[][4]) {}
struct Render *RE_NewRender(const char *name) {return (struct Render *)NULL;}
-void RE_Database_Baking(struct Render *re, struct Scene *scene, int type, struct Object *actob) {};
+void RE_Database_Baking(struct Render *re, struct Scene *scene, int make_faces) {};
/* node_composite.c */
@@ -310,6 +307,15 @@ void post_geometry_free_constraint(struct VNode *vnode) {}
void post_layer_create(struct VLayer *vlayer) {}
void post_layer_destroy(struct VLayer *vlayer) {}
void post_server_add(void) {}
+ /* Multires/sculpt stubs */
+struct MultiresLevel *multires_level_n(struct Multires *mr, int n) {return NULL;}
+void multires_free(struct Multires *mr) {}
+void multires_set_level(struct Object *ob, struct Mesh *me, const int render) {}
+void multires_update_levels(struct Mesh *me, const int render) {}
+void multires_calc_level_maps(struct MultiresLevel *lvl) {}
+struct Multires *multires_copy(struct Multires *orig) {return NULL;}
+void sculptmode_init(struct Scene *sce) {}
+void sculptmode_free_all(struct Scene *sce) {}
/* zbuf.c stub */
void antialias_tagbuf(int xsize, int ysize, char *rectmove) {}
@@ -324,16 +330,3 @@ void BIF_filelist_freelib(struct FileList* filelist) {};
/* edittime.c stub */
TimeMarker *get_frame_marker(int frame){return 0;};
-
-/* editseq.c */
-Sequence *get_forground_frame_seq(int frame){return 0;};
-
-/* modifier.c stub */
-void harmonic_coordinates_bind(struct MeshDeformModifierData *mmd,
- float (*vertexcos)[3], int totvert, float cagemat[][4]) {}
-
-/* particle.c */
-void PE_free_particle_edit(struct ParticleSystem *psys) {}
-void PE_get_colors(char sel[4], char nosel[4]) {}
-void PE_recalc_world_cos(struct Object *ob, struct ParticleSystem *psys) {}
-
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index e772a3bcdb4..88afa8d5e61 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -461,6 +461,9 @@ void init_actuator(bActuator *act)
case ACT_VISIBILITY:
act->data= MEM_callocN(sizeof(bVisibilityActuator), "visibility act");
break;
+ case ACT_2DFILTER:
+ act->data = MEM_callocN(sizeof( bTwoDFilterActuator ), "2d filter act");
+ break;
default:
; /* this is very severe... I cannot make any memory for this */
/* logic brick... */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6b07821a03c..e663bd35fa4 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2948,6 +2948,10 @@ static void lib_link_object(FileData *fd, Main *main)
bMessageActuator *ma= act->data;
ma->toObject= newlibadr(fd, ob->id.lib, ma->toObject);
}
+ else if(act->type==ACT_2DFILTER){
+ bTwoDFilterActuator *_2dfa = act->data;
+ _2dfa->text= newlibadr(fd, ob->id.lib, _2dfa->text);
+ }
act= act->next;
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index afd12d96860..d9766af6ba1 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -719,6 +719,9 @@ static void write_actuators(WriteData *wd, ListBase *lb)
case ACT_VISIBILITY:
writestruct(wd, DATA, "bVisibilityActuator", 1, act->data);
break;
+ case ACT_2DFILTER:
+ writestruct(wd, DATA, "bTwoDFilterActuator", 1, act->data);
+ break;
default:
; /* error: don't know how to write this file */
}
diff --git a/source/blender/include/blendef.h b/source/blender/include/blendef.h
index 36ae384467d..4ded73f10b6 100644
--- a/source/blender/include/blendef.h
+++ b/source/blender/include/blendef.h
@@ -462,5 +462,6 @@
/* Error messages */
#define ERROR_LIBDATA_MESSAGE "Can't edit external libdata"
+#define MAX_RENDER_PASS 100
#endif
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
index 0531e70bb97..0d324b7d5d3 100644
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ b/source/blender/makesdna/DNA_actuator_types.h
@@ -38,6 +38,7 @@ struct Object;
struct Mesh;
struct Scene;
struct Group;
+struct Text;
/* ****************** ACTUATORS ********************* */
@@ -191,6 +192,19 @@ typedef struct bVisibilityActuator {
int flag;
} bVisibilityActuator;
+typedef struct bTwoDFilterActuator{
+ char pad[4];
+ /* Tells what type of 2D Filter*/
+ short type;
+ /* (flag == 0) means 2D filter is activate and
+ (flag != 0) means 2D filter is inactive*/
+ short flag;
+ int int_arg;
+ /* a float argument */
+ float float_arg;
+ struct Text *text;
+}bTwoDFilterActuator;
+
typedef struct bActuator {
struct bActuator *next, *prev, *mynew;
short type;
@@ -259,6 +273,7 @@ typedef struct FreeCamera {
#define ACT_CD 16
#define ACT_GAME 17
#define ACT_VISIBILITY 18
+#define ACT_2DFILTER 19
/* actuator flag */
#define ACT_SHOW 1
@@ -391,5 +406,23 @@ typedef struct FreeCamera {
/* Set means the object will become invisible */
#define ACT_VISIBILITY_INVISIBLE (1 << 0)
+/* twodfilter->type */
+#define ACT_2DFILTER_ENABLED -2
+#define ACT_2DFILTER_DISABLED -1
+#define ACT_2DFILTER_NOFILTER 0
+#define ACT_2DFILTER_MOTIONBLUR 1
+#define ACT_2DFILTER_BLUR 2
+#define ACT_2DFILTER_SHARPEN 3
+#define ACT_2DFILTER_DILATION 4
+#define ACT_2DFILTER_EROSION 5
+#define ACT_2DFILTER_LAPLACIAN 6
+#define ACT_2DFILTER_SOBEL 7
+#define ACT_2DFILTER_PREWITT 8
+#define ACT_2DFILTER_GRAYSCALE 9
+#define ACT_2DFILTER_SEPIA 10
+#define ACT_2DFILTER_INVERT 11
+#define ACT_2DFILTER_CUSTOMFILTER 12
+#define ACT_2DFILTER_NUMBER_OF_FILTERS 13
#endif
+
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index 77922f041d8..819f7bbaa24 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -712,6 +712,8 @@ static char *actuator_name(int type)
return "Game";
case ACT_VISIBILITY:
return "Visibility";
+ case ACT_2DFILTER:
+ return "2D Filter";
}
return "unknown";
}
@@ -727,13 +729,13 @@ static char *actuator_pup(Object *owner)
return "Actuators %t|Action %x15|Motion %x0|Constraint %x9|Ipo %x1"
"|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
"|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17"
- "|Visibility %x18";
+ "|Visibility %x18|2D Filter %x19";
break;
default:
return "Actuators %t|Motion %x0|Constraint %x9|Ipo %x1"
"|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
"|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17"
- "|Visibility %x18";
+ "|Visibility %x18|2D Filter %x19";
}
}
@@ -1476,6 +1478,7 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho
bActionActuator *aa = NULL;
bGameActuator *gma = NULL;
bVisibilityActuator *visAct = NULL;
+ bTwoDFilterActuator *tdfa = NULL;
float *fp;
short ysize = 0, wval;
@@ -2172,6 +2175,58 @@ static short draw_actuatorbuttons(bActuator *act, uiBlock *block, short xco, sho
yco -= ysize;
break;
+ case ACT_2DFILTER:
+ tdfa = act->data;
+
+ ysize = 50;
+ if(tdfa->type == ACT_2DFILTER_CUSTOMFILTER)
+ {
+ ysize +=20;
+ }
+ glRects( xco, yco-ysize, xco+width, yco );
+ uiEmboss( (float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1 );
+
+ switch(tdfa->type)
+ {
+ case ACT_2DFILTER_MOTIONBLUR:
+ if(!tdfa->flag)
+ {
+ uiDefButS(block, TOG, B_REDR, "D", xco+30,yco-44,19, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Disable Motion Blur");
+ uiDefButF(block, NUM, B_REDR, "Value:", xco+52,yco-44,width-82,19,&tdfa->float_arg,0.0,1.0,0.0,0.0,"Set motion blur value");
+ }
+ else
+ {
+ uiDefButS(block, TOG, B_REDR, "Disabled", xco+30,yco-44,width-60, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Enable Motion Blur");
+ }
+ break;
+ case ACT_2DFILTER_BLUR:
+ case ACT_2DFILTER_SHARPEN:
+ case ACT_2DFILTER_DILATION:
+ case ACT_2DFILTER_EROSION:
+ case ACT_2DFILTER_LAPLACIAN:
+ case ACT_2DFILTER_SOBEL:
+ case ACT_2DFILTER_PREWITT:
+ case ACT_2DFILTER_GRAYSCALE:
+ case ACT_2DFILTER_SEPIA:
+ case ACT_2DFILTER_INVERT:
+ case ACT_2DFILTER_NOFILTER:
+ case ACT_2DFILTER_DISABLED:
+ case ACT_2DFILTER_ENABLED:
+ uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30,yco-44,width-60,19,&tdfa->int_arg,0.0,MAX_RENDER_PASS-1,0.0,0.0,"Set motion blur value");
+ break;
+ case ACT_2DFILTER_CUSTOMFILTER:
+ uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30,yco-44,width-60,19,&tdfa->int_arg,0.0,MAX_RENDER_PASS-1,0.0,0.0,"Set motion blur value");
+ uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Script: ", xco+30,yco-64,width-60, 19, &tdfa->text, "");
+ break;
+ }
+
+ str= "2D Filter %t|Motion Blur %x1|Blur %x2|Sharpen %x3|Dilation %x4|Erosion %x5|"
+ "Laplacian %x6|Sobel %x7|Prewitt %x8|Gray Scale %x9|Sepia %x10|Invert %x11|Custom Filter %x12|"
+ "Enable Filter %x-2|Disable Filter %x-1|Remove Filter %x0|";
+ uiDefButS(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &tdfa->type, 0.0, 0.0, 0.0, 0.0, "2D filter type");
+
+ yco -= ysize;
+ break;
default:
ysize= 4;
@@ -2812,3 +2867,4 @@ void logic_buts(void)
if(idar) MEM_freeN(idar);
}
+
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 0c42a35c808..e89c78614cc 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -176,9 +176,13 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
bool lock_arrays = (displaylists && useVertexArrays);
- if(displaylists && !useVertexArrays)
- rasterizer = new RAS_ListRasterizer(canvas);
- else if (useVertexArrays && bgl::QueryVersion(1, 1))
+ if(displaylists){
+ if (useVertexArrays) {
+ rasterizer = new RAS_ListRasterizer(canvas, true, lock_arrays);
+ } else {
+ rasterizer = new RAS_ListRasterizer(canvas);
+ }
+ } else if (useVertexArrays && bgl::QueryVersion(1, 1))
rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays);
else
rasterizer = new RAS_OpenGLRasterizer(canvas);
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
index 463f06869d6..7e32ade37f2 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
@@ -475,4 +475,14 @@ void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
}
}
+void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
+{
+ m_filtermanager.EnableFilter(filtermode, pass, text);
+}
+
+void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas)
+{
+ m_filtermanager.RenderFilters(canvas);
+}
+
unsigned int KX_BlenderRenderTools::m_numgllights;
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
index a79302a283e..3c2d4ac8e35 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
@@ -55,6 +55,7 @@ class KX_BlenderRenderTools : public RAS_IRenderTools
bool m_lastlighting;
static unsigned int m_numgllights;
+
public:
KX_BlenderRenderTools();
@@ -102,8 +103,14 @@ public:
bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data);
virtual void MotionBlur(RAS_IRasterizer* rasterizer);
+
+ virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
+
+ virtual void Render2DFilters(RAS_ICanvas* canvas);
+
};
#endif //__KX_BLENDERRENDERTOOLS
+
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index a6baa04b045..89a07abe21d 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -37,6 +37,8 @@
#define BLENDER_HACK_DTIME 0.02
+#include "MEM_guardedalloc.h"
+
#include "KX_BlenderSceneConverter.h"
#include "KX_ConvertActuators.h"
@@ -45,6 +47,7 @@
#include "SCA_PropertyActuator.h"
#include "SCA_LogicManager.h"
#include "SCA_RandomActuator.h"
+#include "SCA_2DFilterActuator.h"
// Ketsji specific logicbricks
@@ -69,7 +72,7 @@
#include "KX_GameObject.h"
/* This little block needed for linking to Blender... */
-
+#include "BKE_text.h"
#include "BLI_blenlib.h"
#include "KX_NetworkMessageActuator.h"
@@ -836,7 +839,84 @@ void BL_ConvertActuators(char* maggiename,
baseact = tmp_vis_act;
}
break;
+
+ case ACT_2DFILTER:
+ {
+ bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data;
+ SCA_2DFilterActuator *tmp = NULL;
+ RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode;
+ switch(_2dfilter->type)
+ {
+ case ACT_2DFILTER_MOTIONBLUR:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR;
+ break;
+ case ACT_2DFILTER_BLUR:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_BLUR;
+ break;
+ case ACT_2DFILTER_SHARPEN:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_SHARPEN;
+ break;
+ case ACT_2DFILTER_DILATION:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_DILATION;
+ break;
+ case ACT_2DFILTER_EROSION:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_EROSION;
+ break;
+ case ACT_2DFILTER_LAPLACIAN:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_LAPLACIAN;
+ break;
+ case ACT_2DFILTER_SOBEL:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_SOBEL;
+ break;
+ case ACT_2DFILTER_PREWITT:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_PREWITT;
+ break;
+ case ACT_2DFILTER_GRAYSCALE:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_GRAYSCALE;
+ break;
+ case ACT_2DFILTER_SEPIA:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_SEPIA;
+ break;
+ case ACT_2DFILTER_INVERT:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_INVERT;
+ break;
+ case ACT_2DFILTER_CUSTOMFILTER:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER;
+ break;
+ case ACT_2DFILTER_NOFILTER:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
+ break;
+ case ACT_2DFILTER_DISABLED:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_DISABLED;
+ break;
+ case ACT_2DFILTER_ENABLED:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED;
+ break;
+ default:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
+ break;
+ }
+
+ tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag,
+ _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools);
+
+ if (_2dfilter->text)
+ {
+ char *buf;
+ // this is some blender specific code
+ buf = txt_to_buf(_2dfilter->text);
+ if (buf)
+ {
+ tmp->SetShaderText(STR_String(buf));
+ MEM_freeN(buf);
+ }
+ }
+
+ baseact = tmp;
+
+ }
+ break;
default:
; /* generate some error */
}
@@ -860,3 +940,4 @@ void BL_ConvertActuators(char* maggiename,
}
}
+
diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt
index 127edfc151d..4f40fa22b9e 100644
--- a/source/gameengine/GameLogic/CMakeLists.txt
+++ b/source/gameengine/GameLogic/CMakeLists.txt
@@ -35,6 +35,7 @@ SET(INC
../../../intern/string
../../../source/gameengine/Expressions
../../../intern/moto/include
+ ../../../source/gameengine/Rasterizer
${PYTHON_INC}
${SDL_INC}
)
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
new file mode 100644
index 00000000000..9627ad92c4c
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
@@ -0,0 +1,118 @@
+#include "SCA_IActuator.h"
+
+#include "SCA_2DFilterActuator.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <iostream>
+
+
+SCA_2DFilterActuator::~SCA_2DFilterActuator()
+{
+}
+
+SCA_2DFilterActuator::SCA_2DFilterActuator(
+ SCA_IObject *gameobj,
+ RAS_2DFilterManager::RAS_2DFILTER_MODE type,
+ short flag,
+ float float_arg,
+ int int_arg,
+ RAS_IRasterizer* rasterizer,
+ RAS_IRenderTools* rendertools,
+ PyTypeObject* T)
+ : SCA_IActuator(gameobj, T),
+ m_type(type),
+ m_flag(flag),
+ m_int_arg(int_arg),
+ m_float_arg(float_arg),
+ m_rasterizer(rasterizer),
+ m_rendertools(rendertools)
+{
+}
+
+void SCA_2DFilterActuator::SetShaderText(STR_String& text)
+{
+ m_shaderText = text;
+}
+
+
+
+CValue* SCA_2DFilterActuator::GetReplica()
+{
+ SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this);
+ replica->ProcessReplica();
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+}
+
+
+bool SCA_2DFilterActuator::Update()
+{
+ bool result = false;
+
+ bool bNegativeEvent = IsNegativeEvent();
+ RemoveAllEvents();
+
+
+ if (bNegativeEvent)
+ return false; // do nothing on negative events
+
+ if( m_type == RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR )
+ {
+ if(!m_flag)
+ {
+ m_rasterizer->EnableMotionBlur(m_float_arg);
+ }
+ else
+ {
+ m_rasterizer->DisableMotionBlur();
+ }
+ }
+ else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS)
+ {
+ m_rendertools->Update2DFilter(m_type, m_int_arg, m_shaderText);
+ }
+ return true;
+}
+
+
+PyTypeObject SCA_2DFilterActuator::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "SCA_2DFilterActuator",
+ sizeof(SCA_2DFilterActuator),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0,
+ __repr,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+
+PyParentObject SCA_2DFilterActuator::Parents[] = {
+ &SCA_2DFilterActuator::Type,
+ &SCA_IActuator::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+
+PyMethodDef SCA_2DFilterActuator::Methods[] = {
+ /* add python functions to deal with m_msg... */
+ {NULL,NULL}
+};
+
+
+PyObject* SCA_2DFilterActuator::_getattr(const STR_String& attr) {
+ _getattr_up(SCA_IActuator);
+}
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
new file mode 100644
index 00000000000..76df95ac399
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
@@ -0,0 +1,44 @@
+#ifndef __SCA_2DFILETRACTUATOR_H__
+#define __SCA_2DFILETRACTUATOR_H__
+
+#include "RAS_IRasterizer.h"
+#include "RAS_IRenderTools.h"
+#include "SCA_IActuator.h"
+
+
+class SCA_2DFilterActuator : public SCA_IActuator
+{
+ Py_Header;
+
+private:
+
+ RAS_2DFilterManager::RAS_2DFILTER_MODE m_type;
+ short m_flag;
+ float m_float_arg;
+ int m_int_arg;
+ STR_String m_shaderText;
+ RAS_IRasterizer* m_rasterizer;
+ RAS_IRenderTools* m_rendertools;
+
+public:
+
+ SCA_2DFilterActuator(
+ class SCA_IObject* gameobj,
+ RAS_2DFilterManager::RAS_2DFILTER_MODE type,
+ short flag,
+ float float_arg,
+ int int_arg,
+ RAS_IRasterizer* rasterizer,
+ RAS_IRenderTools* rendertools,
+ PyTypeObject* T=&Type
+ );
+
+ void SetShaderText(STR_String& text);
+ virtual ~SCA_2DFilterActuator();
+ virtual bool Update();
+
+ virtual CValue* GetReplica();
+ virtual PyObject* _getattr(const STR_String& attr);
+
+};
+#endif
diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript
index 7a2c3d91e72..1ca884f6dec 100644
--- a/source/gameengine/GameLogic/SConscript
+++ b/source/gameengine/GameLogic/SConscript
@@ -5,6 +5,7 @@ sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp')
incs = '. #/source/kernel/gen_system #/intern/string'
incs += ' #/source/gameengine/Expressions #/intern/moto/include'
+incs += ' #/source/gameengine/Rasterizer'
incs += ' ' + env['BF_PYTHON_INC']
incs += ' ' + env['BF_SDL_INC']
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
index cc5c392d51a..388882e67e4 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
@@ -593,4 +593,14 @@ void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
}
}
+void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
+{
+ m_filtermanager.EnableFilter(filtermode, pass, text);
+}
+
+void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas)
+{
+ m_filtermanager.RenderFilters( canvas);
+}
+
unsigned int GPC_RenderTools::m_numgllights;
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
index e1f2a869c22..d90f0e5da45 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
@@ -151,6 +151,11 @@ public:
bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data);
virtual void MotionBlur(RAS_IRasterizer* rasterizer);
+
+ virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
+
+ virtual void Render2DFilters(RAS_ICanvas* canvas);
+
protected:
/**
* Copied from KX_BlenderGL.cpp in KX_blenderhook
@@ -176,3 +181,4 @@ protected:
#endif // __GPC_RENDERTOOLS_H
+
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index 4f6c78a0fd8..5ef20514390 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -537,7 +537,11 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
goto initFailed;
if(useLists)
- m_rasterizer = new RAS_ListRasterizer(m_canvas);
+ if (useVertexArrays) {
+ m_rasterizer = new RAS_ListRasterizer(m_canvas, true);
+ } else {
+ m_rasterizer = new RAS_ListRasterizer(m_canvas);
+ }
else if (useVertexArrays && bgl::QueryVersion(1, 1))
m_rasterizer = new RAS_VAOpenGLRasterizer(m_canvas);
else
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index f8826245aab..e0a826b8d5d 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -966,13 +966,18 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
scene->CalculateVisibleMeshes(m_rasterizer,cam);
scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
+
+ PostRenderFrame();
+}
+void KX_KetsjiEngine::PostRenderFrame()
+{
+ m_rendertools->PushMatrix();
+ m_rendertools->Render2DFilters(m_canvas);
m_rendertools->MotionBlur(m_rasterizer);
-
+ m_rendertools->PopMatrix();
}
-
-
void KX_KetsjiEngine::StopEngine()
{
if (m_bInitialized)
@@ -1467,3 +1472,4 @@ void KX_KetsjiEngine::GetOverrideFrameColor(float& r, float& g, float& b) const
}
+
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h
index 16b53b6b688..fcb4d0a0790 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.h
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h
@@ -179,6 +179,7 @@ private:
void SetupRenderFrame(KX_Scene *scene, KX_Camera* cam);
void RenderFrame(KX_Scene* scene, KX_Camera* cam);
+ void PostRenderFrame();
void RenderDebugProperties();
void SetBackGround(KX_WorldInfo* worldinfo);
void SetWorldSettings(KX_WorldInfo* worldinfo);
@@ -201,6 +202,8 @@ public:
void SetSceneConverter(KX_ISceneConverter* sceneconverter);
void SetGame2IpoMode(bool game2ipo,int startFrame);
+ RAS_IRasterizer* GetRasterizer(){return m_rasterizer;};
+
///returns true if an update happened to indicate -> Render
bool NextFrame();
void Render();
@@ -342,3 +345,4 @@ protected:
#endif //__KX_KETSJI_ENGINE
+
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
new file mode 100644
index 00000000000..7b895258c1e
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
@@ -0,0 +1,340 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#define STRINGIFY(A) #A
+
+#include "RAS_OpenGLFilters/RAS_Blur2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Sharpen2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Dilation2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Erosion2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Laplacian2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Sobel2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Prewitt2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_GrayScale2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Sepia2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Invert2DFilter.h"
+
+#include "STR_String.h"
+#include "RAS_ICanvas.h"
+#include "RAS_2DFilterManager.h"
+#include <iostream>
+
+#ifdef WIN32
+// OpenGL gl.h needs 'windows.h' on windows platforms
+#include <windows.h>
+#endif //WIN32
+#ifdef __APPLE__
+#define GL_GLEXT_LEGACY 1
+#include <OpenGL/gl.h>
+#else
+#include <GL/gl.h>
+#endif
+
+#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+RAS_2DFilterManager::RAS_2DFilterManager():
+texturewidth(-1), textureheight(-1),
+canvaswidth(-1), canvasheight(-1),
+numberoffilters(0),texname(-1)
+{
+ isshadersupported = bgl::QueryVersion(2,0);
+ if(!isshadersupported)
+ {
+ std::cout<<"shaders not supported!" << std::endl;
+ return;
+ }
+
+ int passindex;
+ for(passindex =0; passindex<MAX_RENDER_PASS; passindex++)
+ {
+ m_filters[passindex] = 0;
+ m_enabled[passindex] = 0;
+ }
+
+}
+
+RAS_2DFilterManager::~RAS_2DFilterManager()
+{
+}
+
+unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource)
+{
+ GLuint program;
+ GLuint fShader = bgl::blCreateShaderObjectARB(GL_FRAGMENT_SHADER);
+ GLint success;
+
+ bgl::blShaderSourceARB(fShader, 1, (const char**)&shadersource, NULL);
+
+ bgl::blCompileShaderARB(fShader);
+
+ bgl::blGetObjectParameterivARB(fShader, GL_COMPILE_STATUS, &success);
+ if(!success)
+ {
+ /*Shader Comile Error*/
+ std::cout << "2dFilters - Shader compile error" << std::endl;
+ return 0;
+ }
+
+ program = bgl::blCreateProgramObjectARB();
+ bgl::blAttachObjectARB(program, fShader);
+
+ bgl::blLinkProgramARB(program);
+ bgl::blGetObjectParameterivARB(program, GL_LINK_STATUS, &success);
+ if (!success)
+ {
+ /*Program Link Error*/
+ std::cout << "2dFilters - Shader program link error" << std::endl;
+ return 0;
+ }
+
+ bgl::blValidateProgramARB(program);
+ bgl::blGetObjectParameterivARB(program, GL_VALIDATE_STATUS, &success);
+ if (!success)
+ {
+ /*Program Validation Error*/
+ std::cout << "2dFilters - Shader program validation error" << std::endl;
+ return 0;
+ }
+ return program;
+}
+
+unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode)
+{
+ switch(filtermode)
+ {
+ case RAS_2DFILTER_BLUR:
+ return CreateShaderProgram(BlurFragmentShader);
+ case RAS_2DFILTER_SHARPEN:
+ return CreateShaderProgram(SharpenFragmentShader);
+ case RAS_2DFILTER_DILATION:
+ return CreateShaderProgram(DilationFragmentShader);
+ case RAS_2DFILTER_EROSION:
+ return CreateShaderProgram(ErosionFragmentShader);
+ case RAS_2DFILTER_LAPLACIAN:
+ return CreateShaderProgram(LaplacionFragmentShader);
+ case RAS_2DFILTER_SOBEL:
+ return CreateShaderProgram(SobelFragmentShader);
+ case RAS_2DFILTER_PREWITT:
+ return CreateShaderProgram(PrewittFragmentShader);
+ case RAS_2DFILTER_GRAYSCALE:
+ return CreateShaderProgram(GrayScaleFragmentShader);
+ case RAS_2DFILTER_SEPIA:
+ return CreateShaderProgram(SepiaFragmentShader);
+ case RAS_2DFILTER_INVERT:
+ return CreateShaderProgram(InvertFragmentShader);
+ }
+ return 0;
+}
+
+void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram)
+{
+ GLint uniformLoc;
+ bgl::blUseProgramObjectARB(shaderprogram);
+ uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture");
+ if (uniformLoc != -1)
+ {
+ bgl::blUniform1iARB(uniformLoc, 0);
+ }
+ uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_TextureCoordinateOffset");
+ if (uniformLoc != -1)
+ {
+ bgl::blUniform2fvARB(uniformLoc, 9, textureoffsets);
+ }
+ uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureWidth");
+ if (uniformLoc != -1)
+ {
+ bgl::blUniform1fARB(uniformLoc,texturewidth);
+ }
+ uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureHeight");
+ if (uniformLoc != -1)
+ {
+ bgl::blUniform1fARB(uniformLoc,textureheight);
+ }
+
+}
+
+void RAS_2DFilterManager::EndShaderProgram()
+{
+ bgl::blUseProgramObjectARB(0);
+}
+
+void RAS_2DFilterManager::SetupTexture()
+{
+ if(texname!=-1)
+ {
+ glDeleteTextures(1,&texname);
+ }
+ glGenTextures(1, &texname);
+ glBindTexture(GL_TEXTURE_2D, texname);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGB,
+ GL_UNSIGNED_BYTE, 0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+}
+
+void RAS_2DFilterManager::UpdateOffsetMatrix(int width, int height)
+{
+ canvaswidth = texturewidth = width;
+ canvasheight = textureheight = height;
+
+ GLint i,j;
+ i = 0;
+ while ((1 << i) <= texturewidth)
+ i++;
+ texturewidth = (1 << (i));
+
+ // Now for height
+ i = 0;
+ while ((1 << i) <= textureheight)
+ i++;
+ textureheight = (1 << (i));
+
+ GLfloat xInc = 1.0f / (GLfloat)texturewidth;
+ GLfloat yInc = 1.0f / (GLfloat)textureheight;
+
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+ textureoffsets[(((i*3)+j)*2)+0] = (-1.0f * xInc) + ((GLfloat)i * xInc);
+ textureoffsets[(((i*3)+j)*2)+1] = (-1.0f * yInc) + ((GLfloat)j * yInc);
+ }
+ }
+
+ SetupTexture();
+}
+
+void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas)
+{
+ if(!isshadersupported)
+ return;
+
+ if(canvaswidth != canvas->GetWidth() || canvasheight != canvas->GetHeight())
+ {
+ UpdateOffsetMatrix(canvas->GetWidth(), canvas->GetHeight());
+ }
+ GLuint viewport[4]={0};
+
+ int passindex;
+ bool first = true;
+ for(passindex =0; passindex<MAX_RENDER_PASS; passindex++)
+ {
+ if(m_filters[passindex] && m_enabled[passindex])
+ {
+ if(first)
+ {
+ glGetIntegerv(GL_VIEWPORT,(int*)viewport);
+ glViewport(0, 0, texturewidth, textureheight);
+
+ glDisable(GL_DEPTH_TEST);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ first = false;
+ }
+
+ StartShaderProgram(m_filters[passindex]);
+
+ glBindTexture(GL_TEXTURE_2D, texname);
+ glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, texturewidth, textureheight, 0);
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_QUADS);
+ glColor4f(1.f, 1.f, 1.f, 1.f);
+ glTexCoord2f(1.0, 1.0); glVertex2f(1,1);
+ glTexCoord2f(0.0, 1.0); glVertex2f(-1,1);
+ glTexCoord2f(0.0, 0.0); glVertex2f(-1,-1);
+ glTexCoord2f(1.0, 0.0); glVertex2f(1,-1);
+ glEnd();
+ }
+ }
+
+ if(!first)
+ {
+ glEnable(GL_DEPTH_TEST);
+ glViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
+ EndShaderProgram();
+ }
+}
+
+void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text)
+{
+ if(!isshadersupported)
+ return;
+ if(pass<0 || pass>=MAX_RENDER_PASS)
+ return;
+
+ if(mode == RAS_2DFILTER_DISABLED)
+ {
+ m_enabled[pass] = 0;
+ return;
+ }
+
+ if(mode == RAS_2DFILTER_ENABLED)
+ {
+ m_enabled[pass] = 1;
+ return;
+ }
+
+ if(mode == RAS_2DFILTER_NOFILTER)
+ {
+ if(m_filters[pass])
+ bgl::blDeleteObjectARB(m_filters[pass]);
+ m_enabled[pass] = 0;
+ m_filters[pass] = 0;
+ return;
+ }
+
+ if(mode == RAS_2DFILTER_CUSTOMFILTER)
+ {
+ if(m_filters[pass])
+ bgl::blDeleteObjectARB(m_filters[pass]);
+ m_filters[pass] = CreateShaderProgram(text.Ptr());
+ m_enabled[pass] = 1;
+ return;
+ }
+
+ if(mode>=RAS_2DFILTER_MOTIONBLUR && mode<=RAS_2DFILTER_INVERT)
+ {
+ if(m_filters[pass])
+ bgl::blDeleteObjectARB(m_filters[pass]);
+ m_filters[pass] = CreateShaderProgram(mode);
+ m_enabled[pass] = 1;
+ }
+}
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h
new file mode 100644
index 00000000000..227d2a26d41
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h
@@ -0,0 +1,91 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_I2DFILTER
+#define __RAS_I2DFILTER
+
+
+
+#define MAX_RENDER_PASS 100
+
+class RAS_2DFilterManager
+{
+private:
+ unsigned int CreateShaderProgram(char* shadersource);
+ unsigned int CreateShaderProgram(int filtermode);
+ void StartShaderProgram(unsigned int shaderprogram);
+ void EndShaderProgram();
+
+ float textureoffsets[18];
+ float view[4];
+ unsigned int texname;
+ int texturewidth;
+ int textureheight;
+ int canvaswidth;
+ int canvasheight;
+ int numberoffilters;
+
+ bool isshadersupported;
+public:
+ enum RAS_2DFILTER_MODE {
+ RAS_2DFILTER_ENABLED = -2,
+ RAS_2DFILTER_DISABLED = -1,
+ RAS_2DFILTER_NOFILTER = 0,
+ RAS_2DFILTER_MOTIONBLUR,
+ RAS_2DFILTER_BLUR,
+ RAS_2DFILTER_SHARPEN,
+ RAS_2DFILTER_DILATION,
+ RAS_2DFILTER_EROSION,
+ RAS_2DFILTER_LAPLACIAN,
+ RAS_2DFILTER_SOBEL,
+ RAS_2DFILTER_PREWITT,
+ RAS_2DFILTER_GRAYSCALE,
+ RAS_2DFILTER_SEPIA,
+ RAS_2DFILTER_INVERT,
+ RAS_2DFILTER_CUSTOMFILTER,
+ RAS_2DFILTER_NUMBER_OF_FILTERS
+ };
+
+ unsigned int m_filters[MAX_RENDER_PASS];
+ short m_enabled[MAX_RENDER_PASS];
+
+ RAS_2DFilterManager();
+
+ ~RAS_2DFilterManager();
+
+ void SetupTexture();
+
+ void UpdateOffsetMatrix(int width, int height);
+
+ void RenderFilters(RAS_ICanvas* canvas);
+
+ void EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text);
+};
+#endif
diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h
index 114783b9a47..771c34a595f 100644
--- a/source/gameengine/Rasterizer/RAS_IRenderTools.h
+++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h
@@ -34,6 +34,7 @@
#include "MT_Transform.h"
#include "RAS_IRasterizer.h"
+#include "RAS_2DFilterManager.h"
#include <vector>
#include <algorithm>
@@ -41,6 +42,7 @@
class RAS_IPolyMaterial;
struct RAS_LightObject;
+
class RAS_IRenderTools
{
@@ -52,7 +54,8 @@ protected:
bool m_modified;
std::vector<struct RAS_LightObject*> m_lights;
-
+
+ RAS_2DFilterManager m_filtermanager;
public:
enum RAS_TEXT_RENDER_MODE {
@@ -61,7 +64,7 @@ public:
RAS_TEXT_PADDED,
RAS_TEXT_MAX
};
-
+
RAS_IRenderTools(
) :
m_clientobject(NULL),
@@ -178,6 +181,14 @@ public:
void
MotionBlur(RAS_IRasterizer* rasterizer)=0;
+ virtual
+ void
+ Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)=0;
+
+ virtual
+ void
+ Render2DFilters(RAS_ICanvas* canvas)=0;
+
virtual
class RAS_IPolyMaterial*
CreateBlenderPolyMaterial(
@@ -200,3 +211,4 @@ public:
#endif //__RAS_IRENDERTOOLS
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h
new file mode 100644
index 00000000000..ac4c2456573
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h
@@ -0,0 +1,54 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_BLUR2DFILTER
+#define __RAS_BLUR2DFILTER
+
+char * BlurFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ }
+
+ gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] +
+ (2.0*sample[3]) + sample[4] + (2.0*sample[5]) +
+ sample[6] + (2.0*sample[7]) + sample[8]) / 13.0;
+}
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h
new file mode 100644
index 00000000000..44f67af3d75
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h
@@ -0,0 +1,54 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_DILATION2DFILTER
+#define __RAS_DILATION2DFILTER
+
+char * DilationFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+ vec4 maxValue = vec4(0.0);
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ maxValue = max(sample[i], maxValue);
+ }
+
+ gl_FragColor = maxValue;
+}
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h
new file mode 100644
index 00000000000..80b6f184c36
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h
@@ -0,0 +1,53 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_EROSION2DFILTER
+#define __RAS_EROSION2DFILTER
+
+char * ErosionFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+ vec4 minValue = vec4(1.0);
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ minValue = min(sample[i], minValue);
+ }
+
+ gl_FragColor = minValue;
+}
+);
+#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h
new file mode 100644
index 00000000000..29cc91814ce
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h
@@ -0,0 +1,44 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_GRAYSCALE2DFILTER
+#define __RAS_GRAYSCALE2DFILTER
+
+char * GrayScaleFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+
+void main(void)
+{
+ vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
+ float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114));
+ gl_FragColor = vec4(gray, gray, gray, texcolor.a);
+}
+);
+#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h
new file mode 100644
index 00000000000..a3482f9647f
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h
@@ -0,0 +1,44 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_INVERT2DFILTER
+#define __RAS_INVERT2DFILTER
+
+char * InvertFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+
+void main(void)
+{
+ vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
+ gl_FragColor.rgb = 1.0 - texcolor.rgb;
+ gl_FragColor.a = texcolor.a;
+}
+);
+#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h
new file mode 100644
index 00000000000..636ecdb68aa
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h
@@ -0,0 +1,56 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_LAPLACION2DFILTER
+#define __RAS_LAPLACION2DFILTER
+
+char * LaplacionFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ }
+
+ gl_FragColor = (sample[4] * 8.0) -
+ (sample[0] + sample[1] + sample[2] +
+ sample[3] + sample[5] +
+ sample[6] + sample[7] + sample[8]);
+ gl_FragColor = vec4(gl_FragColor.rgb, 1.0);
+}
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h
new file mode 100644
index 00000000000..8046aacfbb1
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h
@@ -0,0 +1,61 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_PREWITT2DFILTER
+#define __RAS_PREWITT2DFILTER
+
+char * PrewittFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ }
+
+ vec4 horizEdge = sample[2] + sample[5] + sample[8] -
+ (sample[0] + sample[3] + sample[6]);
+
+ vec4 vertEdge = sample[0] + sample[1] + sample[2] -
+ (sample[6] + sample[7] + sample[8]);
+
+ gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) +
+ (vertEdge.rgb * vertEdge.rgb));
+ gl_FragColor.a = 1.0;
+}
+
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h
new file mode 100644
index 00000000000..b56911a48b4
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h
@@ -0,0 +1,44 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_SEPIA2DFILTER
+#define __RAS_SEPIA2DFILTER
+
+char * SepiaFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+
+void main(void)
+{
+ vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
+ float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114));
+ gl_FragColor = vec4(gray * vec3(1.2, 1.0, 0.8), texcolor.a);
+}
+);
+#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h
new file mode 100644
index 00000000000..e5f942a535c
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h
@@ -0,0 +1,55 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_SHARPEN2DFILTER
+#define __RAS_SHARPEN2DFILTER
+
+char * SharpenFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ }
+
+ gl_FragColor = (sample[4] * 9.0) -
+ (sample[0] + sample[1] + sample[2] +
+ sample[3] + sample[5] +
+ sample[6] + sample[7] + sample[8]);
+}
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h
new file mode 100644
index 00000000000..545e76601e8
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h
@@ -0,0 +1,60 @@
+/**
+ * ***** BEGIN GPL/BL DUAL 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_SOBEL2DFILTER
+#define __RAS_SOBEL2DFILTER
+
+char * SobelFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ }
+
+ vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] -
+ (sample[0] + (2.0*sample[3]) + sample[6]);
+
+ vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] -
+ (sample[6] + (2.0*sample[7]) + sample[8]);
+
+ gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) +
+ (vertEdge.rgb * vertEdge.rgb));
+ gl_FragColor.a = 1.0;
+}
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
index ed4cfb2ae42..7baa6c49656 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
@@ -96,8 +96,9 @@ bool RAS_ListSlot::End()
-RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas)
-: RAS_OpenGLRasterizer(canvas)
+RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays, bool lock)
+: RAS_VAOpenGLRasterizer(canvas, lock),
+ mUseVertexArrays(useVertexArrays)
{
// --
}
@@ -159,13 +160,22 @@ void RAS_ListRasterizer::IndexPrimitives(
if(localSlot->End())
return;
}
-
- RAS_OpenGLRasterizer::IndexPrimitives(
- vertexarrays, indexarrays,
- mode, polymat,
- rendertools, useObjectColor,
- rgbacolor,slot
- );
+
+ if (mUseVertexArrays) {
+ RAS_VAOpenGLRasterizer::IndexPrimitives(
+ vertexarrays, indexarrays,
+ mode, polymat,
+ rendertools, useObjectColor,
+ rgbacolor,slot
+ );
+ } else {
+ RAS_OpenGLRasterizer::IndexPrimitives(
+ vertexarrays, indexarrays,
+ mode, polymat,
+ rendertools, useObjectColor,
+ rgbacolor,slot
+ );
+ }
if(!useObjectColor) {
localSlot->EndList();
@@ -195,16 +205,53 @@ void RAS_ListRasterizer::IndexPrimitivesMulti(
return;
}
- RAS_OpenGLRasterizer::IndexPrimitivesMulti(
- vertexarrays, indexarrays,
- mode, polymat,
- rendertools, useObjectColor,
- rgbacolor,slot
- );
+ if (mUseVertexArrays) {
+ RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(
+ vertexarrays, indexarrays,
+ mode, polymat,
+ rendertools, useObjectColor,
+ rgbacolor,slot
+ );
+ } else {
+ RAS_OpenGLRasterizer::IndexPrimitivesMulti(
+ vertexarrays, indexarrays,
+ mode, polymat,
+ rendertools, useObjectColor,
+ rgbacolor,slot
+ );
+ }
+
if(!useObjectColor) {
localSlot->EndList();
*slot = localSlot;
}
}
+bool RAS_ListRasterizer::Init(void)
+{
+ if (mUseVertexArrays) {
+ return RAS_VAOpenGLRasterizer::Init();
+ } else {
+ return RAS_OpenGLRasterizer::Init();
+ }
+}
+
+void RAS_ListRasterizer::SetDrawingMode(int drawingmode)
+{
+ if (mUseVertexArrays) {
+ RAS_VAOpenGLRasterizer::SetDrawingMode(drawingmode);
+ } else {
+ RAS_OpenGLRasterizer::SetDrawingMode(drawingmode);
+ }
+}
+
+void RAS_ListRasterizer::Exit()
+{
+ if (mUseVertexArrays) {
+ RAS_VAOpenGLRasterizer::Exit();
+ } else {
+ RAS_OpenGLRasterizer::Exit();
+ }
+}
+
// eof
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
index 82840cd1399..f25f621f70c 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
@@ -2,7 +2,7 @@
#define __RAS_LISTRASTERIZER_H__
#include "RAS_MaterialBucket.h"
-#include "RAS_OpenGLRasterizer.h"
+#include "RAS_VAOpenGLRasterizer.h"
#include <vector>
class RAS_ListSlot : public KX_ListSlot
@@ -33,15 +33,16 @@ enum RAS_ListSlotFlags {
typedef std::map<const vecVertexArray, RAS_ListSlot*> RAS_Lists;
-class RAS_ListRasterizer : public RAS_OpenGLRasterizer
+class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer
{
+ bool mUseVertexArrays;
RAS_Lists mLists;
RAS_ListSlot* FindOrAdd(const vecVertexArray& vertexarrays, KX_ListSlot** slot);
void ReleaseAlloc();
public:
- RAS_ListRasterizer(RAS_ICanvas* canvas);
+ RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays=false, bool lock=false);
virtual ~RAS_ListRasterizer();
virtual void IndexPrimitives(
@@ -66,6 +67,11 @@ public:
class KX_ListSlot** slot
);
+ virtual bool Init();
+ virtual void Exit();
+
+ virtual void SetDrawingMode(int drawingmode);
+
virtual bool QueryLists(){return true;}
};