资源简介
opengl渲染到纹理技术,RendertoaTexture很好的例子
代码片段和文件信息
//***********************************************************************//
// //
// - “Talk to me like I‘m a 3 year old!“ Programming Lessons - //
// //
// $Author: DigiBen digiben@gametutorials.com //
// //
// $Program: RenderToTexture //
// //
// $Description: Demonstrates how to render screen to a texture //
// //
// $Date: 2/27/02 //
// //
//***********************************************************************//
#include “main.h“
///////////////////////////////// CREATE TEXTURE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This creates a texture in OpenGL that we can texture map
/////
///////////////////////////////// CREATE TEXTURE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void CreateTexture(UINT textureArray[] LPSTR strFileName int textureID)
{
AUX_RGBImageRec *pBitmap = NULL;
if(!strFileName) // Return from the function if no file name was passed in
return;
// We need to load the texture data so we use a cool API that the glaux.lib offers.
pBitmap = auxDIBImageLoad(strFileName); // Load the bitmap and store the data
if(pBitmap == NULL) // If we can‘t load the file quit!
exit(0);
// Generate a texture with the associative texture ID stored in the array
glGenTextures(1 &textureArray[textureID]);
// Bind the texture to the texture arrays index and init the texture
glBindTexture(GL_TEXTURE_2D textureArray[textureID]);
// Build Mipmaps (builds different versions of the picture for distances - looks better)
gluBuild2DMipmaps(GL_TEXTURE_2D 3 pBitmap->sizeX pBitmap->sizeY GL_RGB GL_UNSIGNED_BYTE pBitmap->data);
// Lastly we need to tell OpenGL the quality of our texture map. GL_LINEAR_MIPMAP_LINEAR
// is the smoothest. GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR_MIPMAP_LINEAR
// but looks blochy and pixilated. Good for slower computers though.
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MIN_FILTERGL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR);
// Now we need to free the bitmap data that we loaded since openGL stored it as a texture
if (pBitmap) // If we loaded the bitmap
{
if (pBitmap->data) // If there is texture data
{
free(pBitmap->data); // Free the texture data we don‘t need it anymore
}
free(pBitmap); // Free the bitmap structure
}
}
///////////////////////////////// CHANGE TO FULL SCREEN \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/////
///// This changes the screen to FULL SCREEN
/////
///////////////////////////////// CHANGE TO FULL SCREEN \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
void ChangeToFullScreen()
{
DEVMODE dmSettings; // Device Mode variable
memset(&dmSettings0sizeof(dmSettings)); // Makes Sure
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4410 2005-01-09 23:45 Render to a Texture\RenderToTexture.vcproj
文件 19377 2003-11-20 00:36 Render to a Texture\Main.cpp
文件 919 2005-01-09 23:45 Render to a Texture\RenderToTexture.sln
文件 12795 2003-11-20 00:37 Render to a Texture\Init.cpp
文件 196662 2002-02-28 01:59 Render to a Texture\Brick.bmp
文件 3096 2002-02-28 01:56 Render to a Texture\main.h
文件 49152 2003-11-20 00:37 Render to a Texture\RenderToTexture.exe
文件 2108 2003-04-20 17:51 Render to a Texture\ReadMe - RenderToTexture.txt
目录 0 2008-05-01 01:47 Render to a Texture
----------- --------- ---------- ----- ----
288737 10
相关资源
- VS2012OpenGL配置所需要的全部libdllh文件
- Influence of shear banding on the formation of
- Experiment investigation of deep-drawing sheet
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
- opengl完美天空盒
- 3D绘图程序设计:使用Direct3D 10/9和Ope
- OpenGL绘制可运动自行车源程序.zip
- OpenGL实现飘动效果
- opengl室内场景的绘制,包括碰撞检测
- OpenGL场景漫游
- 用opengl实现的太阳系模型
- OpenGL 3D贪吃蛇程序,很小
- OpenGL爆炸碎片化效果 源码
- OpenGL三茶壶三光源光源绕着茶壶旋转
- 10个OpenGL的源码
- vc写的一个游戏里面三维场景漫游
- OpenGL实现的简单游戏引擎
- OpenGL游戏程序设计源码
- glew最新版本glew1.11.0
- Rendering to an off-screen
- Anti_TexturePacker v1.6
- OpenGL 火箭
- Direct3D Rendering Cookbook
评论
共有 条评论