mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
[qwaq] Get DrawBuffer and TextContext working
Especially blitting whole regions. Partial regions not tested yet.
This commit is contained in:
parent
9c06b22719
commit
7f9a415cbc
7 changed files with 61 additions and 6 deletions
|
@ -291,12 +291,18 @@ get_panel (qwaq_resources_t *res, const char *name, int handle)
|
|||
return panel;
|
||||
}
|
||||
|
||||
//XXX goes away with threads
|
||||
static void process_commands (qwaq_resources_t *);
|
||||
static void process_input (qwaq_resources_t *);
|
||||
static int
|
||||
acquire_string (qwaq_resources_t *res)
|
||||
{
|
||||
int string_id = -1;
|
||||
|
||||
// XXX add locking and loop for available
|
||||
if (!RB_DATA_AVAILABLE (res->string_ids)) {
|
||||
process_commands(res);
|
||||
}
|
||||
if (RB_DATA_AVAILABLE (res->string_ids)) {
|
||||
RB_READ_DATA (res->string_ids, &string_id, 1);
|
||||
}
|
||||
|
@ -338,9 +344,6 @@ qwaq_submit_result (qwaq_resources_t *res, const int *result, unsigned len)
|
|||
}
|
||||
}
|
||||
|
||||
//XXX goes away with threads
|
||||
static void process_commands (qwaq_resources_t *);
|
||||
static void process_input (qwaq_resources_t *);
|
||||
static void
|
||||
qwaq_wait_result (qwaq_resources_t *res, int *result, int cmd, unsigned len)
|
||||
{
|
||||
|
@ -628,11 +631,18 @@ cmd_mvwblit_line (qwaq_resources_t *res)
|
|||
int chs_id = RB_PEEK_DATA (res->command_queue, 5);
|
||||
int len = RB_PEEK_DATA (res->command_queue, 6);
|
||||
int *chs = (int *) res->strings[chs_id].str;
|
||||
int save_x;
|
||||
int save_y;
|
||||
|
||||
window_t *window = get_window (res, __FUNCTION__, window_id);
|
||||
getyx (window->win, save_y, save_x);
|
||||
for (int i = 0; i < len; i++) {
|
||||
mvwaddch (window->win, y, x, chs[i]);
|
||||
Sys_Printf(" %d", chs[i]);
|
||||
mvwaddch (window->win, y, x + i, chs[i]);
|
||||
}
|
||||
Sys_Printf("\n");
|
||||
wmove (window->win, save_y, save_x);
|
||||
release_string (res, chs_id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
- blitFromBuffer: (DrawBuffer *) srcBuffer to: (Point) pos from: (Rect) rect
|
||||
{
|
||||
Extent srcSize = srcBuffer.size;
|
||||
Rect r = { {}, srcBuffer.size };
|
||||
Rect r = { {}, size };
|
||||
Rect t = { pos, rect.extent };
|
||||
|
||||
t = clipRect (r, t);
|
||||
|
|
|
@ -18,6 +18,8 @@ typedef struct Rect_s {
|
|||
|
||||
#ifdef __QFCC__
|
||||
@extern Rect makeRect (int xpos, int ypos, int xlen, int ylen);
|
||||
@extern Point makePoint (int x, int y);
|
||||
@extern Extent makeExtent (int width, int height);
|
||||
//XXX will not work if point or rect point to a local variabl
|
||||
@extern int rectContainsPoint (Rect *rect, Point *point);
|
||||
@extern Rect getwrect (struct window_s *window);
|
||||
|
|
|
@ -29,6 +29,18 @@ makeRect (int xpos, int ypos, int xlen, int ylen)
|
|||
return rect;
|
||||
}
|
||||
|
||||
Point makePoint (int x, int y)
|
||||
{
|
||||
Point p = {x, y};
|
||||
return p;
|
||||
}
|
||||
|
||||
Extent makeExtent (int width, int height)
|
||||
{
|
||||
Extent e = {width, height};
|
||||
return e;
|
||||
}
|
||||
|
||||
int
|
||||
rectContainsPoint (Rect *rect, Point *point)
|
||||
{
|
||||
|
|
|
@ -43,6 +43,8 @@ static TextContext *screen;
|
|||
}
|
||||
window = create_window (rect.offset.x, rect.offset.y,
|
||||
rect.extent.width, rect.extent.height);
|
||||
offset = {};
|
||||
size = rect.extent;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -60,13 +62,30 @@ static TextContext *screen;
|
|||
return window;
|
||||
}
|
||||
|
||||
-(Extent) size
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
- blitFromBuffer: (DrawBuffer *) srcBuffer to: (Point) pos from: (Rect) rect
|
||||
{
|
||||
Extent srcSize = [srcBuffer size];
|
||||
Rect r = { {}, srcSize };
|
||||
Rect r = { {}, size };
|
||||
Rect t = { pos, rect.extent };
|
||||
|
||||
wprintf (stdscr, "src: %p\n", srcBuffer);
|
||||
wprintf (stdscr, "srcSize: %d %d\n", srcSize.width, srcSize.height);
|
||||
wprintf (stdscr, "pos: %d %d\n", pos.x, pos.x);
|
||||
wprintf (stdscr, "rect: %d %d %d %d\n",
|
||||
rect.offset.x, rect.offset.y,
|
||||
rect.extent.width, rect.extent.height);
|
||||
wprintf (stdscr, "r: %d %d %d %d\n",
|
||||
r.offset.x, r.offset.y, r.extent.width, r.extent.height);
|
||||
wprintf (stdscr, "t: %d %d %d %d\n",
|
||||
t.offset.x, t.offset.y, t.extent.width, t.extent.height);
|
||||
t = clipRect (r, t);
|
||||
wprintf (stdscr, "t: %d %d %d %d\n",
|
||||
t.offset.x, t.offset.y, t.extent.width, t.extent.height);
|
||||
if (t.extent.width < 0 || t.extent.height < 0) {
|
||||
return self;
|
||||
}
|
||||
|
@ -80,6 +99,12 @@ static TextContext *screen;
|
|||
r.extent = size;
|
||||
|
||||
rect = clipRect (r, rect);
|
||||
wprintf (stdscr, "pos: %d %d\n", pos.x, pos.x);
|
||||
wprintf (stdscr, "rect: %d %d %d %d\n",
|
||||
rect.offset.x, rect.offset.y,
|
||||
rect.extent.width, rect.extent.height);
|
||||
wprintf (stdscr, "r: %d %d %d %d\n",
|
||||
r.offset.x, r.offset.y, r.extent.width, r.extent.height);
|
||||
if (rect.extent.width < 0 || rect.extent.height < 0) {
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
{
|
||||
Point point; // FIXME can't be local :(
|
||||
struct panel_s *panel;
|
||||
DrawBuffer *buf;
|
||||
}
|
||||
+windowWithRect: (Rect) rect;
|
||||
-setBackground: (int) ch;
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
buffer = [[TextContext alloc] initWithRect: rect];
|
||||
textContext = buffer;
|
||||
panel = create_panel ([buffer window]);
|
||||
buf = [DrawBuffer buffer: makeExtent (3, 3)];
|
||||
[buf mvaddstr: makePoint (0, 0), "XOX"];
|
||||
[buf mvaddstr: makePoint (0, 1), "OXO"];
|
||||
[buf mvaddstr: makePoint (0, 2), "XOX"];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -108,6 +112,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
[textContext blitFromBuffer: buf to: makePoint (6, 3) from: [buf rect]];
|
||||
[self refresh];
|
||||
return self;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue