[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16178] branches/apricot/source: Apricot Branch

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Aug 18 20:16:32 CEST 2008


Revision: 16178
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16178
Author:   blendix
Date:     2008-08-18 20:16:32 +0200 (Mon, 18 Aug 2008)

Log Message:
-----------
Apricot Branch
==============

* Added support for the realtime image "Anim" option for GLSL textures.
  Note that "Tiles" is not supported, i.e. it doesn't scale the texture
  for you, but that may even be desirable.
* Further there was some refactoring to remove duplicated and unused
  opengl texture code for GLSL.

Modified Paths:
--------------
    branches/apricot/source/blender/gpu/GPU_draw.h
    branches/apricot/source/blender/gpu/GPU_extensions.h
    branches/apricot/source/blender/gpu/GPU_material.h
    branches/apricot/source/blender/gpu/intern/gpu_codegen.c
    branches/apricot/source/blender/gpu/intern/gpu_codegen.h
    branches/apricot/source/blender/gpu/intern/gpu_draw.c
    branches/apricot/source/blender/gpu/intern/gpu_extensions.c
    branches/apricot/source/blender/gpu/intern/gpu_material.c
    branches/apricot/source/blender/src/header_image.c
    branches/apricot/source/gameengine/Ketsji/BL_BlenderShader.cpp
    branches/apricot/source/gameengine/Ketsji/BL_BlenderShader.h
    branches/apricot/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
    branches/apricot/source/gameengine/Ketsji/KX_PolygonMaterial.cpp

Modified: branches/apricot/source/blender/gpu/GPU_draw.h
===================================================================
--- branches/apricot/source/blender/gpu/GPU_draw.h	2008-08-18 17:08:25 UTC (rev 16177)
+++ branches/apricot/source/blender/gpu/GPU_draw.h	2008-08-18 18:16:32 UTC (rev 16178)
@@ -103,7 +103,8 @@
 
 void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h);
 void GPU_update_images_framechange(void);
-int GPU_update_image_time(struct MTFace *tface, double time);
+int GPU_update_image_time(struct Image *ima, double time);
+int GPU_verify_image(struct Image *ima, int tftile, int tfmode);
 void GPU_free_image(struct Image *ima);
 void GPU_free_images(void);
 

Modified: branches/apricot/source/blender/gpu/GPU_extensions.h
===================================================================
--- branches/apricot/source/blender/gpu/GPU_extensions.h	2008-08-18 17:08:25 UTC (rev 16177)
+++ branches/apricot/source/blender/gpu/GPU_extensions.h	2008-08-18 18:16:32 UTC (rev 16178)
@@ -70,10 +70,11 @@
 	- if created with from_blender, will not free the texture
 */
 
-GPUTexture *GPU_texture_create_1D(int w, float *pixels, int halffloat);
-GPUTexture *GPU_texture_create_2D(int w, int h, float *pixels, int halffloat);
+GPUTexture *GPU_texture_create_1D(int w, float *pixels);
+GPUTexture *GPU_texture_create_2D(int w, int h, float *pixels);
 GPUTexture *GPU_texture_create_depth(int w, int h);
-GPUTexture *GPU_texture_from_blender(struct Image *ima, struct ImageUser *iuser);
+GPUTexture *GPU_texture_from_blender(struct Image *ima,
+	struct ImageUser *iuser, double time);
 void GPU_texture_free(GPUTexture *tex);
 
 void GPU_texture_ref(GPUTexture *tex);
@@ -81,17 +82,11 @@
 void GPU_texture_bind(GPUTexture *tex, int number);
 void GPU_texture_unbind(GPUTexture *tex);
 
-int GPU_texture_width(GPUTexture *tex);
-int GPU_texture_height(GPUTexture *tex);
-
-int GPU_texture_is_half_float(GPUTexture *tex);
 GPUFrameBuffer *GPU_texture_framebuffer(GPUTexture *tex);
 
 int GPU_texture_target(GPUTexture *tex);
