void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: exit(EXIT_SUCCESS); break; case '=': case '+': w += 0.01f; break; case '-': w -= 0.01f; break; case 'f': linearFiltering = !linearFiltering; setTextureFilterMode(linearFiltering); break; case ' ': animate = !animate; break; default: break; } glutPostRedisplay(); }
void keyboard(unsigned char key, int x, int y) { switch(key) { case 27: exit(0); break; case 'f': linearFiltering = !linearFiltering; setTextureFilterMode(linearFiltering); break; case '=': density += 0.01; break; case '-': density -= 0.01; break; case '+': density += 0.1; break; case '_': density -= 0.1; break; case ']': brightness += 0.1; break; case '[': brightness -= 0.1; break; case ';': transferOffset += 0.01; break; case '\'': transferOffset -= 0.01; break; case '.': transferScale += 0.01; break; case ',': transferScale -= 0.01; break; default: break; } shrLog("density = %.2f, brightness = %.2f, transferOffset = %.2f, transferScale = %.2f\n", density, brightness, transferOffset, transferScale); glutPostRedisplay(); }
ImageGL::ImageGL(unsigned int nDispWidth, unsigned int nDispHeight, unsigned int nTexWidth, unsigned int nTexHeight, bool bVsync, PixelFormat ePixelFormat) : nWidth_(nDispWidth) , nHeight_(nDispHeight) , nTexWidth_(nTexWidth) , nTexHeight_(nTexHeight) , e_PixFmt_(ePixelFormat) , bVsync_(bVsync) , bIsCudaResource_(false) { int nFrames = bVsync_ ? 3 : 1; glGenBuffersARB(nFrames, gl_pbo_); for (int n=0; n < nFrames; n++) { glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, gl_pbo_[n]); glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, nTexWidth*nTexHeight*4, NULL, GL_STREAM_DRAW_ARB); glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0); registerAsCudaResource(n); } // create texture for display glGenTextures(nFrames, gl_texid_); // setup the Texture filtering mode setTextureFilterMode(GL_NEAREST, GL_NEAREST); // load gl_shader_ program gl_shader_ = compile_glsl_shader(GL_FRAGMENT_PROGRAM_ARB, gl_shader_code); glPrimitiveRestartIndex(65535); glEnable(GL_PRIMITIVE_RESTART); }