be paranoid about gl context - reset it to "0" every frame.
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 20 May 2010 15:24:28 +0000 (15:24 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 20 May 2010 15:24:28 +0000 (15:24 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@49065 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/modules/engines/gl_common/evas_gl_common.h
src/modules/engines/gl_common/evas_gl_context.c
src/modules/engines/gl_x11/evas_engine.c

index fb4348c..e9dfbeb 100644 (file)
@@ -139,7 +139,7 @@ struct _Evas_GL_Context
       Eina_Bool       clip : 1;
       struct {
          GLuint          cur_prog;
-         GLuint          cur_tex, cur_texum, cur_texv;
+         GLuint          cur_tex, cur_texu, cur_texv;
          int             render_op;
          int             cx, cy, cw, ch;
          Eina_Bool       smooth : 1;
@@ -286,6 +286,7 @@ void glerr(int err, const char *file, const char *func, int line, const char *op
 Evas_GL_Context  *evas_gl_common_context_new(void);
 void              evas_gl_common_context_free(Evas_GL_Context *gc);
 void              evas_gl_common_context_use(Evas_GL_Context *gc);
+void              evas_gl_common_context_newframe(Evas_GL_Context *gc);
 void              evas_gl_common_context_resize(Evas_GL_Context *gc, int w, int h, int rot);
 void              evas_gl_common_context_target_surface_set(Evas_GL_Context *gc, Evas_GL_Image *surface);
 
index e5a0d1b..098c8b3 100644 (file)
@@ -369,6 +369,8 @@ evas_gl_common_context_new(void)
    
    _evas_gl_common_context = gc;
 
+   gc->shader.render_op = EVAS_RENDER_BLEND;
+   
    if (!shared)
      {
         GLint linked;
@@ -597,12 +599,97 @@ evas_gl_common_context_free(Evas_GL_Context *gc)
 void
 evas_gl_common_context_use(Evas_GL_Context *gc)
 {
-//   if (_evas_gl_common_context == gc) return;
+   if (_evas_gl_common_context == gc) return;
    _evas_gl_common_context = gc;
    _evas_gl_common_viewport_set(gc);
 }
 
 void
+evas_gl_common_context_newframe(Evas_GL_Context *gc)
+{
+   gc->clip.x = 0;
+   gc->clip.y = 0;
+   gc->clip.w = 0;
+   gc->clip.h = 0;
+   gc->clip.active = 0;
+   gc->shader.surface = NULL;
+   gc->shader.cur_prog = 0;
+   gc->shader.cur_tex = 0;
+   gc->shader.cur_texu = 0;
+   gc->shader.cur_texv = 0;
+   gc->shader.render_op = EVAS_RENDER_BLEND;
+   gc->shader.cx = 0;
+   gc->shader.cy = 0;
+   gc->shader.cw = 0;
+   gc->shader.ch = 0;
+   gc->shader.smooth = 0;
+   gc->shader.blend = 0;
+   gc->shader.clip = 0;
+   gc->shader.current.cur_prog = 0;
+   gc->shader.current.cur_tex = 0;
+   gc->shader.current.cur_texu = 0;
+   gc->shader.current.cur_texv = 0;
+   gc->shader.current.render_op = 0;
+   gc->shader.current.cx = 0;
+   gc->shader.current.cy = 0;
+   gc->shader.current.cw = 0;
+   gc->shader.current.ch = 0;
+   gc->shader.current.smooth = 0;
+   gc->shader.current.blend = 0;
+   gc->shader.current.clip = 0;
+   gc->change.size = 1;
+   
+   glDisable(GL_SCISSOR_TEST);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   glScissor(0, 0, 0, 0);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   
+   glDisable(GL_DEPTH_TEST);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   glEnable(GL_DITHER);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   glDisable(GL_BLEND);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   // no dest alpha
+//   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // dest alpha
+//   glBlendFunc(GL_SRC_ALPHA, GL_ONE); // ???
+   glDepthMask(GL_FALSE);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+        
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+#ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
+   if (shared->info.anisotropic > 0.0)
+     {
+        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0);
+        GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+     }
+#endif
+   
+   glEnableVertexAttribArray(SHAD_VERTEX);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   glEnableVertexAttribArray(SHAD_COLOR);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   glUseProgram(gc->shader.cur_prog);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   
+   glActiveTexture(GL_TEXTURE0);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+   glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex);
+   GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+
+   _evas_gl_common_viewport_set(gc);
+}
+
+void
 evas_gl_common_context_resize(Evas_GL_Context *gc, int w, int h, int rot)
 {
    if ((gc->w == w) && (gc->h == h) && (gc->rot == rot)) return;
index 30d74ea..243f40d 100644 (file)
@@ -492,9 +492,11 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
    Render_Engine *re;
 
    re = (Render_Engine *)data;
-   evas_gl_common_context_flush(re->win->gl_context);
    /* get the upate rect surface - return engine data as dummy */
    if (!re->win->draw.redraw) return NULL;
+   evas_gl_common_context_flush(re->win->gl_context);
+   eng_window_use(re->win);
+   evas_gl_common_context_newframe(re->win->gl_context);
    if (x) *x = re->win->draw.x1;
    if (y) *y = re->win->draw.y1;
    if (w) *w = re->win->draw.x2 - re->win->draw.x1 + 1;