-
 int GPU_texture_opengl_width(GPUTexture *tex);
 int GPU_texture_opengl_height(GPUTexture *tex);
-void GPU_texture_coord_2f(GPUTexture *tex, float s, float t);
 
 /* GPU Framebuffer
    - this is a wrapper for an OpenGL framebuffer object (FBO). in practice

Modified: branches/apricot/source/blender/gpu/GPU_material.h
===================================================================
--- branches/apricot/source/blender/gpu/GPU_material.h	2008-08-18 17:08:25 UTC (rev 16177)
+++ branches/apricot/source/blender/gpu/GPU_material.h	2008-08-18 18:16:32 UTC (rev 16178)
@@ -124,7 +124,7 @@
 
 void GPU_materials_free();
 
-void GPU_material_bind(GPUMaterial *material, int lay);
+void GPU_material_bind(GPUMaterial *material, int lay, double time);
 void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4]);
 void GPU_material_unbind(GPUMaterial *material);
 

Modified: branches/apricot/source/blender/gpu/intern/gpu_codegen.c
===================================================================
--- branches/apricot/source/blender/gpu/intern/gpu_codegen.c	2008-08-18 17:08:25 UTC (rev 16177)
+++ branches/apricot/source/blender/gpu/intern/gpu_codegen.c	2008-08-18 18:16:32 UTC (rev 16178)
@@ -819,7 +819,7 @@
 	GPU_shader_unbind(shader);
 }
 
-void GPU_pass_bind(GPUPass *pass)
+void GPU_pass_bind(GPUPass *pass, double time)
 {
 	GPUInput *input;
 	GPUShader *shader = pass->shader;
@@ -833,7 +833,7 @@
 	/* now bind the textures */
 	for (input=inputs->first; input; input=input->next) {
 		if (input->ima)
-			input->tex = GPU_texture_from_blender(input->ima, input->iuser);
+			input->tex = GPU_texture_from_blender(input->ima, input->iuser, time);
 
 		if(input->ima || input->tex) {
 			if(input->tex) {
@@ -977,11 +977,11 @@
 		input->textype = type;
 
 		if (type == GPU_TEX1D) {
-			input->tex = GPU_texture_create_1D(link->texturesize, link->ptr1, 0);
+			input->tex = GPU_texture_create_1D(link->texturesize, link->ptr1);
 			input->textarget = GL_TEXTURE_1D;
 		}
 		else {
-			input->tex = GPU_texture_create_2D(link->texturesize, link->texturesize, link->ptr2, 0);
+			input->tex = GPU_texture_create_2D(link->texturesize, link->texturesize, link->ptr2);
 			input->textarget = GL_TEXTURE_2D;
 		}
 

Modified: branches/apricot/source/blender/gpu/intern/gpu_codegen.h
===================================================================
--- branches/apricot/source/blender/gpu/intern/gpu_codegen.h	2008-08-18 17:08:25 UTC (rev 16177)
+++ branches/apricot/source/blender/gpu/intern/gpu_codegen.h	2008-08-18 18:16:32 UTC (rev 16178)
@@ -71,7 +71,7 @@
 
 struct GPUShader *GPU_pass_shader(GPUPass *pass);
 
-void GPU_pass_bind(GPUPass *pass);
+void GPU_pass_bind(GPUPass *pass, double time);
 void GPU_pass_update_uniforms(GPUPass *pass);
 void GPU_pass_unbind(GPUPass *pass);
 

Modified: branches/apricot/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- branches/apricot/source/blender/gpu/intern/gpu_draw.c	2008-08-18 17:08:25 UTC (rev 16177)
+++ branches/apricot/source/blender/gpu/intern/gpu_draw.c	2008-08-18 18:16:32 UTC (rev 16178)
@@ -185,19 +185,18 @@
 /* Current OpenGL state caching for GPU_set_tpage */
 
 static struct GPUTextureState {
-	int curtile, curmode;
-	int curtileXRep, curtileYRep;
-	Image *curima;
-	short texwindx, texwindy;
-	short texwinsx, texwinsy;
+	int curtile, tile;
+	int curtilemode, tilemode;
+	int curtileXRep, tileXRep;
+	int curtileYRep, tileYRep;
+	Image *ima, *curima;
+
 	int domipmap, linearmipmap;
 
 	int alphamode;
 	MTFace *lasttface;
+} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, NULL};
 
-	int tilemode, tileXRep, tileYRep;
-} GTS = {0, 0, 0, 0, NULL, 0, 0, 0, 0, 1, 0, -1, NULL, 0, 0, 0};
-
 /* Mipmap settings */
 
 void GPU_set_mipmap(int mipmap)
@@ -257,12 +256,12 @@
 	GTS.lasttface= 0;
 	GTS.curtile= 0;
 	GTS.curima= 0;
-	if(GTS.curmode!=0) {
+	if(GTS.curtilemode!=0) {
 		glMatrixMode(GL_TEXTURE);
 		glLoadIdentity();
 		glMatrixMode(GL_MODELVIEW);
 	}
-	GTS.curmode= 0;
+	GTS.curtilemode= 0;
 	GTS.curtileXRep=0;
 	GTS.curtileYRep=0;
 	GTS.alphamode= -1;
@@ -336,112 +335,92 @@
 	}
 }
 
