rewrote demo for better examples

This commit is contained in:
vurtun 2015-11-05 19:39:51 +01:00
parent cb2e9c2f41
commit 1aac008546
4 changed files with 758 additions and 767 deletions

File diff suppressed because it is too large Load Diff

View File

@ -103,8 +103,8 @@ draw(NVGcontext *nvg, struct zr_command_queue *queue, int width, int height)
nvgBeginPath(nvg);
nvgMoveTo(nvg, l->begin.x, l->begin.y);
nvgLineTo(nvg, l->end.x, l->end.y);
nvgFillColor(nvg, nvgRGBA(l->color.r, l->color.g, l->color.b, l->color.a));
nvgFill(nvg);
nvgStrokeColor(nvg, nvgRGBA(l->color.r, l->color.g, l->color.b, l->color.a));
nvgStroke(nvg);
} break;
case ZR_COMMAND_CURVE: {
const struct zr_command_curve *q = zr_command(curve, cmd);
@ -244,7 +244,7 @@ main(int argc, char *argv[])
NVGcontext *vg = NULL;
/* GUI */
struct demo_gui gui;
struct demo gui;
if (argc < 2) {
fprintf(stdout,"Missing TTF Font file argument: gui <path>\n");
exit(EXIT_FAILURE);
@ -306,7 +306,7 @@ main(int argc, char *argv[])
run_demo(&gui);
/* Draw */
glClearColor(0.4f, 0.4f, 0.4f, 1.0f);
glClearColor(0.9f, 0.9f, 0.9f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
draw(vg, &gui.queue, width, height);
SDL_GL_SwapWindow(win);

View File

@ -444,7 +444,7 @@ main(int argc, char *argv[])
/* GUI */
struct zr_allocator alloc;
struct device device;
struct demo_gui gui;
struct demo gui;
struct zr_font font;
font_path = argv[1];
@ -511,7 +511,7 @@ main(int argc, char *argv[])
/* Draw */
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.4f, 0.4f, 0.4f, 1.0f);
glClearColor(0.9f, 0.9f, 0.9f, 1.0f);
device_draw(&device, &gui.queue, width, height, ZR_ANTI_ALIASING_ON);
SDL_GL_SwapWindow(win);
}

View File

@ -218,12 +218,10 @@ static void
surface_scissor(XSurface *surf, float x, float y, float w, float h)
{
XRectangle clip_rect;
clip_rect.x = (short)(x - 1);
clip_rect.y = (short)(y - 1);
clip_rect.x = (short)(x-1);
clip_rect.y = (short)(y-1);
clip_rect.width = (unsigned short)(w + 2);
clip_rect.height = (unsigned short)(h + 2);
clip_rect.width = (unsigned short)MIN(surf->w, clip_rect.width);
clip_rect.height = (unsigned short)MIN(surf->h, clip_rect.height);
XSetClipRectangles(surf->dpy, surf->gc, 0, 0, &clip_rect, 1, Unsorted);
}
@ -283,8 +281,6 @@ surface_draw_text(XSurface *surf, zr_short x, zr_short y, zr_ushort w, zr_ushort
XFillRectangle(surf->dpy, surf->drawable, surf->gc, (int)x, (int)y, (unsigned)w, (unsigned)h);
if(!text || !font || !len) return;
tx = (int)x;
th = font->ascent + font->descent;
ty = (int)y + ((int)h / 2) - (th / 2) + font->ascent;
@ -429,7 +425,7 @@ main(int argc, char *argv[])
long dt;
long started;
XWindow xw;
struct demo_gui gui;
struct demo gui;
/* Platform */
UNUSED(argc); UNUSED(argv);
@ -490,7 +486,7 @@ main(int argc, char *argv[])
/* Draw */
XClearWindow(xw.dpy, xw.win);
surface_clear(xw.surf, 0x00646464);
surface_clear(xw.surf, 0x00FFFFFF);
draw(xw.surf, &gui.queue);
surface_blit(xw.win, xw.surf, xw.width, xw.height);
XFlush(xw.dpy);