From 29d8242835b45806faec5a9bfa139e412d692f1a Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Wed, 2 Aug 2000 05:28:28 +0000 Subject: [PATCH] demo works MUCH better now! SVN revision: 2972 --- legacy/evas/src/evas_gl_routines.c | 56 +++++++++++++++++------------- legacy/evas/src/evas_gl_routines.h | 4 ++- legacy/evas/test/evas_test.c | 37 ++++++++++++++------ 3 files changed, 61 insertions(+), 36 deletions(-) diff --git a/legacy/evas/src/evas_gl_routines.c b/legacy/evas/src/evas_gl_routines.c index 20cc4e6323..41612fd7db 100644 --- a/legacy/evas/src/evas_gl_routines.c +++ b/legacy/evas/src/evas_gl_routines.c @@ -173,6 +173,35 @@ void __evas_calc_tex_and_poly(Evas_GL_Image *im, int x, double *x1, double *x2, *x2 = (double)w; } +void __evas_gl_set_conect_for_dest(Evas_GL_Image *im, Display *disp, Window w, + int win_w, int win_h) +{ + if (im->buffer.dest != w) + { + im->buffer.dest = w; + glXMakeCurrent(disp, w, im->context); + glEnable(GL_BLEND); + glShadeModel(GL_FLAT); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); + /* why doesnt scissor work ? */ + /* + glEnable(GL_SCISSOR_TEST); + glScissor(dst_x, win_h - dst_y - 1, dst_w, dst_h); + */ + glViewport(0, 0, win_w, win_h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, win_w, 0, win_h, -1, 1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glScalef(1, -1, 1); + glTranslatef(0, -win_h, 0); + } +} + void __evas_gl_render_to_window(Evas_GL_Image *im, Display *disp, Window w, int win_w, int win_h, int src_x, int src_y, int src_w, int src_h, @@ -180,34 +209,11 @@ void __evas_gl_render_to_window(Evas_GL_Image *im, { int x, y, i; double dx, dy, dw, dh; + int done = 1; if (im->state != EVAS_STATE_TEXTURE) __evas_gl_move_state_data_to_texture(im); - glXMakeCurrent(disp, w, im->context); -/* - glClearColor(0.7, 0.7, 0.7, 1.0); - glClear(GL_COLOR_BUFFER_BIT); -*/ - glEnable(GL_BLEND); - glShadeModel(GL_FLAT); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); - glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); -/* why doesnt scissor work ? */ -/* - glEnable(GL_SCISSOR_TEST); - glScissor(dst_x, win_h - dst_y - 1, dst_w, dst_h); -*/ -/* translate all poly coords in ints to normal X coord space */ - glViewport(0, 0, win_w, win_h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, win_w, 0, win_h, -1, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glScalef(1, -1, 1); - glTranslatef(0, -win_h, 0); + __evas_gl_set_conect_for_dest(im, disp, w, win_w, win_h); /* project src and dst rects to overall dest rect */ dw = (((double)dst_w * (double)im->w)/ (double)src_w); dx = (double)dst_x - (((double)dst_w * (double)src_x)/ (double)src_w); diff --git a/legacy/evas/src/evas_gl_routines.h b/legacy/evas/src/evas_gl_routines.h index a34cdfad69..1257986855 100644 --- a/legacy/evas/src/evas_gl_routines.h +++ b/legacy/evas/src/evas_gl_routines.h @@ -47,7 +47,7 @@ struct _evas_gl_image Display *display; XVisualInfo *visual_info; Colormap colormap; - Window window; + Window window, dest; } buffer; }; @@ -57,6 +57,8 @@ void __evas_gl_copy_image_rect_to_texture(Evas_GL_Image *im, int x, int y, void __evas_gl_move_state_data_to_texture(Evas_GL_Image *im); void __evas_calc_tex_and_poly(Evas_GL_Image *im, int x, double *x1, double *x2, int *tx, int *txx, double *dtx, double *dtxx, int tw, int w, int edge); +void __evas_gl_set_conect_for_dest(Evas_GL_Image *im, Display *disp, Window w, + int win_w, int win_h); void __evas_gl_render_to_window(Evas_GL_Image *im, Display *disp, Window w, int win_w, int win_h, int src_x, int src_y, int src_w, int src_h, diff --git a/legacy/evas/test/evas_test.c b/legacy/evas/test/evas_test.c index 7f8a86a3d3..5637c866a6 100644 --- a/legacy/evas/test/evas_test.c +++ b/legacy/evas/test/evas_test.c @@ -33,11 +33,20 @@ main(int argc, char **argv) XMapWindow(d, win); } { - double a = 0.0; - Evas_GL_Image *i, *bg; + int a = -4096; + Evas_GL_Image *i[10], *bg; bg = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/backgrounds/Propaganda/Vol6/8a.jpg"); - i = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-gmush.png"); + i[0] = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-gmush.png"); + i[1] = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-term.png"); + i[2] = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-word.png"); + i[3] = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-help.png"); + i[4] = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-info.png"); + i[5] = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-modem.png"); + i[6] = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-money.png"); + i[7] = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-mouse.png"); + i[8] = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-stones.png"); + i[9] = __evas_gl_image_new_from_file(d, "/usr/share/pixmaps/gnome-balsa2.png"); for(;;) { int x, y, j; @@ -49,17 +58,25 @@ main(int argc, char **argv) 0, 0, bg->w, bg->h, x, y, bg->w, bg->h); } - for (j = 0; j < 32; j++) + for (j = 0, y = 0; y < 128; y++) { - x = 400 + (cos((a + ((double)j / 10))) * (1 * a)); - y = 300 + (sin((a + ((double)j / 10))) * (1 * a)); - __evas_gl_render_to_window(i, d, win, 800, 600, - 0, 0, i->w, i->h, - x, y, i->w, i->h); + for (x = 0; x < 128; x++, j++) + { + int xx, yy; + + xx = (x * 64) + a; + yy = (y * 64) + a; + if ((xx > -64) && (xx < 800) && (yy > -64) && (yy < 600)) + __evas_gl_render_to_window(i[j], d, win, 800, 600, + 0, 0, i[j]->w, i[j]->h, + xx, yy, i[j]->w, i[j]->h); + if (j == 9) j = -1; + } } /* __evas_sync(d);*/ __evas_flush_draw(d, win); - a += 0.1; + a++; + if (a == 0) a = -4096; } } }