-static int gpu_verify_tile(MTFace *tface, Image *ima)
+int GPU_verify_image(Image *ima, int tftile, int tfmode)
 {
+	ImBuf *ibuf = NULL;
+	unsigned int *bind = NULL;
+	int rectw, recth, tpx=0, tpy=0, y;
+	unsigned int *rectrow, *tilerectrow;
+	unsigned int *tilerect= NULL, *scalerect= NULL, *rect= NULL;
+	short texwindx, texwindy, texwinsx, texwinsy;
+
 	/* initialize tile mode and number of repeats */
-	GTS.tilemode= tface->mode & TF_TILES;
+	GTS.ima = ima;
+	GTS.tilemode= (tfmode & TF_TILES) || (ima && (ima->tpageflag & IMA_TWINANIM));
 	GTS.tileXRep = 0;
 	GTS.tileYRep = 0;
 
+	/* setting current tile according to frame */
+	if(ima && (ima->tpageflag & IMA_TWINANIM))
+		GTS.tile= ima->lastframe;
+	else
+		GTS.tile= tftile;
+
 	if(ima) {
 		GTS.tileXRep = ima->xrep;
 		GTS.tileYRep = ima->yrep;
 	}
 
 	/* if same image & tile, we're done */
-	if(ima == GTS.curima && GTS.curtile == tface->tile &&
-	   GTS.tilemode == GTS.curmode && GTS.curtileXRep == GTS.tileXRep &&
+	if(ima == GTS.curima && GTS.curtile == GTS.tile &&
+	   GTS.tilemode == GTS.curtilemode && GTS.curtileXRep == GTS.tileXRep &&
 	   GTS.curtileYRep == GTS.tileYRep)
 		return (ima!=0);
 
 	/* if tiling mode or repeat changed, change texture matrix to fit */
-	if(GTS.tilemode!=GTS.curmode || GTS.curtileXRep!=GTS.tileXRep ||
+	if(GTS.tilemode!=GTS.curtilemode || GTS.curtileXRep!=GTS.tileXRep ||
 	   GTS.curtileYRep != GTS.tileYRep) {
 
 		glMatrixMode(GL_TEXTURE);
 		glLoadIdentity();
-		
-		if(GTS.tilemode && ima!=NULL)
+
+		if((tfmode & TF_TILES) && ima!=NULL)
 			glScalef(ima->xrep, ima->yrep, 1.0);
 
 		glMatrixMode(GL_MODELVIEW);
 	}
 
-	return 1;
-}
-
-static int gpu_verify_image_bind(MTFace *tface, Image *ima)
-{
-	ImBuf *ibuf = NULL;
-	unsigned int *bind = NULL;
-	int rectw, recth, tpx=0, tpy=0, y;
-	unsigned int *rectrow, *tilerectrow;
-	unsigned int *tilerect= NULL, *scalerect= NULL, *rect= NULL;
-
 	/* check if we have a valid image */
-	if(ima==NULL || ima->ok==0) {
-		glDisable(GL_TEXTURE_2D);
-		
-		GTS.curtile= tface->tile;
-		GTS.curima= 0;
-		GTS.curmode= GTS.tilemode;
-		GTS.curtileXRep = GTS.tileXRep;
-		GTS.curtileYRep = GTS.tileYRep;
-
+	if(ima==NULL || ima->ok==0)
 		return 0;
-	}
 
 	/* check if we have a valid image buffer */
 	ibuf= BKE_image_get_ibuf(ima, NULL);
 
-	if(ibuf==NULL) {
-		glDisable(GL_TEXTURE_2D);
-
-		GTS.curtile= tface->tile;
-		GTS.curima= 0;
-		GTS.curmode= GTS.tilemode;
-		GTS.curtileXRep = GTS.tileXRep;
-		GTS.curtileYRep = GTS.tileYRep;
-		
+	if(ibuf==NULL)
 		return 0;
-	}
 
 	/* ensure we have a char buffer and not only float */
 	if ((ibuf->rect==NULL) && ibuf->rect_float)
 		IMB_rect_from_float(ibuf);
 
-	/* setting current tile according to frame */
-	if(ima->tpageflag & IMA_TWINANIM)
-		GTS.curtile= ima->lastframe;
-	else
-		GTS.curtile= tface->tile;
-
 	if(GTS.tilemode) {
 		/* tiled mode */
 		if(ima->repbind==0) gpu_make_repbind(ima);
-		if(GTS.curtile>=ima->totbind) GTS.curtile= 0;
+		if(GTS.tile>=ima->totbind) GTS.tile= 0;
 		
 		/* this happens when you change repeat buttons */
-		if(ima->repbind) bind= ima->repbind+GTS.curtile;
+		if(ima->repbind) bind= &ima->repbind[GTS.tile];
 		else bind= &ima->bindcode;
 		
 		if(*bind==0) {
 			
-			GTS.texwindx= ibuf->x/ima->xrep;
-			GTS.texwindy= ibuf->y/ima->yrep;
+			texwindx= ibuf->x/ima->xrep;
+			texwindy= ibuf->y/ima->yrep;
 			
-			if(GTS.curtile>=ima->xrep*ima->yrep) GTS.curtile= ima->xrep*ima->yrep-1;
+			if(GTS.tile>=ima->xrep*ima->yrep)
+				GTS.tile= ima->xrep*ima->yrep-1;
 	
-			GTS.texwinsy= GTS.curtile / ima->xrep;
-			GTS.texwinsx= GTS.curtile - GTS.texwinsy*ima->xrep;
+			texwinsy= GTS.tile / ima->xrep;
+			texwinsx= GTS.tile - texwinsy*ima->xrep;
 	
-			GTS.texwinsx*= GTS.texwindx;
-			GTS.texwinsy*= GTS.texwindy;
+			texwinsx*= texwindx;
+			texwinsy*= texwindy;
 	
-			tpx= GTS.texwindx;
-			tpy= GTS.texwindy;
+			tpx= texwindx;
+			tpy= texwindy;
 
-			rect= ibuf->rect + GTS.texwinsy*ibuf->x + GTS.texwinsx;
+			rect= ibuf->rect + texwinsy*ibuf->x + texwinsx;
 		}
 	}
 	else {
@@ -455,17 +434,15 @@
 		}
 	}
 
-	rectw = tpx;
-	recth = tpy;
-
 	if(*bind != 0) {
 		/* enable opengl drawing with textures */
 		glBindTexture(GL_TEXTURE_2D, *bind);
-		glEnable(GL_TEXTURE_2D);
-
-		return 1;
+		return *bind;
 	}
 
+	rectw = tpx;
+	recth = tpy;
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list