static int quit, disp_pending, dirty_valid;
static rtk_rect dirty;
static int mx, my;
-static rtk_rect rband;
+static rtk_rect rband, prev_rband;
int main(int argc, char **argv)
if(opt.vsync) {
vid_vsync();
}
- if(!dirty_valid) return;
- if(dirty.width < win_width || dirty.height < win_height) {
- uint32_t *src = framebuf + dirty.y * win_width + dirty.x;
- vid_blit32(dirty.x, dirty.y, dirty.width, dirty.height, src, 0);
+ if(dirty_valid) {
+ if(dirty.width < win_width || dirty.height < win_height) {
+ uint32_t *src = framebuf + dirty.y * win_width + dirty.x;
+ vid_blit32(dirty.x, dirty.y, dirty.width, dirty.height, src, 0);
- if(mx >= dirty.x && my >= dirty.y && mx < dirty.x + dirty.width && my < dirty.y + dirty.height) {
+ if(mx >= dirty.x && my >= dirty.y && mx < dirty.x + dirty.width && my < dirty.y + dirty.height) {
+ draw_cursor(mx, my);
+ }
+ } else {
+ vid_blitfb32(framebuf, 0);
draw_cursor(mx, my);
}
- } else {
- vid_blitfb32(framebuf, 0);
- draw_cursor(mx, my);
+ dirty_valid = 0;
}
- dirty_valid = 0;
+ if(rband.width) {
+ if(prev_rband.width) {
+ draw_rband(&prev_rband);
+ }
+ draw_rband(&rband);
+ prev_rband = rband;
+ }
}
void app_quit(void)
{
if(!(w | h)) {
w = h = 0;
+ prev_rband.width = 0;
}
rband.x = x;
}
}
-static void draw_rband(void)
+static void draw_rband(rtk_rect *r)
{
int i;
rtk_rect rect;
uint32_t *fbptr, *bptr;
- rect = rband;
- fix_rect(&rect);
+ rect = *r;
+ rtk_fix_rect(&rect);
- fbptr = framebuf + rect.y * win_width + rect.x;
+ fbptr = vmem + rect.y * win_width + rect.x;
bptr = fbptr + win_width * (rect.height - 1);
for(i=0; i<rect.width; i++) {
fbptr[rect.width - 1] ^= 0xffffff;
fbptr += win_width;
}
- app_redisplay(rect.x, rect.y, rect.width, rect.height);
}
#include <assert.h>
#include "miniglut.h"
#include "app.h"
+#include "rtk.h"
#include "logger.h"
static void display(void);
static PROC wgl_swap_interval_ext;
#endif
+static rtk_rect rband;
int main(int argc, char **argv)
void app_redisplay(int x, int y, int w, int h)
{
- dbgmsg("fakeupd: %d,%d (%dx%d)\n", x, y, w, h);
+ /*dbgmsg("fakeupd: %d,%d (%dx%d)\n", x, y, w, h);*/
glutPostRedisplay();
}
void app_swap_buffers(void)
{
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
glRasterPos2i(-1, 1);
glPixelZoom(1, -1);
glDrawPixels(win_width, win_height, GL_BGRA, GL_UNSIGNED_BYTE, framebuf);
glDisable(GL_ALPHA_TEST);
- glMatrixMode(GL_PROJECTION);
+ if(rband.width | rband.height) {
+ glOrtho(0, win_width, win_height, 0, -1, 1);
+
+ glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_LIGHTING);
+
+ glEnable(GL_COLOR_LOGIC_OP);
+ glLogicOp(GL_XOR);
+
+ glBegin(GL_LINE_LOOP);
+ glColor3f(1, 1, 1);
+ glVertex2f(rband.x, rband.y);
+ glVertex2f(rband.x + rband.width, rband.y);
+ glVertex2f(rband.x + rband.width, rband.y + rband.height);
+ glVertex2f(rband.x, rband.y + rband.height);
+ glEnd();
+
+ glPopAttrib();
+ }
+
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
#endif
+void app_rband(int x, int y, int w, int h)
+{
+ rband.x = x;
+ rband.y = y;
+ rband.width = w;
+ rband.height = h;
+
+ glutPostRedisplay();
+}
+
static void display(void)
{
return 0;
}
+void rtk_fix_rect(rtk_rect *rect)
+{
+ int x, y, w, h;
+
+ x = rect->x;
+ y = rect->y;
+
+ if(rect->width < 0) {
+ w = -rect->width;
+ x += rect->width;
+ } else {
+ w = rect->width;
+ }
+ if(rect->height < 0) {
+ h = -rect->height;
+ y += rect->height;
+ } else {
+ h = rect->height;
+ }
+
+ rect->x = x;
+ rect->y = y;
+ rect->width = w;
+ rect->height = h;
+}
void rtk_rect_union(rtk_rect *a, const rtk_rect *b)
{
int rtk_input_mmotion(rtk_widget *w, int x, int y);
/* misc */
+void rtk_fix_rect(rtk_rect *r);
void rtk_rect_union(rtk_rect *a, const rtk_rect *b);
#endif /* RTK_H_ */
static void act_addobj(void);
static void act_rmobj(void);
-static void fix_rect(rtk_rect *rect);
static void draw_rband(void);
static void moveobj(struct object *obj, int px0, int py0, int px1, int py1);
/* GUI */
rtk_draw_widget(toolbar);
-
- if(rband_valid) {
- draw_rband();
- }
}
static void draw_object(struct object *obj)
if(rband_valid) {
rband_valid = 0;
+ app_rband(0, 0, 0, 0);
if(cur_tool == TOOL_REND_AREA) {
if(prev_tool >= 0) {
}
rendering = 1;
rend_size(win_width, win_height);
- fix_rect(&rband);
+ rtk_fix_rect(&rband);
rendrect = rband;
rend_begin(rband.x, rband.y, rband.width, rband.height);
}
rband.width = x - rband.x;
rband.height = y - rband.y;
rband_valid = 1;
+ app_rband(rband.x, rband.y, rband.width, rband.height);
}
break;
}
}
-static void fix_rect(rtk_rect *rect)
-{
- int x, y, w, h;
-
- x = rband.x;
- y = rband.y;
-
- if(rband.width < 0) {
- w = -rband.width;
- x += rband.width;
- } else {
- w = rband.width;
- }
- if(rband.height < 0) {
- h = -rband.height;
- y += rband.height;
- } else {
- h = rband.height;
- }
-
- rect->x = x;
- rect->y = y;
- rect->width = w;
- rect->height = h;
-}
-
void primray(cgm_ray *ray, int x, int y)
{