diff options
author | Stephane Marchesin <stephane.marchesin@gmail.com> | 2010-05-03 00:46:31 -0700 |
---|---|---|
committer | Stephane Marchesin <stephane.marchesin@gmail.com> | 2010-05-03 00:46:31 -0700 |
commit | ffea40ecbbe86ead2699239d504c4d6ecdca4732 (patch) | |
tree | acdebe030d0310857c070c09a973c7e275898f99 | |
parent | a3147fea5e0b2da35e0ededd4f28b2253aa5d607 (diff) |
First skeleton for a PutImage implementation.
-rw-r--r-- | draw.c | 4 | ||||
-rw-r--r-- | init.c | 4 | ||||
-rw-r--r-- | render.c | 3 | ||||
-rw-r--r-- | tests/.rect.c.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | tests/rect.c | 6 | ||||
-rw-r--r-- | xlib_api.c | 37 |
6 files changed, 48 insertions, 6 deletions
@@ -27,4 +27,8 @@ void draw_rectangle(GC gc, xenon_rect* r) damage_add(r); } +void draw_image(GC gc, XImage* image, xenon_rect area, int x, int y) +{ + +} @@ -4,14 +4,14 @@ #include "render.h" #include "damage.h" -int init_done = 0; +extern int inhibit_rendering; void __attribute__ ((constructor)) init() { screen.width = 640; screen.height = 480; render_init(screen.width, screen.height); - init_done = 1; + inhibit_rendering = 0; damage_clear(); } @@ -35,6 +35,7 @@ typedef struct xenon_libGL xenon_libGL; static xenon_libGL libGL; +int inhibit_rendering = 1; static void render_init_libs() { @@ -105,11 +106,13 @@ void render_init(int w, int h) void render_update(xenon_rect r) { + inhibit_rendering = 1; for(int j = r.y ; j < r.y + r.h ; j++) { libGL.glRasterPos2i(r.x, r.h - j - 1); libGL.glDrawPixels(r.w, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels + (r.x + j * screen_rect.w) * 4 ); } + inhibit_rendering = 0; } diff --git a/tests/.rect.c.swp b/tests/.rect.c.swp Binary files differdeleted file mode 100644 index 141eb94..0000000 --- a/tests/.rect.c.swp +++ /dev/null diff --git a/tests/rect.c b/tests/rect.c index db66834..4fb4f0b 100644 --- a/tests/rect.c +++ b/tests/rect.c @@ -31,12 +31,14 @@ int main() { XAllocColor(dis, colormap, &green_col); XSetForeground(dis, green_gc, green_col.pixel); - XSelectInput(dis, win, ExposureMask | KeyPressMask | ButtonPressMask); + printf("select input\n"); +/* XSelectInput(dis, win, ExposureMask | KeyPressMask | ButtonPressMask); XDrawRectangle(dis, win, green_gc, 1, 1, 247, 247); XDrawRectangle(dis, win, green_gc, 50, 50, 148, 148); + printf("flush\n"); XFlush(dis); sleep(5); - return 0; +*/ return 0; } @@ -30,8 +30,8 @@ GC XCreateGC( ) { // XXX init hack, remove when the renderer is changed to gallium - extern int init_done; - if (!init_done) + extern int inhibit_rendering; + if (inhibit_rendering) { void* handle; handle = dlopen("/usr/lib64/libX11.so.6", RTLD_LAZY); @@ -193,6 +193,39 @@ Status XParseColor( printf("parse color ok\n"); } +int XPutImage( + Display* display, + Drawable d, + GC gc, + XImage* image, + int src_x, + int src_y, + int dest_x, + int dest_y, + unsigned int width, + unsigned int height +) +{ + // XXX init hack, remove when the renderer is changed to gallium + extern int inhibit_rendering; + if (inhibit_rendering) + { + void* handle; + handle = dlopen("/usr/lib64/libX11.so.6", RTLD_LAZY); + if (!handle) + handle = dlopen("/usr/lib/libX11.so.6", RTLD_LAZY); + if (!handle) + printf("can't open libX11\n"); + typedef GC (* XPutImagefunc) (Display*, Drawable, GC, XImage*, int, int, int, int, unsigned, unsigned); + XPutImagefunc XPutImagereal = dlsym(handle, "XPutImage"); + return XPutImagereal(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height); + } + + xenon_rect r = {src_x,src_y,width,height}; + draw_image(gc, image, r, dest_x, dest_y); + printf("put image ok\n"); +} + int XSelectInput( Display* display, Window w, |