int main(int argc, char **argv) { setup_bind_pose(); GFX gfx; gfx.Init(800,600,false,DrawScene); timeBeginPeriod(1); glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);get_GL_error(); wglSwapIntervalEXT(0); #ifdef USE_PBUFFER pbuffer.Init(512,512); pbuffer.begin(); gfx.InitGL(512,512); #endif // manager.load_obj ("../media/trousers.obj"); // manager.load_obj ("../media/box2.obj"); // manager.load_obj ("../media/can4.obj"); // manager.load_obj ("../media/suspension.obj"); // manager.load_obj ("../media/leg3.obj"); // manager.load_obj ("../media/female3.obj"); // manager.load_obj ("../media/char3.obj"); manager.load_obj ("../media/female-legs.obj"); #ifdef USE_PBUFFER pbuffer.end(); #endif manager.print_controls(); manager.print_materials(); gfx.Run(); return 0; }
//Set up variables bool DemoInit() { if(!window.Init("Render To Texture", 640, 480, 32, 24, 8, WINDOWED_SCREEN)) return 0; //quit if not created camera.Init(VECTOR3D(0.0f, 0.0f, -2.5f), 2.0f, 100.0f); //Set up extensions if( !SetUpWGL_ARB_extensions_string()) return false; SetUpEXT_texture_filter_anisotropic(); SetUpSGIS_generate_mipmap(); //Get the WGL extensions string const char * wglExtensions; wglExtensions=wglGetExtensionsStringARB(window.hDC); //Set up wgl extensions if( !SetUpWGL_ARB_pbuffer(wglExtensions) || !SetUpWGL_ARB_pixel_format(wglExtensions) || !SetUpWGL_ARB_render_texture(wglExtensions)) return false; //Init the pbuffer int pbufferExtraIAttribs[]={WGL_BIND_TO_TEXTURE_RGBA_ARB, true, 0}; int pbufferFlags[]={WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB, WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB, //request mipmap space if mipmaps are to be used SGIS_generate_mipmap_supported ? WGL_MIPMAP_TEXTURE_ARB : 0, SGIS_generate_mipmap_supported ? true : 0, 0}; if(!pbuffer.Init(pbufferSize, pbufferSize, 32, 24, 8, 1, pbufferExtraIAttribs, pbufferFlags)) return false; //Create the texture object to relate to the pbuffer glGenTextures(1, &pbufferTexture); glBindTexture(GL_TEXTURE_2D, pbufferTexture); 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_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //Use generated mipmaps if supported if(SGIS_generate_mipmap_supported) { glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, true); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST); useMipmapFilter=true; } //Use maximum anisotropy if supported if(EXT_texture_filter_anisotropic_supported) { glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy); currentAnisotropy=maxAnisotropy; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy); } //Load the decal texture //Note: This MUST be done when the pbuffer is the current context pbuffer.MakeCurrent(); IMAGE decalImage; decalImage.Load("decal.bmp"); glGenTextures(1, &decalTexture); glBindTexture(GL_TEXTURE_2D, decalTexture); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, decalImage.width, decalImage.height, 0, decalImage.format, GL_UNSIGNED_BYTE, decalImage.data); 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_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //reset timer for start timer.Reset(); return true; }