CG中指定纹理的两种方法
来源:互联网 发布:激光器的软件 编辑:程序博客网 时间:2024/05/18 21:09
方法一:使用Opengl的多重纹理以及CG的semantics
// In C++ File:
// Identify the textures to use for the pixel shader...
cgGLSetTextureParameter( g_CGparam_testTexture, g_testTextureID );
cgGLSetTextureParameter( g_CGparam_checkerTexture, g_checkerTextureID );
// STAGE 0
glActiveTextureARB( GL_TEXTURE0_ARB );
glBindTexture( GL_TEXTURE_2D, g_testTextureID );
// STAGE 1
glActiveTextureARB( GL_TEXTURE1_ARB );
glBindTexture( GL_TEXTURE_2D, g_checkerTextureID );
cgGLBindProgram( g_CGprogram_pixel );
cgGLEnableProfile( g_CGprofile_pixel );
// Draw primitives
cgGLDisableProfile( g_CGprofile_pixel );
// In Cg File:
uniform sampler2D testTexture : TEXUNIT0,
uniform sampler2D checkerTexture : TEXUNIT1
方法二:使用CG的纹理函数cgGLSetTextureParameter, cgGLEnableTextureParameter, cgGLDisableTextureParameter
g_CGparam_testTexture = cgGetNamedParameter(g_CGprogram_pixel, "testTexture");
g_CGparam_checkerTexture = cgGetNamedParameter(g_CGprogram_pixel, "checkerTexture");
// Identify the textures to use for the pixel shader...
cgGLSetTextureParameter( g_CGparam_testTexture, g_testTextureID );
cgGLSetTextureParameter( g_CGparam_checkerTexture, g_checkerTextureID );
cgGLBindProgram( g_CGprogram_pixel );
cgGLEnableProfile( g_CGprofile_pixel );
cgGLEnableTextureParameter( g_CGparam_testTexture );
cgGLEnableTextureParameter( g_CGparam_checkerTexture );
// Draw primitives
cgGLDisableTextureParameter( g_CGparam_checkerTexture );
cgGLDisableTextureParameter( g_CGparam_testTexture );
cgGLDisableProfile( g_CGprofile_pixel );
// In Cg File:
uniform sampler2D testTexture,
uniform sampler2D checkerTexture
最近在绘制程序中用到了这两种纹理制定方法,由于一直没理清头绪,遇到很多麻烦
在我程序中,两种方法不可以混用,否则会出现纹理混淆的状况,即你指定了纹理1,实际上在cg中得到的是纹理2
方法一似乎更稳定些,但具体这两种方法各有什么优势和限制还不得而知,这方面的资料也实在很少,看来需要更多的积累
原文:http://dev.21tx.com/2005/09/22/15665.html
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/rainbowx/archive/2008/10/16/3086192.aspx
- CG中指定纹理的两种方法
- CG中指定纹理的两种方法
- Struts2调用action中指定的方法
- 去除字符串中指定字符的方法
- C++中指定输出格式的方法
- php删除数组中指定值的元素的几种方法
- php删除数组中指定值的元素的几种方法
- 找出设备中指定的所有应用的方法
- python打印列表中指定元素的所有下标(5种方法)
- C# VI: 删除字符串中指定字符的几种方法
- java运行jar包中指定Class的main方法
- Oracle实现获得字符串中指定字符个数的方法
- Java-调用抽象类中指定参数的构造方法
- 今天学到的几个替换字符串中指定字符方法。
- C#获取网页中指定图片的方法
- JAVA基础 - 删除字符串中指定字符串的方法
- java运行jar包中指定Class的main方法
- window.print()打印网页中指定内容的实现方法
- 10种用户友好的验证码
- adobe reader的英文字体很难看的解决方法
- Android2.2的camera应用程序中支持双camera切换(一)
- Louis Vuitton wallet M93561 Shenyang lack of high-rise fire caused by a high majority of gun fire useless field
- 回答朋友的问题(关于 RTEMS 的知识储备)
- CG中指定纹理的两种方法
- Android2.2的camera应用程序中支持双camera切换(二)
- 面向程序员的数据库访问性能优化法则
- 计算几何 模板
- 八种常见的防盗链方法总结及分析
- 最短路径-Dijkstra
- vilast
- 怎样给flash文件中的图片和文字插入超链接?
- 关于导入swf时安全域与应用域的问题