mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-24 19:23:00 +00:00
[qwaq] Implement blitting from draw buffer to text
Sending the data out to curses.
This commit is contained in:
parent
f91fb4f840
commit
b3850bbc69
4 changed files with 65 additions and 0 deletions
|
@ -13,6 +13,10 @@
|
|||
}
|
||||
+ (DrawBuffer *) buffer: (Extent) size;
|
||||
- initWithSize: (Extent) size;
|
||||
|
||||
- (Extent) size;
|
||||
- (int *) buffer;
|
||||
|
||||
- blitFromBuffer: (DrawBuffer *) srcBuffer to: (Point) pos from: (Rect) rect;
|
||||
|
||||
- (void) printf: (string) fmt, ...;
|
||||
|
|
|
@ -18,6 +18,16 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (Extent) size
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
- (int *) buffer
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
- blitFromBuffer: (DrawBuffer *) srcBuffer to: (Point) pos from: (Rect) rect
|
||||
{
|
||||
Extent srcSize = srcBuffer.size;
|
||||
|
|
|
@ -6,9 +6,24 @@
|
|||
#include "qwaq-curses.h"
|
||||
#include "qwaq-rect.h"
|
||||
|
||||
@class DrawBuffer;
|
||||
|
||||
@interface TextContext : Object
|
||||
{
|
||||
window_t window;
|
||||
union {
|
||||
Rect rect;
|
||||
struct {
|
||||
Point offset;
|
||||
Extent size;
|
||||
};
|
||||
struct {
|
||||
int xpos;
|
||||
int ypos;
|
||||
int xlen;
|
||||
int ylen;
|
||||
};
|
||||
};
|
||||
}
|
||||
+ (int) max_colors;
|
||||
+ (int) max_color_pairs;
|
||||
|
@ -25,6 +40,8 @@
|
|||
|
||||
-(window_t) window;
|
||||
|
||||
- blitFromBuffer: (DrawBuffer *) srcBuffer to: (Point) pos from: (Rect) rect;
|
||||
|
||||
- (void) printf: (string) fmt, ...;
|
||||
- (void) vprintf: (string) mft, @va_list args;
|
||||
- (void) addch: (int) ch;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "qwaq-draw.h"
|
||||
#include "qwaq-textcontext.h"
|
||||
|
||||
@implementation TextContext
|
||||
|
@ -59,6 +60,39 @@ static TextContext *screen;
|
|||
return window;
|
||||
}
|
||||
|
||||
- blitFromBuffer: (DrawBuffer *) srcBuffer to: (Point) pos from: (Rect) rect
|
||||
{
|
||||
Extent srcSize = [srcBuffer size];
|
||||
Rect r = { {}, srcSize };
|
||||
Rect t = { pos, rect.extent };
|
||||
|
||||
t = clipRect (r, t);
|
||||
if (t.extent.width < 0 || t.extent.height < 0) {
|
||||
return self;
|
||||
}
|
||||
|
||||
rect.offset.x += t.offset.x - pos.x;
|
||||
rect.offset.y += t.offset.y - pos.y;
|
||||
rect.extent = t.extent;
|
||||
pos = t.offset;
|
||||
|
||||
r.offset = nil;
|
||||
r.extent = size;
|
||||
|
||||
rect = clipRect (r, rect);
|
||||
if (rect.extent.width < 0 || rect.extent.height < 0) {
|
||||
return self;
|
||||
}
|
||||
|
||||
int *src = [srcBuffer buffer]
|
||||
+ rect.offset.y * srcSize.width + rect.offset.x;
|
||||
for (int y = 0; y < rect.extent.height; y++) {
|
||||
mvwblit_line (window, pos.x, y + pos.y, src, rect.extent.width);
|
||||
src += srcSize.width;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) mvprintf: (Point) pos, string fmt, ... = #0;
|
||||
- (void) printf: (string) fmt, ... = #0;
|
||||
- (void) vprintf: (string) mft, @va_list args = #0;
|
||||
|
|
Loading…
Reference in a new issue