[brlcad-commits] SF.net SVN: brlcad:[39141] isst/trunk/sdl
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <eri...@us...> - 2010-05-12 17:28:10
|
Revision: 39141 http://brlcad.svn.sourceforge.net/brlcad/?rev=39141&view=rev Author: erikgreenwald Date: 2010-05-12 17:28:02 +0000 (Wed, 12 May 2010) Log Message: ----------- show how to pass values to plugin. use "z" to set the raytrace resolution to a fixed size Modified Paths: -------------- isst/trunk/sdl/event.c isst/trunk/sdl/isst.h isst/trunk/sdl/main.c isst/trunk/sdl/myplugin.c Modified: isst/trunk/sdl/event.c =================================================================== --- isst/trunk/sdl/event.c 2010-05-12 17:12:59 UTC (rev 39140) +++ isst/trunk/sdl/event.c 2010-05-12 17:28:02 UTC (rev 39141) @@ -69,8 +69,8 @@ void move_float(struct isst_s * isst, double dist) { - isst->camera.pos.v[2] += dist; - isst->camera.focus.v[2] += dist; + isst->camera.pos.v[2] += 2*dist; + isst->camera.focus.v[2] += 2*dist; } void @@ -117,7 +117,9 @@ int fc = 0, showfps = 1; double dt = 1.0, dt2 = 0.0; double mouse_sensitivity = 0.1; + double val = 1; int vel[3] = { 0, 0, 0 }; + char buf[BUFSIZ]; gettimeofday(ts, NULL); @@ -176,7 +178,9 @@ case '2': render_shader_init(&isst->camera.render, "normal", NULL); break; case '3': render_shader_init(&isst->camera.render, "depth", NULL); break; case '4': render_shader_init(&isst->camera.render, "component", NULL); break; - case '=': render_shader_init(&isst->camera.render, "myplugin", NULL); break; + case '=': snprintf(buf, BUFSIZ, "%f", val); render_shader_init(&isst->camera.render, "myplugin", buf); break; + case '[': val -= 0.1; snprintf(buf, BUFSIZ, "%f", val); render_shader_init(&isst->camera.render, "myplugin", buf); break; + case ']': val += 0.1; snprintf(buf, BUFSIZ, "%f", val); render_shader_init(&isst->camera.render, "myplugin", buf); break; case SDLK_DELETE: case '-': { @@ -185,7 +189,8 @@ printf("Failed unloading plugin"); exit(-1); } - render_shader_init(&isst->camera.render, render_shader_load_plugin(".libs/libmyplugin.0.dylib"), NULL); + snprintf(buf, BUFSIZ, "%f", val); + render_shader_init(&isst->camera.render, render_shader_load_plugin(".libs/libmyplugin.0.dylib"), buf); } break; case SDLK_UP: @@ -199,6 +204,7 @@ case ' ': vel[2] = 1; break; case 'v': vel[2] = -1; break; case '0': zero_view(isst); break; + case 'z': isst->gs = !isst->gs; resize_isst(isst); break; /* TODO: more keys for nifty things like changing mode or pulling up gui bits or something */ } break; @@ -222,7 +228,7 @@ case 1: break; case 4: - look(isst, mouse_sensitivity * dt * e.motion.xrel, mouse_sensitivity * dt * e.motion.yrel); + look(isst, isst->w / isst->camera.w * mouse_sensitivity * dt * e.motion.xrel, isst->h / isst->camera.h * mouse_sensitivity * dt * e.motion.yrel); break; } break; Modified: isst/trunk/sdl/isst.h =================================================================== --- isst/trunk/sdl/isst.h 2010-05-12 17:12:59 UTC (rev 39140) +++ isst/trunk/sdl/isst.h 2010-05-12 17:28:02 UTC (rev 39141) @@ -31,7 +31,7 @@ tienet_buffer_t buffer_image; struct SDL_Rect r; struct SDL_Surface *screen; - int ogl, sflags, w, h; + int ogl, sflags, w, h, gs; #ifdef HAVE_OPENGL int texid; void *texdata; Modified: isst/trunk/sdl/main.c =================================================================== --- isst/trunk/sdl/main.c 2010-05-12 17:12:59 UTC (rev 39140) +++ isst/trunk/sdl/main.c 2010-05-12 17:28:02 UTC (rev 39141) @@ -61,8 +61,12 @@ isst->r.w = isst->tile.size_x = isst->camera.w = isst->w; isst->r.h = isst->tile.size_y = isst->camera.h = isst->h; isst->r.x = isst->r.y = isst->tile.orig_x = isst->tile.orig_y = 0; + if(!isst->gs) { + isst->camera.w = isst->tile.size_x = 320; + isst->camera.h = isst->tile.size_y = 240; + } isst->tile.format = RENDER_CAMERA_BIT_DEPTH_24; - TIENET_BUFFER_SIZE(isst->buffer_image, 3 * isst->w * isst->h); + TIENET_BUFFER_SIZE(isst->buffer_image, 3 * isst->camera.w * isst->camera.h); isst->screen = SDL_SetVideoMode (isst->w, isst->h, 24, isst->sflags); if(isst->screen == NULL) { printf("Failed to generate display context\n"); @@ -73,11 +77,11 @@ glClearColor (0.0, 0, 0.0, 1); glBindTexture (GL_TEXTURE_2D, isst->texid); glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - isst->texdata = malloc(isst->r.w * isst->r.h * 3); - glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, isst->r.w, isst->r.h, 0, GL_RGB, GL_UNSIGNED_BYTE, isst->texdata); + isst->texdata = malloc(isst->camera.w * isst->camera.h * 3); + glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, isst->camera.w, isst->camera.h, 0, GL_RGB, GL_UNSIGNED_BYTE, isst->texdata); glDisable(GL_LIGHTING); glViewport(0,0,isst->r.w, isst->r.h); glMatrixMode (GL_PROJECTION); @@ -103,7 +107,6 @@ load_g(isst->tie, file, argc-1, (const char **)argv, &(isst->meshes)); bu_free((genptr_t)argv, "isst sdl"); - } static void @@ -165,7 +168,7 @@ glColor3f(1,1,1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, isst->texid); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, isst->r.w, isst->r.h, GL_RGB, GL_UNSIGNED_BYTE, isst->buffer_image.data); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, isst->camera.w, isst->camera.h, GL_RGB, GL_UNSIGNED_BYTE, isst->buffer_image.data); glBegin(GL_TRIANGLE_STRIP); glTexCoord2d(0,0); glVertex3f(0,0,0); glTexCoord2d(0,1); glVertex3f(0,isst->r.h,0); Modified: isst/trunk/sdl/myplugin.c =================================================================== --- isst/trunk/sdl/myplugin.c 2010-05-12 17:12:59 UTC (rev 39140) +++ isst/trunk/sdl/myplugin.c 2010-05-12 17:28:02 UTC (rev 39141) @@ -24,6 +24,7 @@ void init(render_t *r, char *usr) { + printf("value passed to shader: %s\n", usr); r->work = adrt_plugin_work; r->free = adrt_plugin_free; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |