本文整理汇总了C++中osg::TextureObjChunkRefPtr类的典型用法代码示例。如果您正苦于以下问题:C++ TextureObjChunkRefPtr类的具体用法?C++ TextureObjChunkRefPtr怎么用?C++ TextureObjChunkRefPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextureObjChunkRefPtr类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: grabImage
void grabImage(OSG::Image *img)
{
OSG::UInt8* data = img->editData();
// for this example, just fill it with random junk
if(changeOnlyPart)
{
// Just change a small rectangular area
OSG::UInt32 x = rand() % (img->getWidth() - 100);
OSG::UInt32 y = rand() % (img->getHeight() - 100);
OSG::UInt32 w = rand() % 100;
OSG::UInt32 h = rand() % 100;
OSG::UInt32 bpp = img->getBpp();
OSG::UInt32 bpl = img->getWidth() * bpp;
OSG::UInt32 bytes = w * bpp;
data += y * bpl + x * bpp;
OSG::UInt8 val = ((rand() & 0x7f) + 0x80);
for(OSG::UInt32 i = h; i > 0; --i, data += bpl)
{
OSG::UInt8 *d = data;
for(OSG::UInt32 j = bytes; j > 0; --j)
*d++ = val;
}
// If only a part of the image changed, only that part needs to
// be updated. The speed of the update operation is pretty
// directly dependent on the amount of data changed.
texObj->imageContentChanged(x, x + w, y, y + h);
}
else
{
// Fill the whole picture
for(OSG::UInt32 i = img->getHeight(); i > 0; --i)
{
OSG::UInt8 val = ((rand() & 0x3f) + 0x80);
for(OSG::UInt32 j = img->getWidth() * img->getBpp(); j > 0; --j)
*data++ = val;
}
// Everything changed
texObj->imageContentChanged();
}
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:50,代码来源:videotexturebackground.cpp
示例2: main
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
// OSG init
OSG::osgInit(argc,argv);
// GLUT init
int winid = setupGLUT(&argc, argv);
{
// the connection between GLUT and OpenSG
OSG::GLUTWindowRefPtr gwin = OSG::GLUTWindow::create();
gwin->setGlutId(winid);
gwin->init();
// create the scene
OSG::NodeRefPtr torus = OSG::makeTorus( .5, 2, 16, 32 );
OSG::NodeRefPtr scene = OSG::Node::create();
trans = OSG::Transform::create();
scene->setCore(trans);
scene->addChild(torus);
// Create the parts needed for the video background
OSG::UInt32 width = 640;
OSG::UInt32 height = 480;
// get the desired size from the command line
if(argc >= 3)
{
width = atoi(argv[1]);
height = atoi(argv[2]);
}
// To check OpenGL extensions, the Window needs to have run through
// frameInit at least once. This automatically happens when rendering,
// but we can't wait for that here.
gwin->activate ();
gwin->frameInit();
// Now we can check for OpenGL extensions
hasNPOT = gwin->hasExtension("GL_ARB_texture_non_power_of_two");
// Print what we've got
SLOG << "Got " << (isPOT?"":"non-") << "power-of-two images and "
<< (hasNPOT?"can":"cannot") << " use NPOT textures, changing "
<< (changeOnlyPart?"part":"all")
<< " of the screen"
<< std::endl;
// Ok, now for the meat of the code...
// first we need an Image to hold the picture(s) to show
image = OSG::Image::create();
// set the image's size and type, and allocate memory
// this example uses RGB. On some systems (e.g. Windows) BGR
// or BGRA might be faster, it depends on how the images are
// acquired
image->set(OSG::Image::OSG_RGB_PF, width, height);
// Now create the texture to be used for the background
texObj = OSG::TextureObjChunk::create();
// Associate image and texture
texObj->setImage(image);
// Set filtering modes. LINEAR is cheap and good if the image size
// changes very little (i.e. the window is about the same size as
// the images).
texObj->setMinFilter(GL_LINEAR);
texObj->setMagFilter(GL_LINEAR);
// Set the wrapping modes. We don't need repetition, it might actually
// introduce artifactes at the borders, so switch it off.
texObj->setWrapS(GL_CLAMP_TO_EDGE);
texObj->setWrapT(GL_CLAMP_TO_EDGE);
// Newer versions of OpenGL can handle NPOT textures directly.
// OpenSG will do that internally automatically.
//
// Older versions need POT textures. By default OpenSG
// will scale an NPOT texture to POT while defining it.
// For changing textures that's too slow.
// So tell OpenSG not to scale the image and adjust the texture
// coordinates used by the TextureBackground (see below).
texObj->setScale(false);
// Create the background
OSG::TextureBackgroundRefPtr back = OSG::TextureBackground::create();
//.........这里部分代码省略.........
开发者ID:jondo2010,项目名称:OpenSG,代码行数:101,代码来源:videotexturebackground.cpp
注:本文中的osg::TextureObjChunkRefPtr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论