summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Marchesin <stephane.marchesin@gmail.com>2010-04-24 20:07:28 -0700
committerStephane Marchesin <stephane.marchesin@gmail.com>2010-04-24 20:07:28 -0700
commitfb3187afdc1d54638791e2ead5c28cb8e949cf2e (patch)
treea82d0634c39314f31d5798f683e41c3633e47087
parent661eb5a9126e608b8e5cea3e6105728da3edd015 (diff)
Get some things kindof working.
-rw-r--r--CMakeLists.txt2
-rw-r--r--damage.c16
-rw-r--r--damage.h2
-rw-r--r--draw.h10
-rw-r--r--init.c2
-rw-r--r--render.c8
-rw-r--r--xenon.h2
-rw-r--r--xlib_api.c8
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)
diff --git a/damage.c b/damage.c
index 8d27c06..6702c33 100644
--- a/damage.c
+++ b/damage.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;
}
diff --git a/damage.h b/damage.h
index 8d6f66a..0bd6d38 100644
--- a/damage.h
+++ b/damage.h
@@ -2,4 +2,4 @@
void damage_add(xenon_rect* region);
void damage_clear();
-xenon_rect current_damage();
+xenon_rect damage_current();
diff --git a/draw.h b/draw.h
index 5122f0c..8a5bf32 100644
--- a/draw.h
+++ b/draw.h
@@ -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
{
diff --git a/init.c b/init.c
index ad86034..8d03576 100644
--- a/init.c
+++ b/init.c
@@ -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();
}
diff --git a/render.c b/render.c
index b977eee..4bcd2e1 100644
--- a/render.c
+++ b/render.c
@@ -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 );
+ }
}
+
diff --git a/xenon.h b/xenon.h
index c7d1b11..5d6cc7d 100644
--- a/xenon.h
+++ b/xenon.h
@@ -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))
diff --git a/xlib_api.c b/xlib_api.c
index 5d1f66b..40a8887 100644
--- a/xlib_api.c
+++ b/xlib_api.c
@@ -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");
}