Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: ecompmgr.c eglx.c eglx.h glwin.c Log Message: glx bits. =================================================================== RCS file: /cvs/e/e16/e/src/ecompmgr.c,v retrieving revision 1.163 retrieving revision 1.164 diff -u -3 -r1.163 -r1.164 --- ecompmgr.c 18 Jul 2007 11:10:54 -0000 1.163 +++ ecompmgr.c 21 Jul 2007 20:28:40 -0000 1.164 @@ -1228,6 +1228,9 @@ cw->pixmap = None; if (Mode_compmgr.use_pixmap) what |= INV_PICTURE; +#if USE_GLX + EobjTextureInvalidate(eo); +#endif } if (what & (INV_SIZE | INV_SHAPE)) =================================================================== RCS file: /cvs/e/e16/e/src/eglx.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- eglx.c 24 Jun 2007 16:48:16 -0000 1.4 +++ eglx.c 21 Jul 2007 20:28:40 -0000 1.5 @@ -318,7 +318,8 @@ return; /* First time */ - glEnable(GL_TEXTURE_2D); /* ??? */ + glEnable(TEXTURE_TARGET); + glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); @@ -352,10 +353,10 @@ if (!et) return NULL; + et->type = ETEX_TYPE_IMAGE; et->target = TEXTURE_TARGET; glGenTextures(1, &et->texture); glBindTexture(et->target, et->texture); - et->type = ETEX_TYPE_IMAGE; EImageGetSize(im, &w, &h); data = EImageGetData(im); @@ -407,11 +408,27 @@ return glxpixmap; } +static void +_EGlTextureFromDrawable(ETexture * et, Drawable draw, int mode) +{ + if (!et || draw == None) + return; + + glBindTexture(et->target, et->texture); + et->glxpmap = GetGlPixmap(draw, (mode & 0x100) ? None : draw); + if (et->glxpmap == None) + return; + + _glXBindTexImageEXT(disp, et->glxpmap, GLX_FRONT_LEFT_EXT, NULL); +#if 0 /* No! */ + glXDestroyPixmap(disp, et->glxpmap); +#endif +} + ETexture * EGlTextureFromDrawable(Drawable draw, int mode) { ETexture *et; - GLXPixmap glxpixmap; if (draw == None) return NULL; @@ -420,41 +437,12 @@ if (!et) return NULL; + et->type = ETEX_TYPE_PIXMAP; et->target = TEXTURE_TARGET; glGenTextures(1, &et->texture); - glEnable(et->target); /* Why ??? */ glBindTexture(et->target, et->texture); - et->type = ETEX_TYPE_PIXMAP; - - glxpixmap = GetGlPixmap(draw, (mode & 0x100) ? None : draw); - if (glxpixmap == None) - return NULL; - et->glxpmap = glxpixmap; - -#if 0 - unsigned int trg; - glXQueryDrawable(disp, et->glxpmap, GLX_TEXTURE_TARGET_EXT, &trg); - Dprintf("TARGET: %#x\n", trg); -#endif - - switch (mode & 0xff) - { - case 0: - _glXBindTexImageEXT(disp, glxpixmap, GLX_FRONT_LEFT_EXT, NULL); - glTexParameteri(et->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(et->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - break; - case 1: - _glXBindTexImageEXT(disp, glxpixmap, GLX_FRONT_LEFT_EXT, NULL); - glTexParameteri(et->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(et->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - break; - } -#if 0 /* No! */ - glXDestroyPixmap(disp, glxpixmap); -#endif - glBindTexture(et->target, 0); + _EGlTextureFromDrawable(et, draw, mode); return et; } @@ -468,8 +456,19 @@ Dprintf("EGlTextureDestroy %d type=%u pmap=%#x\n", et->texture, et->type, et->glxpmap); - glEnable(et->target); /* Why ??? */ - glBindTexture(et->target, et->texture); + EGlTextureInvalidate(et); + glDeleteTextures(1, &et->texture); + Efree(et); +} + +void +EGlTextureInvalidate(ETexture * et) +{ + if (!et) + return; + + Dprintf("EGlTextureInvalidate %d type=%u pmap=%#x\n", et->texture, et->type, + et->glxpmap); switch (et->type) { @@ -479,16 +478,10 @@ if (!et->glxpmap) break; _glXReleaseTexImageEXT(disp, et->glxpmap, GLX_FRONT_LEFT_EXT); - glBindTexture(et->target, 0); - glDisable(et->target); glXDestroyPixmap(disp, et->glxpmap); + et->glxpmap = None; break; } - - glBindTexture(et->target, 0); - glDeleteTextures(1, &et->texture); - - Efree(et); } #include "eobj.h" @@ -507,10 +500,22 @@ ETexture * EobjGetTexture(EObj * eo) { - Pixmap pmap; - if (eo->glhook) - return eo->glhook; + { + if (eo->glhook->glxpmap) + return eo->glhook; + + _EGlTextureFromDrawable(eo->glhook, EobjGetPixmap(eo), 0); + return eo->glhook; + } + + return EobjTextureCreate(eo); +} + +ETexture * +EobjTextureCreate(EObj * eo) +{ + Pixmap pmap; pmap = EobjGetPixmap(eo); if (pmap == None) @@ -526,4 +531,10 @@ { EGlTextureDestroy(eo->glhook); eo->glhook = NULL; +} + +void +EobjTextureInvalidate(EObj * eo) +{ + EGlTextureInvalidate(eo->glhook); } =================================================================== RCS file: /cvs/e/e16/e/src/eglx.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- eglx.h 8 Apr 2007 20:24:06 -0000 1.2 +++ eglx.h 21 Jul 2007 20:28:40 -0000 1.3 @@ -53,5 +53,6 @@ ETexture *EGlTextureFromImage(EImage * im, int mode); ETexture *EGlTextureFromDrawable(Drawable draw, int mode); void EGlTextureDestroy(ETexture * et); +void EGlTextureInvalidate(ETexture * et); #endif /* _EGLX_H_ */ =================================================================== RCS file: /cvs/e/e16/e/src/glwin.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- glwin.c 24 Jun 2007 16:48:16 -0000 1.2 +++ glwin.c 21 Jul 2007 20:28:40 -0000 1.3 @@ -170,7 +170,7 @@ if (!et) return; - glBindTexture(GL_TEXTURE_2D, et->texture); + glBindTexture(et->target, et->texture); glBegin(GL_QUADS); glNormal3f(0.0f, 0.0f, 1.0f); @@ -194,7 +194,7 @@ if (!et) return; - glBindTexture(GL_TEXTURE_2D, et->texture); + glBindTexture(et->target, et->texture); switch (filter) { @@ -310,21 +310,17 @@ } static void -SceneDraw1(double t) +SceneDraw1(double t, EWin ** ewins, int num) { - unsigned int i, j, nx, ny; + int i, j, k, nx, ny; GLfloat x, y, w, h, dx, dy, sz; - EWin *const *ewins; EObj *eo; - int k, num; w = EobjGetW(GLWin.eo); h = EobjGetH(GLWin.eo); DrawBackground(texture[sel_bg], w, h); - ewins = EwinListGetAll(&num); - i = sqrt(w * h / (1.5 * num)); ny = h / i; nx = num / ny; @@ -377,22 +373,18 @@ } static void -SceneDraw2(double t) +SceneDraw2(double t, EWin ** ewins, int num) { static double t1; int i; GLfloat w, h, dx, dy, sz, dx1, dy1; - EWin *const *ewins; EObj *eo; - int num; w = EobjGetW(GLWin.eo); h = EobjGetH(GLWin.eo); DrawBackground(texture[sel_bg], w, h); - ewins = EwinListGetAll(&num); - for (i = 0; i < num; i++) { dx1 = (.5 + .3 * cos(t1 + t + (i + .5) * 2. * M_PI / num)) * w; @@ -413,30 +405,57 @@ } } +static EWin ** +GlwinEwins(int *pnum) +{ + int i, j, num; + EWin *const *ewins; + EWin **lst; + + ewins = EwinListGetAll(&num); + lst = EMALLOC(EWin *, num); + + for (i = j = 0; i < num; i++) + { + if (!EoIsShown(ewins[i])) + continue; + lst[j++] = ewins[i]; + } + *pnum = j; + + return lst; +} + static void SceneDraw(void) { double t; + EWin **ewins; + int num; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); t = GetDTime(); + ewins = GlwinEwins(&num); + switch (Conf_glwin.mode) { default: - SceneDraw1(t); + SceneDraw1(t, ewins, num); break; case 1: - SceneDraw2(t); + SceneDraw2(t, ewins, num); break; } + glXSwapBuffers(disp, EobjGetXwin(GLWin.eo)); + + Efree(ewins); + rot_x += speed_x; rot_y += speed_y; - - glXSwapBuffers(disp, EobjGetXwin(GLWin.eo)); } static int ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs