# HG changeset patch # User John Tsiombikas # Date 1357647546 -7200 # Node ID 1d5dc834d40309d606496f4ba2df1999602d40d7 # Parent 2d27bfd21fc51113c214540e32769c9e839f92ba blockify diff -r 2d27bfd21fc5 -r 1d5dc834d403 src/udg.cc --- a/src/udg.cc Tue Jan 08 03:16:48 2013 +0200 +++ b/src/udg.cc Tue Jan 08 14:19:06 2013 +0200 @@ -16,6 +16,14 @@ #define DITHER_SZ 4 #define DITHER_LEVELS 16 +#if DITHER_SZ == 4 +#define dither_matrix dither_matrix4 +#elif DITHER_SZ == 8 +#define dither_matrix dither_matrix8 +#else +#error "invalid dither size" +#endif + struct render_target { unsigned int fbo; unsigned int color_tex, depth_buf; @@ -41,7 +49,7 @@ int main(int argc, char **argv) { glutInit(&argc, argv); - glutInitWindowSize(800, 600); + glutInitWindowSize(1024, 768); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutCreateWindow("DBF UDG compo entry by Nuclear"); @@ -72,7 +80,7 @@ for(int y=0; y= thres ? 1.0 : 0.0; } } @@ -132,13 +140,14 @@ float ldir[] = {-1, 1, 2, 0}; if(!rtarg) { - printf("(re)creating render target (%dx%d)\n", xsz, ysz); - if(!(rtarg = create_rtarg(xsz, ysz))) { + printf("(re)creating render target (%dx%d)\n", xsz / DITHER_SZ, ysz / DITHER_SZ); + if(!(rtarg = create_rtarg(xsz / DITHER_SZ, ysz / DITHER_SZ))) { exit(0); } } glBindFramebufferEXT(GL_FRAMEBUFFER, rtarg->fbo); + glViewport(0, 0, xsz / DITHER_SZ, ysz / DITHER_SZ); glClearColor(1, 1, 1, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -163,6 +172,8 @@ glBindFramebufferEXT(GL_FRAMEBUFFER, 0); + glViewport(0, 0, xsz, ysz); + glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); @@ -292,8 +303,8 @@ glBindTexture(GL_TEXTURE_2D, rt->color_tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, xsz, ysz, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->color_tex, 0);