diff options
author | Stephane Marchesin <stephane.marchesin@gmail.com> | 2010-04-24 20:07:28 -0700 |
---|---|---|
committer | Stephane Marchesin <stephane.marchesin@gmail.com> | 2010-04-24 20:07:28 -0700 |
commit | fb3187afdc1d54638791e2ead5c28cb8e949cf2e (patch) | |
tree | a82d0634c39314f31d5798f683e41c3633e47087 | |
parent | 661eb5a9126e608b8e5cea3e6105728da3edd015 (diff) |
Get some things kindof working.
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | damage.c | 16 | ||||
-rw-r--r-- | damage.h | 2 | ||||
-rw-r--r-- | draw.h | 10 | ||||
-rw-r--r-- | init.c | 2 | ||||
-rw-r--r-- | render.c | 8 | ||||
-rw-r--r-- | xenon.h | 2 | ||||
-rw-r--r-- | xlib_api.c | 8 |
8 files changed, 38 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ac0f5e9..7c704fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.4) link_libraries(dl) -set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wtype-limits -Wuninitialized -Wmissing-field-initializers -Wmissing-parameter-type -march=native -O2 --std=gnu99") +set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wtype-limits -Wuninitialized -Wmissing-field-initializers -Wmissing-parameter-type -march=native -O2 --std=gnu99") add_library (X11 SHARED damage.c display.c draw.c drawable.c init.c render.c screen.c window.c xlib_api.c) @@ -1,17 +1,29 @@ #include "draw.h" +#include "xenon.h" static xenon_rect current_rect; void damage_add(xenon_rect* region) { - xenon_rect new = current_rect; + int xmin = min(current_rect.x, region->x); + int xmax = max(current_rect.x + current_rect.w, region->x + region->w); + int ymin = min(current_rect.y, region->y); + int ymax = max(current_rect.y + current_rect.h, region->y + region->h); + current_rect.x = xmin; + current_rect.w = xmax - xmin; + current_rect.y = ymin; + current_rect.h = ymax - ymin; } void damage_clear() { + current_rect.x = 0; + current_rect.y = 0; + current_rect.w = 0; + current_rect.h = 0; } -xenon_rect current_damage() +xenon_rect damage_current() { return current_rect; } @@ -2,4 +2,4 @@ void damage_add(xenon_rect* region); void damage_clear(); -xenon_rect current_damage(); +xenon_rect damage_current(); @@ -1,12 +1,12 @@ #ifndef _draw_h_ #define _draw_h_ -#define pixelr(x,y) pixels[(screen_rect.w * y + x)*4 + 0] -#define pixelg(x,y) pixels[(screen_rect.w * y + x)*4 + 1] -#define pixelb(x,y) pixels[(screen_rect.w * y + x)*4 + 2] -#define pixela(x,y) pixels[(screen_rect.w * y + x)*4 + 3] +#define pixelr(x,y) pixels[(screen_rect.w * (y) + (x))*4 + 0] +#define pixelg(x,y) pixels[(screen_rect.w * (y) + (x))*4 + 1] +#define pixelb(x,y) pixels[(screen_rect.w * (y) + (x))*4 + 2] +#define pixela(x,y) pixels[(screen_rect.w * (y) + (x))*4 + 3] -#define pixelrgba(x,y) ((unsigned*)pixels)[(screen_rect.w * y + x)] +#define pixelrgba(x,y) ((unsigned*)pixels)[(screen_rect.w * (y) + (x))] typedef struct xenon_rect { @@ -2,6 +2,7 @@ #include "xenon.h" #include "screen.h" #include "render.h" +#include "damage.h" int init_done = 0; @@ -11,5 +12,6 @@ void __attribute__ ((constructor)) init() screen.height = 480; render_init(screen.width, screen.height); init_done = 1; + damage_clear(); } @@ -105,7 +105,11 @@ void render_init(int w, int h) void render_update(xenon_rect r) { - libGL.glRasterPos2i(r.x, r.y); - libGL.glDrawPixels(r.w, r.h, GL_RGBA, GL_UNSIGNED_BYTE, pixels + (r.x + r.y * screen_rect.w) * 4 ); + for(int j = r.y ; j < r.y + r.h ; j++) + { + libGL.glRasterPos2i(r.x, r.h - j); + libGL.glDrawPixels(r.w, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels + (r.x + j * screen_rect.w) * 4 ); + } } + @@ -4,4 +4,6 @@ #include <stdlib.h> #include <stdio.h> +#define min(a,b) ((a)<(b)?(a):(b)) +#define max(a,b) ((a)>(b)?(a):(b)) @@ -2,6 +2,7 @@ #include "xenon.h" #include "window.h" #include "display.h" +#include "damage.h" #include "draw.h" Status XAllocColor( @@ -10,6 +11,7 @@ Status XAllocColor( XColor* screen_in_out ) { + printf("alloc color ok\n"); } int XCloseDisplay( @@ -120,8 +122,9 @@ int XFlush( Display* display ) { + render_update(damage_current()); + damage_clear(); printf("flush ok\n"); - // XXX here call render_update } void XFlushGC( @@ -164,6 +167,7 @@ Status XParseColor( XColor* exact_def_return ) { + printf("parse color ok\n"); } int XSelectInput( @@ -172,6 +176,7 @@ int XSelectInput( long event_mask ) { + printf("select input ok\n"); } int XSetForeground( @@ -180,6 +185,7 @@ int XSetForeground( unsigned long foreground ) { + printf("set foreground ok\n"); } |