[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50051] branches/soc-2012-swiss_cheese/ source/blender: Some texture fixes and Clean up for GLES/GLSL
Alexander Kuznetsov
kuzsasha at gmail.com
Mon Aug 20 18:09:54 CEST 2012
Revision: 50051
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50051
Author: alexk
Date: 2012-08-20 16:09:53 +0000 (Mon, 20 Aug 2012)
Log Message:
-----------
Some texture fixes and Clean up for GLES/GLSL
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_glsl.c
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c
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
branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_draw.c
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_glsl.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_glsl.c 2012-08-20 15:29:02 UTC (rev 50050)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_glsl.c 2012-08-20 16:09:53 UTC (rev 50051)
@@ -104,16 +104,18 @@
/* setup vertex arrays
Assume that vertex arrays have been disabled for everything
and only enable what is needed */
- if (GPU_IMMEDIATE->format.textureUnitCount == 0)
+ if (GPU_IMMEDIATE->format.textureUnitCount == 1)
{
- gpu_set_shader_es(&shader_main_info, 0);
+
+ gpu_set_shader_es(&shader_alphatexture_info, 0);
- gpu_glUseProgram(shader_main);
+ gpu_glUseProgram(shader_alphatexture);
+
} else
{
- gpu_set_shader_es(&shader_alphatexture_info, 0);
+ gpu_set_shader_es(&shader_main_info, 0);
- gpu_glUseProgram(shader_alphatexture);
+ gpu_glUseProgram(shader_main);
}
@@ -154,18 +156,7 @@
offset += 4 * sizeof(GLubyte);
- } else
- {
- /*gpugameobj.gpuColorPointer(
- 4 * sizeof(GLubyte),
- GL_UNSIGNED_BYTE,
- GPU_IMMEDIATE->stride,
- bufferData->ptr + offset);*/
-
-
-
- //gpugameobj.gpuColorSet( stateData.curcolor);
- }
+ }
/* texture coordinate */
@@ -181,20 +172,20 @@
}
else if (GPU_IMMEDIATE->format.textureUnitCount > 1) {
- /*for (i = 0; i < GPU_IMMEDIATE->format.textureUnitCount; i++) {
- glClientActiveTexture(GPU_IMMEDIATE->format.textureUnitMap[i]);
+ for (i = 0; i < GPU_IMMEDIATE->format.textureUnitCount; i++) {
+ /*glClientActiveTexture(GPU_IMMEDIATE->format.textureUnitMap[i]);
glTexCoordPointer(
GPU_IMMEDIATE->format.texCoordSize[i],
GL_FLOAT,
GPU_IMMEDIATE->stride,
- bufferData->ptr + offset);
+ bufferData->ptr + offset);*/
offset +=
(size_t)(GPU_IMMEDIATE->format.texCoordSize[i]) * sizeof(GLfloat);
// glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- }*/
+ }
// glClientActiveTexture(GL_TEXTURE0);
}
@@ -202,37 +193,37 @@
/* float vertex attribute */
for (i = 0; i < GPU_IMMEDIATE->format.attribCount_f; i++) {
- gpu_glVertexAttribPointer(
+ /* gpu_glVertexAttribPointer(
GPU_IMMEDIATE->format.attribIndexMap_f[i],
GPU_IMMEDIATE->format.attribSize_f[i],
GL_FLOAT,
GPU_IMMEDIATE->format.attribNormalized_f[i],
GPU_IMMEDIATE->stride,
- bufferData->ptr + offset);
+ bufferData->ptr + offset);*/
offset +=
(size_t)(GPU_IMMEDIATE->format.attribSize_f[i]) * sizeof(GLfloat);
- gpu_glEnableVertexAttribArray(
- GPU_IMMEDIATE->format.attribIndexMap_f[i]);
+ /*gpu_glEnableVertexAttribArray(
+ GPU_IMMEDIATE->format.attribIndexMap_f[i]);*/
}
/* byte vertex attribute */
for (i = 0; i < GPU_IMMEDIATE->format.attribCount_ub; i++) {
if (GPU_IMMEDIATE->format.attribSize_ub[i] > 0) {
- glVertexAttribPointer(
+ /*glVertexAttribPointer(
GPU_IMMEDIATE->format.attribIndexMap_ub[i],
GPU_IMMEDIATE->format.attribSize_ub[i],
GL_UNSIGNED_BYTE,
GPU_IMMEDIATE->format.attribNormalized_ub[i],
GPU_IMMEDIATE->stride,
- bufferData->ptr + offset);
+ bufferData->ptr + offset);*/
offset += 4 * sizeof(GLubyte);
- glEnableVertexAttribArray(
- GPU_IMMEDIATE->format.attribIndexMap_ub[i]);
+ /*glEnableVertexAttribArray(
+ GPU_IMMEDIATE->format.attribIndexMap_ub[i]);*/
}
}
@@ -298,8 +289,8 @@
}
-static short vqeos [65536*3/2];
-static char vqeoc [256*3/2];
+ short vqeos[65536*3/2];
+ char vqeoc[256*3/2];
void gpu_quad_elements_init(void)
{
@@ -311,7 +302,6 @@
if(init) return;
init = 1;
-
for(i=0, j=0; i<65536; i++, j++)
{
vqeos[j] = i;
@@ -344,17 +334,30 @@
gpugameobj.gpuColorSet( stateData.curcolor);
}
+
gpuMatrixCommit();
-
if(GPU_IMMEDIATE->mode != GL_QUADS )
+ {
+
glDrawArrays(GPU_IMMEDIATE->mode, 0, GPU_IMMEDIATE->count);
+
+ }
else
{
- if(GPU_IMMEDIATE->count <= 256)
+
+ if(GPU_IMMEDIATE->count <= 256){
+
glDrawElements(GL_TRIANGLES,GPU_IMMEDIATE->count *3/2, GL_UNSIGNED_BYTE, vqeoc);
+
+ }
else if(GPU_IMMEDIATE->count <= 65536)
+ {
+
glDrawElements(GL_TRIANGLES,GPU_IMMEDIATE->count *3/2, GL_UNSIGNED_SHORT, vqeos);
+
+
+ }
else
{
printf("To big GL_QUAD object to draw. Vertices: %i", GPU_IMMEDIATE->count);
@@ -362,7 +365,7 @@
}
-gpu_glUseProgram(0);
+
GPU_CHECK_NO_ERROR();
}
}
@@ -376,7 +379,8 @@
/* Disable any arrays that were used so that everything is off again. */
GPU_CHECK_NO_ERROR();
-
+gpu_glUseProgram(0);
+gpu_set_shader_es(0, 0);
/* vertex */
//glDisableClientState(GL_VERTEX_ARRAY);
@@ -410,13 +414,13 @@
/* float vertex attribute */
for (i = 0; i < GPU_IMMEDIATE->format.attribCount_f; i++) {
- gpu_glDisableVertexAttribArray(GPU_IMMEDIATE->format.attribIndexMap_f[i]);
+ //gpu_glDisableVertexAttribArray(GPU_IMMEDIATE->format.attribIndexMap_f[i]);
}
/* byte vertex attribute */
for (i = 0; i < GPU_IMMEDIATE->format.attribCount_ub; i++) {
- gpu_glDisableVertexAttribArray(GPU_IMMEDIATE->format.attribIndexMap_ub[i]);
+ //gpu_glDisableVertexAttribArray(GPU_IMMEDIATE->format.attribIndexMap_ub[i]);
}
GPU_CHECK_NO_ERROR();
@@ -478,7 +482,6 @@
void gpu_current_normal_glsl(void)
{
- //glNormal3fv(GPU_IMMEDIATE->normal);
copy_v3_v3(stateData.curnormal, GPU_IMMEDIATE->normal);
}
@@ -511,6 +514,7 @@
gpuMatrixCommit();
+
glDrawElements(
GPU_IMMEDIATE->mode,
index->count,
@@ -525,7 +529,7 @@
GPUindex* index = GPU_IMMEDIATE->index;
GPU_CHECK_NO_ERROR();
- gpuMatrixCommit();
+ //gpuMatrixCommit();
//glDrawArrays(GPU_IMMEDIATE->mode, 0, GPU_IMMEDIATE->count);
/*glDrawRangeElements(
GPU_IMMEDIATE->mode,
@@ -534,6 +538,8 @@
index->count,
GL_UNSIGNED_INT,
index->unmappedBuffer);*/
+
+
GPU_CHECK_NO_ERROR();
}
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c 2012-08-20 15:29:02 UTC (rev 50050)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c 2012-08-20 16:09:53 UTC (rev 50051)
@@ -267,10 +267,10 @@
glUniformMatrix4fv(curglslesi->projectionmatloc, 1, 0, ms_projection.dynstack[ms_projection.pos]);
}
- if(ms_texture.changed|| glslneedupdate)
+ //if(ms_texture.changed|| glslneedupdate)
{
- if(curglslesi->texturecoordloc!=-1)
- glUniformMatrix4fv(curglslesi->texturecoordloc, 1, 0, ms_texture.dynstack[ms_texture.pos]);
+ if(curglslesi->texturematloc!=-1)
+ glUniformMatrix4fv(curglslesi->texturematloc, 1, 0, ms_texture.dynstack[ms_texture.pos]);
}
}
Modified: 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 2012-08-20 15:29:02 UTC (rev 50050)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gles.c 2012-08-20 16:09:53 UTC (rev 50051)
@@ -64,8 +64,11 @@
if(curglslesi && (curglslesi->texturecoordloc!=-1))
{
glEnableVertexAttribArray(curglslesi->texturecoordloc);
+ //glDisableVertexAttribArray(curglslesi->texturecoordloc);
glVertexAttribPointer(curglslesi->texturecoordloc, size, type, 0, stride, pointer);
}
+ if(curglslesi && curglslesi->texidloc!=-1)
+ glUniform1i(curglslesi->texidloc, 0);
}
@@ -93,13 +96,14 @@
glslesinfo->normalmatloc = gpu_glGetUniformLocation(program, "b_NormalMatrix");
glslesinfo->viewmatloc = gpu_glGetUniformLocation(program, "b_ModelViewMatrix");
glslesinfo->projectionmatloc = gpu_glGetUniformLocation(program, "b_ProjectionMatrix");
- glslesinfo->texturecoordloc = gpu_glGetUniformLocation(program, "b_TextureMatrix");
+ glslesinfo->texturematloc = gpu_glGetUniformLocation(program, "b_TextureMatrix");
glslesinfo->texidloc = gpu_glGetUniformLocation(program, "v_texid");
glslesinfo->vertexloc = gpu_glGetAttribLocation(program, "b_Vertex");
glslesinfo->normalloc = gpu_glGetAttribLocation(program, "b_Normal");
glslesinfo->colorloc = gpu_glGetAttribLocation(program, "b_Color");
+ glslesinfo->texturecoordloc = gpu_glGetAttribLocation(program, "b_Coord");
}
@@ -227,7 +231,7 @@
"varying vec4 v_Color; \n"
"void main() \n"
"{ \n"
-" gl_FragColor = vec4(vec3(v_Color), v_Color.a * 1.0); \n"
+" gl_FragColor = v_Color; \n"
"} \n"
;
@@ -268,6 +272,7 @@
int shader_alphatexture;
+
void gpu_object_init_gles(void)
{
GLuint vo = compile_shader(GL_VERTEX_SHADER, &object_shader_vector_basic, 1);
Modified: 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 2012-08-20 15:29:02 UTC (rev 50050)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_object_gles.h 2012-08-20 16:09:53 UTC (rev 50051)
@@ -9,13 +9,14 @@
int viewmatloc;
int normalmatloc;
int projectionmatloc;
- int texturecoordloc;
+ int texturematloc;
int texidloc;
int vertexloc;
int normalloc;
int colorloc;
+ int texturecoordloc;
} GPUGLSL_ES_info;
Modified: branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_draw.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_draw.c 2012-08-20 15:29:02 UTC (rev 50050)
+++ branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_draw.c 2012-08-20 16:09:53 UTC (rev 50051)
@@ -774,6 +774,9 @@
drawmethod = wm_automatic_draw_method(win);
+#ifdef GLES
+ wm_method_draw_full(C, win);
+#else
if (win->drawfail)
wm_method_draw_overlap_all(C, win, 0);
else if (drawmethod == USER_DRAW_FULL)
@@ -784,6 +787,7 @@
wm_method_draw_overlap_all(C, win, 1);
else // if (drawmethod == USER_DRAW_TRIPLE)
wm_method_draw_triple(C, win);
+#endif
win->screen->do_draw_gesture = FALSE;
win->screen->do_draw_paintcursor = FALSE;
More information about the Bf-blender-cvs
mailing list