diff options
author | Stephane Marchesin <stephane.marchesin@gmail.com> | 2010-04-24 18:09:17 -0700 |
---|---|---|
committer | Stephane Marchesin <stephane.marchesin@gmail.com> | 2010-04-24 18:09:17 -0700 |
commit | 661eb5a9126e608b8e5cea3e6105728da3edd015 (patch) | |
tree | e5e6814fb6986ec6ad9db27175ae5cb54e2cf238 | |
parent | 24f654343c555424cb4313a863d02fe6ce819499 (diff) |
More work on draw/damage.
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | damage.c | 18 | ||||
-rw-r--r-- | damage.h | 5 | ||||
-rw-r--r-- | draw.c | 23 | ||||
-rw-r--r-- | draw.h | 21 | ||||
-rw-r--r-- | render.c | 3 | ||||
-rw-r--r-- | render.h | 7 | ||||
-rw-r--r-- | xlib_api.c | 3 |
8 files changed, 74 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 530950f..ac0f5e9 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 -march=native -O2") -add_library (X11 SHARED display.c drawable.c init.c render.c screen.c window.c xlib_api.c) +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) diff --git a/damage.c b/damage.c new file mode 100644 index 0000000..8d27c06 --- /dev/null +++ b/damage.c @@ -0,0 +1,18 @@ +#include "draw.h" + +static xenon_rect current_rect; + +void damage_add(xenon_rect* region) +{ + xenon_rect new = current_rect; +} + +void damage_clear() +{ +} + +xenon_rect current_damage() +{ + return current_rect; +} + diff --git a/damage.h b/damage.h new file mode 100644 index 0000000..8d6f66a --- /dev/null +++ b/damage.h @@ -0,0 +1,5 @@ +#include "draw.h" + +void damage_add(xenon_rect* region); +void damage_clear(); +xenon_rect current_damage(); @@ -0,0 +1,23 @@ +#include "xenon.h" +#include "draw.h" +#include "damage.h" + +unsigned char* pixels; +xenon_rect screen_rect; + +void draw_rectangle(GC gc, xenon_rect* r) +{ + for(int i = r->x ; i < r->x + r->w ; i++) + { + pixelrgba(i, r->y) = 0xffffffff; + pixelrgba(i, r->y + r->h) = 0xffffffff; + } + for(int j = r->y ; j < r->y + r->h ; j++) + { + pixelrgba(r->x, j) = 0xffffffff; + pixelrgba(r->x + r->w, j) = 0xffffffff; + } + damage_add(r); +} + + @@ -0,0 +1,21 @@ +#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 pixelrgba(x,y) ((unsigned*)pixels)[(screen_rect.w * y + x)] + +typedef struct xenon_rect +{ + int x, y; + int w, h; +} +xenon_rect; +extern unsigned char* pixels; +extern xenon_rect screen_rect; + +#endif + @@ -2,10 +2,9 @@ #include <dlfcn.h> #include "xenon.h" #include "render.h" +#include "draw.h" #include <GL/glx.h> -unsigned char* pixels; -static xenon_rect screen_rect; typedef struct xenon_libX11 { @@ -1,10 +1,5 @@ -typedef struct xenon_rect -{ - int x, y; - int w, h; -} -xenon_rect; +#include "draw.h" extern void render_init(int w, int h); extern void render_update(xenon_rect r); @@ -2,6 +2,7 @@ #include "xenon.h" #include "window.h" #include "display.h" +#include "draw.h" Status XAllocColor( Display* display, @@ -84,6 +85,8 @@ int XDrawRectangle( unsigned int height ) { + xenon_rect r = {x,y,width,height}; + draw_rectangle(gc, &r); printf("draw rectangle ok\n"); } |