本文整理汇总了C++中TextureChunkPtr::setNPOTMatrixScale方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureChunkPtr::setNPOTMatrixScale方法的具体用法?C++ TextureChunkPtr::setNPOTMatrixScale怎么用?C++ TextureChunkPtr::setNPOTMatrixScale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureChunkPtr
的用法示例。
在下文中一共展示了TextureChunkPtr::setNPOTMatrixScale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSceneFBO
//.........这里部分代码省略.........
// Make Torus Node (creates Torus in background of scene)
NodePtr TorusGeometryNode = makeTorus(.5, 2, 24, 48);
beginEditCP(TorusGeometryNode->getCore());
GeometryPtr::dcast(TorusGeometryNode->getCore())->setMaterial(TheMaterial);
endEditCP(TorusGeometryNode->getCore());
calcVertexNormals(GeometryPtr::dcast(TorusGeometryNode->getCore()));
calcVertexTangents(GeometryPtr::dcast(TorusGeometryNode->getCore()),0,Geometry::TexCoords7FieldId, Geometry::TexCoords6FieldId);
RootTransformCore = Transform::create();
NodePtr TorusTransformNode = Node::create();
beginEditCP(TorusTransformNode, Node::CoreFieldMask);
TorusTransformNode->setCore(RootTransformCore);
TorusTransformNode->addChild(TorusGeometryNode);
endEditCP(TorusTransformNode, Node::CoreFieldMask);
//Create Light Beacon
Matrix LightMat;
LightMat.setTranslate(0.0f,10.0f,1.0f);
TransformPtr LightBeconCore = Transform::create();
beginEditCP(LightBeconCore, Transform::MatrixFieldMask);
LightBeconCore->setMatrix(LightMat);
endEditCP(LightBeconCore, Transform::MatrixFieldMask);
NodePtr LightBeconNode = Node::create();
beginEditCP(LightBeconNode, Node::CoreFieldMask);
LightBeconNode->setCore(LightBeconCore);
endEditCP(LightBeconNode, Node::CoreFieldMask);
//Create Light
TheLight = PointLight::create();
beginEditCP(TheLight);
TheLight->setBeacon(LightBeconNode);
endEditCP(TheLight);
NodePtr LightNode = Node::create();
beginEditCP(LightNode, Node::CoreFieldMask);
LightNode->setCore(TheLight);
LightNode->addChild(TorusTransformNode);
endEditCP(LightNode, Node::CoreFieldMask);
//Create Root
NodePtr TheRoot = Node::create();
beginEditCP(TheRoot);
TheRoot->setCore(Group::create());
TheRoot->addChild(CameraBeconNode);
TheRoot->addChild(LightNode);
TheRoot->addChild(LightBeconNode);
endEditCP(TheRoot);
//Create Background
SolidBackgroundPtr TheBackground = SolidBackground::create();
TheBackground->setColor(Color3f(1.0,0.0,0.0));
//DepthClearBackgroundPtr TheBackground = DepthClearBackground::create();
//Create the Image
ImagePtr TheColorImage = Image::create();
TheColorImage->set(Image::OSG_RGB_PF,2,2,1,1,1,0.0f,0,Image::OSG_FLOAT16_IMAGEDATA);
//Create the texture
TextureChunkPtr TheColorTextureChunk = TextureChunk::create();
beginEditCP(TheColorTextureChunk);
TheColorTextureChunk->setImage(TheColorImage);
TheColorTextureChunk->setMinFilter(GL_NEAREST);
TheColorTextureChunk->setMagFilter(GL_NEAREST);
TheColorTextureChunk->setWrapS(GL_CLAMP_TO_EDGE);
TheColorTextureChunk->setWrapR(GL_CLAMP_TO_EDGE);
TheColorTextureChunk->setScale(false);
TheColorTextureChunk->setNPOTMatrixScale(true);
TheColorTextureChunk->setEnvMode(GL_REPLACE);
TheColorTextureChunk->setInternalFormat(GL_RGB16F);
endEditCP(TheColorTextureChunk);
//Create FBO
FBOViewportPtr TheFBO = FBOViewport::create();
beginEditCP(TheFBO);
TheFBO->setBackground(TheBackground);
TheFBO->setRoot(TheRoot);
TheFBO->setCamera(TheCamera);
TheFBO->setEnabled(true);
TheFBO->getTextures().push_back(TheColorTextureChunk);
TheFBO->setStorageWidth(TheColorTextureChunk->getImage()->getWidth());
TheFBO->setStorageHeight(TheColorTextureChunk->getImage()->getHeight());
TheFBO->setSize(0,0,TheColorTextureChunk->getImage()->getWidth()-1, TheColorTextureChunk->getImage()->getHeight()-1);
endEditCP(TheFBO);
return TheFBO;
}
示例2: createVideoMaterial
MaterialPtr createVideoMaterial(void)
{
// Ok, now for the meat of the code...
// first we need an Image to hold the picture(s) to show
//image = Image::create();
//beginEditCP(image);
//{
// 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(Image::OSG_RGB_PF, 2, 2);
//}
//endEditCP(image);
// Now create the texture to be used for the background
tex = TextureChunk::create();
beginEditCP(tex);
{
// Associate image and texture
//tex->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).
//tex->setMinFilter(GL_LINEAR);
tex->setMinFilter(GL_NEAREST);
tex->setMagFilter(GL_LINEAR);
//tex->setMagFilter(GL_NEAREST);
// Set the wrapping modes. We don't need repetition, it might actually
// introduce artifactes at the borders, so switch it off.
tex->setWrapS(GL_CLAMP_TO_EDGE);
tex->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, but use the texture
// matrix to scale. This only works if we're not using the
// texture matrix for anything else, which is fine for video
// backgrounds.
// This does not do anything if NPOT textures are supported, so
// it is safe to just set it.
tex->setScale(false);
tex->setNPOTMatrixScale(true);
}
endEditCP(tex);
ChunkMaterialPtr TheMaterial = ChunkMaterial::create();
beginEditCP(TheMaterial, ChunkMaterial::ChunksFieldMask);
TheMaterial->addChunk(tex);
TheMaterial->addChunk(MaterialChunk::create());
endEditCP(TheMaterial, ChunkMaterial::ChunksFieldMask);
return TheMaterial;
}
示例3: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindowEventProducer = createDefaultWindowEventProducer();
WindowPtr MainWindow = TutorialWindowEventProducer->initWindow();
TutorialWindowEventProducer->setDisplayCallback(display);
TutorialWindowEventProducer->setReshapeCallback(reshape);
TutorialKeyListener TheKeyListener;
TutorialWindowEventProducer->addKeyListener(&TheKeyListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(MainWindow);
// Make Torus Node (creates Torus in background of scene)
NodePtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodePtr scene = osg::Node::create();
beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
scene->setCore(osg::Group::create());
scene->addChild(TorusGeometryNode);
endEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
//Create the Image
Path ImagePath("./Data/TutorialImage.jpg");
ImagePtr TheImage = ImageFileHandler::the().read(ImagePath.string().c_str());
//Create the texture
TextureChunkPtr TheTextureChunk = TextureChunk::create();
beginEditCP(TheTextureChunk);
TheTextureChunk->setImage(TheImage);
TheTextureChunk->setMinFilter(GL_NEAREST);
TheTextureChunk->setMagFilter(GL_NEAREST);
TheTextureChunk->setWrapS(GL_CLAMP_TO_EDGE);
TheTextureChunk->setWrapR(GL_CLAMP_TO_EDGE);
TheTextureChunk->setScale(false);
TheTextureChunk->setNPOTMatrixScale(true);
TheTextureChunk->setEnvMode(GL_REPLACE);
endEditCP(TheTextureChunk);
//Create a Texture Source
TextureSourceTextureFilterPtr TutorialTextureSourceTextureFilter = TextureSourceTextureFilter::create();
beginEditCP(TutorialTextureSourceTextureFilter, TextureSourceTextureFilter::TextureFieldMask);
TutorialTextureSourceTextureFilter->setTexture(TheTextureChunk);
endEditCP(TutorialTextureSourceTextureFilter, TextureSourceTextureFilter::TextureFieldMask);
//Create a Grayscale filter
std::string GrayScaleFragProg = "uniform sampler2D Slot0Texture; void main() { gl_FragColor = vec4(vec3( dot(vec3(0.3,0.59,0.11), texture2D(Slot0Texture,gl_TexCoord[0].st).rgb)), 1.0); }";
//Create a shader Filter
ShaderTextureFilterPtr GrayscaleTextureFilter = ShaderTextureFilter::create();
GrayscaleTextureFilter->attachSource(TutorialTextureSourceTextureFilter, 0, 0);
GrayscaleTextureFilter->setFragmentSource(GrayScaleFragProg);
//Create a Color Mult filter
std::string ColorMultFragProg = "uniform sampler2D Slot0Texture; void main() { gl_FragColor = vec4(vec3(1.0,0.0,0.0) * texture2D(Slot0Texture,gl_TexCoord[0].st).rgb, 1.0); }";
//Create a shader Filter
ShaderTextureFilterPtr ColorMultTextureFilter = ShaderTextureFilter::create();
ColorMultTextureFilter->attachSource(GrayscaleTextureFilter,0,0);
ColorMultTextureFilter->setFragmentSource(ColorMultFragProg);
////Create a Blur filter
//std::string BlurFragProg = "";
//BlurFragProg +=
//"uniform sampler2D Slot0Texture;"
//"void main()"
//"{"
//" vec2 offsets[9];"
//" offsets[0] = vec2(-0.000625,0.00111111111);"
//" offsets[1] = vec2(0.0,0.00111111111);"
//" offsets[2] = vec2(0.000625,0.00111111111);"
//" offsets[3] = vec2(-0.000625,0.0);"
//" offsets[4] = vec2(0.0,0.0);"
//" offsets[5] = vec2(0.0,0.0);"
//" offsets[6] = vec2(-0.000625,-0.00111111111);"
//" offsets[7] = vec2(0.0,-0.00111111111);"
//" offsets[8] = vec2(0.000625,-0.00111111111);"
//" vec4 kernel[9];"
////" kernel[0] = vec4(0.0);"
////" kernel[1] = vec4(0.0);"
////" kernel[2] = vec4(0.0);"
////" kernel[3] = vec4(0.0);"
////" kernel[4] = vec4(1.0);"
////" kernel[5] = vec4(0.0);"
////" kernel[6] = vec4(0.0);"
//.........这里部分代码省略.........