本文整理汇总了C++中RenderInfo类的典型用法代码示例。如果您正苦于以下问题:C++ RenderInfo类的具体用法?C++ RenderInfo怎么用?C++ RenderInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compileGLObjects
void Drawable::compileGLObjects(RenderInfo& renderInfo) const
{
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
if (!renderInfo.getState()->useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects) && _useDisplayList)
{
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
unsigned int contextID = renderInfo.getContextID();
// get the globj for the current contextID.
GLuint& globj = _globjList[contextID];
// call the globj if already set otherwise compile and execute.
if( globj != 0 )
{
glDeleteLists( globj, 1 );
}
globj = generateDisplayList(contextID, getGLObjectSizeHint());
glNewList( globj, GL_COMPILE );
drawInner(renderInfo);
glEndList();
}
#endif
}
示例2: render
void NullModel::render(const RenderInfo& info) const {
if (info.checkFlag(RENDER_TEXTURE_2D))
{
aabb_draw_solid(_aabbLocal, info.getFlags());
}
else
{
aabb_draw_wire(_aabbLocal);
}
}
示例3: glDeleteLists
void Drawable::compileGLObjects(RenderInfo& renderInfo) const
{
if (!_useDisplayList) return;
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
unsigned int contextID = renderInfo.getContextID();
// get the globj for the current contextID.
GLuint& globj = _globjList[contextID];
// call the globj if already set otherwise compile and execute.
if( globj != 0 )
{
glDeleteLists( globj, 1 );
}
globj = generateDisplayList(contextID, getGLObjectSizeHint());
glNewList( globj, GL_COMPILE );
if (_drawCallback.valid())
_drawCallback->drawImplementation(renderInfo,this);
else
drawImplementation(renderInfo);
glEndList();
#else
OSG_NOTICE<<"Warning: Drawable::compileGLObjects(RenderInfo&) - not supported."<<std::endl;
#endif
}
示例4: render
void RenderablePatchFixedWireframe::render(const RenderInfo& info) const
{
if (_tess.vertices.empty() || _tess.indices.empty()) return;
// No colour changing
glDisableClientState(GL_COLOR_ARRAY);
if (info.checkFlag(RENDER_VERTEX_COLOUR))
{
glColor3f(1, 1, 1);
}
if (_needsUpdate)
{
_needsUpdate = false;
// Create a VBO and add the vertex data
VertexBuffer_T currentVBuf;
currentVBuf.addVertices(_tess.vertices.begin(), _tess.vertices.end());
// Submit index batches
const RenderIndex* strip_indices = &_tess.indices.front();
for (std::size_t i = 0;
i < _tess.m_numStrips;
i++, strip_indices += _tess.m_lenStrips)
{
currentVBuf.addIndexBatch(strip_indices, _tess.m_lenStrips);
}
// Render all index batches
_vertexBuf.replaceData(currentVBuf);
}
_vertexBuf.renderAllBatches(GL_QUAD_STRIP);
}
示例5: render
// Back-end render function
void RenderablePicoSurface::render(const RenderInfo& info) const
{
// Invoke appropriate display list
if (info.checkFlag(RENDER_PROGRAM))
{
if (info.checkFlag(RENDER_VERTEX_COLOUR))
{
glCallList(_dlProgramVcol);
}
else
{
glCallList(_dlProgramNoVCol);
}
}
else
{
glCallList(_dlRegular);
}
}
示例6: draw
//// Drawable functions ////
void DMesh::draw( RenderInfo& r) {
glPushMatrix();
glMultMatrixf(m_transform);
// Material
r.material( Drawable::m_material );
r.state( 1 + (getNormalPointer()? 2:0) + (getTexCoordPointer()?4:0) );
glVertexPointer(3, GL_FLOAT, getStride(), getVertexPointer());
glNormalPointer( GL_FLOAT, getStride(), getNormalPointer());
glTexCoordPointer(2, GL_FLOAT, getStride(), getTexCoordPointer());
// Tangents?
if(getTangentPointer() && base::Shader::current().ready()) {
base::Shader::current().AttributePointer("tangent", 3, GL_FLOAT, 0, getStride(), getTangentPointer());
}
// Draw it
if(hasIndices()) glDrawElements( getMode(), getSize(), GL_UNSIGNED_SHORT, getIndexPointer());
else glDrawArrays( getMode(), 0, getSize());
glPopMatrix();
}
示例7:
// Back-end render
void MD5Surface::render(const RenderInfo& info) const
{
if (info.checkFlag(RENDER_BUMP))
{
glCallList(_lightingList);
}
else
{
glCallList(_normalList);
}
}
示例8: draw
void Drawable::draw(RenderInfo& renderInfo) const
{
State& state = *renderInfo.getState();
bool useVertexArrayObject = state.useVertexArrayObject(_useVertexArrayObject);
if (useVertexArrayObject)
{
unsigned int contextID = renderInfo.getContextID();
VertexArrayState* vas = _vertexArrayStateList[contextID].get();
if (!vas)
{
_vertexArrayStateList[contextID] = vas = createVertexArrayState(renderInfo, true);
// OSG_NOTICE<<" Geometry::draw() "<<this<<", assigned _vertexArrayStateList[renderInfo.getContextID()]="<<_vertexArrayStateList[renderInfo.getContextID()].get()<<", vas="<<vas<< std::endl;
}
else
{
// vas->setRequiresSetArrays(getDataVariance()==osg::Object::DYNAMIC);
// OSG_NOTICE<<" Geometry::draw() "<<this<<", reusing _vertexArrayStateList[renderInfo.getContextID()]="<<_vertexArrayStateList[renderInfo.getContextID()].get()<<", vas="<<vas<< std::endl;
}
State::SetCurrentVertexArrayStateProxy setVASProxy(state, vas);
vas->bindVertexArrayObject();
drawInner(renderInfo);
vas->setRequiresSetArrays(getDataVariance()==osg::Object::DYNAMIC);
return;
}
// TODO, add check against whether VAO is active and supported
if (state.getCurrentVertexArrayState()) state.getCurrentVertexArrayState()->bindVertexArrayObject();
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
if (!state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects) && _useDisplayList)
{
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
unsigned int contextID = renderInfo.getContextID();
// get the globj for the current contextID.
GLuint& globj = _globjList[contextID];
if( globj == 0 )
{
// compile the display list
globj = generateDisplayList(contextID, getGLObjectSizeHint());
glNewList( globj, GL_COMPILE );
drawInner(renderInfo);
glEndList();
}
// call the display list
glCallList( globj);
}
else
#endif
{
// if state.previousVertexArrayState() is different than currentVertexArrayState bind current
// OSG_NOTICE<<"Fallback drawInner()........................"<<std::endl;
drawInner(renderInfo);
}
}
示例9: render
void Model::render(const RenderInfo& info) {
if (info.renderMode() == RenderInfo::SHADOW) {
if (!shadow_cast_) {
return;
}
current_shader_ = simple_shader_;
} else {
current_shader_ = model_shader_;
}
auto& meshes = mesh_->meshes();
auto& info_matrix = info.transform();
for (int i = 0; i < meshes.size(); ++i) {
auto& mesh = meshes.at(i);
cross::RenderSystem::resetBufferBind();
mesh->bind();
// 親の姿勢行列にメッシュの姿勢行列を掛けて最終的な行列を作成
Mtx44 transform = info_matrix * mesh->matrix();
current_shader_->use();
current_shader_->setUniform(SHADER_UNIF_PMV, transform);
current_shader_->setUniform(SHADER_UNIF_SAMPLER, 0);
current_shader_->setUniform(SHADER_UNIF_SHADOW_SAMPLER, 1);
bool draw_flag = info.renderMode() == RenderInfo::SHADOW ? false : true;
// シェーダに描画フラグ設定
current_shader_->setUniform("draw_flag", draw_flag);
current_shader_->setUniform("draw_shadow", shadow_receive_);
// 影用行列生成
Mtx44 shadow_bias;
Mtx44::makeShadowBias(shadow_bias);
Mtx44 shadow_mtx;
shadow_mtx = shadow_bias * info.projMatrix()* info.lightMatrix();
current_shader_->setUniform(SHADER_UNIF_SHADOW_MTX, shadow_mtx);
// 頂点設定
current_shader_->bindAttributeLocation(0, SHADER_ATTR_POSITION);
// 法線設定
current_shader_->bindAttributeLocation(1, SHADER_ATTR_NORMAL);
// UV設定
current_shader_->bindAttributeLocation(2, SHADER_ATTR_UV);
// 出力カラー設定
current_shader_->bindFragmentDataLocation(0, SHADER_OUT_COLOR);
auto& material = mesh->material();
if (material) {
// マテリアルを持っているので設定
auto& model_texture = material->diffuseMap();
// テクスチャを設定
if (model_texture) {
cross::RenderSystem::setActiveTextureUnit(
cross::RenderSystem::TextureUnit::UNIT0
);
model_texture->bind();
current_shader_->setUniform(SHADER_UNIF_USE_TEXTURE_FLAG, true);
} else {
current_shader_->setUniform(SHADER_UNIF_USE_TEXTURE_FLAG, false);
}
// カラー設定
const auto& diffuse = material->diffuse();
current_shader_->setUniform(SHADER_UNIF_COLOR_DIFFUSE, diffuse.redFloat(), diffuse.greenFloat(), diffuse.blueFloat(), diffuse.alphaFloat());
}
cross::RenderSystem::setActiveTextureUnit(
cross::RenderSystem::TextureUnit::UNIT1
);
auto& shadow_texture = info.shadowTexture();
if (shadow_texture) {
shadow_texture->bind();
}
cross::RenderSystem::setCullingMode(culling_mode_);
cross::RenderSystem::drawElements(
cross::RenderSystem::DrawMode::MODE_TRIANGLES,
mesh->indexCount(),
sizeof(uint32_t)
);
mesh->unbind();
}
}
示例10: drawImplementation
void ComputeDispatch::drawImplementation(RenderInfo& renderInfo) const
{
renderInfo.getState()->get<GLExtensions>()->glDispatchCompute(_numGroupsX, _numGroupsY, _numGroupsZ);
}
示例11: render
void Winding::render(const RenderInfo& info) const
{
// Do not render if there are no points
if (empty())
{
return;
}
// Our vertex colours are always white, if requested
glDisableClientState(GL_COLOR_ARRAY);
if (info.checkFlag(RENDER_VERTEX_COLOUR))
{
glColor3f(1, 1, 1);
}
// A shortcut pointer to the first array element to avoid
// massive calls to std::vector<>::begin()
const WindingVertex& firstElement = front();
// Set the vertex pointer first
glVertexPointer(3, GL_DOUBLE, sizeof(WindingVertex), &firstElement.vertex);
// Check render flags. Multiple flags may be set, so the order matters.
if (info.checkFlag(RENDER_TEXTURE_CUBEMAP))
{
// In cube-map mode, we submit the vertex coordinate as the texture
// coordinate. The RenderSystem will set the appropriate texture matrix
// etc.
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(
3, GL_DOUBLE, sizeof(WindingVertex), &firstElement.vertex
);
}
else if (info.checkFlag(RENDER_BUMP))
{
// Lighting mode, submit normals, tangents and texcoords to the shader
// program.
glVertexAttribPointer(
ATTR_NORMAL, 3, GL_DOUBLE, 0, sizeof(WindingVertex), &firstElement.normal
);
glVertexAttribPointer(
ATTR_TEXCOORD, 2, GL_DOUBLE, 0, sizeof(WindingVertex), &firstElement.texcoord
);
glVertexAttribPointer(
ATTR_TANGENT, 3, GL_DOUBLE, 0, sizeof(WindingVertex), &firstElement.tangent
);
glVertexAttribPointer(
ATTR_BITANGENT, 3, GL_DOUBLE, 0, sizeof(WindingVertex), &firstElement.bitangent
);
}
else
{
// Submit normals in lighting mode
if (info.checkFlag(RENDER_LIGHTING))
{
glNormalPointer(GL_DOUBLE, sizeof(WindingVertex), &firstElement.normal);
}
// Set texture coordinates in 2D texture mode
if (info.checkFlag(RENDER_TEXTURE_2D))
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(
2, GL_DOUBLE, sizeof(WindingVertex), &firstElement.texcoord
);
}
}
// Submit all data to OpenGL
glDrawArrays(GL_POLYGON, 0, GLsizei(size()));
}
示例12: drawImplementation
void PanoDrawable::drawImplementation(RenderInfo& ri) const
{
if(ComController::instance()->isMaster() && !_renderOnMaster)
{
return;
}
int context = ri.getContextID();
_initLock.lock();
if(badinit)
{
if(_doDelete)
{
if(_contextinit[ri.getContextID()] > 0)
{
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
if(_contextinit[ri.getContextID()] & RIGHT)
{
glDeleteTextures(1, rtextures[context][i][j]);
delete rtextures[context][i][j];
}
if(_contextinit[ri.getContextID()] & LEFT)
{
glDeleteTextures(1, ltextures[context][i][j]);
delete ltextures[context][i][j];
}
}
}
_contextinit[ri.getContextID()] = -1;
}
bool tempb = true;
for(map<int, int>::iterator it = _contextinit.begin(); it != _contextinit.end(); it++)
{
if(it->second > 0)
{
tempb = false;
}
}
_deleteDone = tempb;
}
_initLock.unlock();
return;
}
/*string host;
int vx, vy, context;
context = ri.getContextID();
vx = (int)ri.getCurrentCamera()->getViewport()->x();
vy = (int)ri.getCurrentCamera()->getViewport()->y();
char hostname[51];
gethostname(hostname, 50);
host = hostname;*/
int eye = 0;
if(!getNumParents())
{
_initLock.unlock();
return;
}
osg::Node::NodeMask nm = getParent(0)->getNodeMask();
//std::cerr << "Node Mask: " << nm << std::endl;
if((nm & CULL_MASK) || (nm & CULL_MASK_LEFT) )
{
//std::cerr << "LEFT" << std::endl;
if(ScreenBase::getEyeSeparation() >= 0.0)
{
eye = LEFT;
}
else
{
eye = RIGHT;
}
}
else
{
//std::cerr << "RIGHT" << std::endl;
if(ScreenBase::getEyeSeparation() >= 0.0)
{
eye = RIGHT;
}
else
{
eye = LEFT;
}
}
if(_contextinit[ri.getContextID()] >= 0)
{
if(!(_contextinit[ri.getContextID()] & eye))
{
_initLock.unlock();
//.........这里部分代码省略.........
示例13: printf
bool BufferInfo::AddMesh(Mesh * mesh, GLenum drawType,VertexFormats vertFormat)
{
if (m_isFull) return false;
//int id = m_id;
if (mesh == nullptr)
{
printf("Mesh is nullptr\n");
return false;
}
GLsizei totalIndexSizeBytes = mesh->GetIndexSizeInBytes();
GLsizei numIndices = mesh->GetNumIndices();
GLsizei numVerts = mesh->GetNumVerts();
GLsizei totalVertSizeBytes = mesh->GetVertSizeInBytes();
GLsizei indexOffsetBytes = 0;
GLsizei vertOffset = 0;
GLsizei vertByteOffset = 0;
RenderInfo * meshRenderInfo = mesh->GetRenderInfo();
if (m_sizeOfVerts + totalVertSizeBytes > m_vertexBufferSize || m_sizeOfIndices + totalIndexSizeBytes > m_vertexBufferSize) {
if (m_hasData)
{
m_isFull = true;
return false;
}
else
{
totalVertSizeBytes = m_vertexBufferSize = totalVertSizeBytes;
totalIndexSizeBytes = m_indexBufferSize = totalIndexSizeBytes;
m_isFull = true;
}
}
if (!m_hasData)
{
CreateBuffers();
}
//glBindBuffer(GL_ARRAY_BUFFER, m_vertBufferID);
//glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferID);
//printf("\n\n\n\n\n\n\nAddMesh: INDEX SIZE ENUM Retrieved: %d\n\n\n\n\n\n", mesh->m_renderInfo.m_isb);
if (m_headRenderInfoPtr == nullptr)
{
m_headRenderInfoPtr = &mesh->m_renderInfo;
indexOffsetBytes = 0;
vertOffset = 0;
meshRenderInfo->m_vertOffset = 0;
meshRenderInfo->SetRenderInfo(m_vertBufferID, m_indexBufferID, totalIndexSizeBytes, indexOffsetBytes, numIndices, numVerts, vertOffset, true, nullptr, drawType, vertFormat);
m_tailRenderInfoPtr = meshRenderInfo;
}
else
{
//meshRenderInfo = mesh->GetRenderInfo();
GetCurrentOffsets(&indexOffsetBytes, &vertOffset);
meshRenderInfo->m_vertOffset = vertOffset;
meshRenderInfo->SetRenderInfo(m_vertBufferID, m_indexBufferID, totalIndexSizeBytes, indexOffsetBytes, numIndices, numVerts, vertOffset,true,nullptr, drawType,vertFormat);
//meshRenderInfo->SetIndexSizeEnum(mesh->GetIndexSizeEnum());
m_headRenderInfoPtr->SetNextRenderInfoPtr(m_tailRenderInfoPtr);
m_tailRenderInfoPtr = meshRenderInfo;
}
//----------------------IMPORTANT?-----------------------------
meshRenderInfo->SetIndexSizeEnum(mesh->GetIndexSizeEnum());
//-------------------------------------------------------------
meshRenderInfo->m_vertBufferID = m_vertBufferID;
meshRenderInfo->m_indBufferID = m_indexBufferID;
vertByteOffset = vertOffset * mesh->GetStride();
if (mesh->m_renderInfo.m_stride == 0)mesh->m_renderInfo.m_stride = mesh->GetStride();
//mesh->m_renderInfo.m_draw_mode = drawType;
//mesh->m_renderInfo.m_vertexFormat = vertFormat;
//mesh->m_renderInfo.m_vertexFormat =
InsertVertexSubBuffer(m_vertBufferID, mesh, vertByteOffset);
if (mesh->m_renderInfo.m_indexed)
{
InsertIndexSubBuffer(m_indexBufferID, mesh, indexOffsetBytes);
}
//InsertIndexSubBuffer
//GLsizei indexSize, GLsizei indexOffsetBytes, GLsizei numIndices, GLsizei numVerts, bool enabled = true, RenderInfo * nextPtr = nullpt
//Log stats
GameLogger::Log(LogMsgType::cInfo, "--------BufferInfo::AddMesh() Added mesh successfully-------");
//.........这里部分代码省略.........
示例14: Create
//-------------------------------------------------------
RenderCapabilitiesUPtr RenderCapabilities::Create(const RenderInfo& renderInfo) noexcept
{
return RenderCapabilitiesUPtr(new RenderCapabilities(renderInfo.IsShadowMappingSupported(), renderInfo.IsDepthTextureSupported(), renderInfo.IsMapBufferSupported(),
renderInfo.IsHighPrecisionFloatsSupported(), renderInfo.GetMaxTextureSize(), renderInfo.GetNumTextureUnits()));
}
示例15: drawImplementation
void coVolumeDrawable::drawImplementation(RenderInfo &renderInfo) const
{
vvDebugMsg::msg(3, "coVolumeDrawable::drawImplementation()");
const unsigned ctx = renderInfo.getState()->getContextID();
while (ctx >= contextState.size())
{
// this will delete the old renderer contextState.resize(ctx+1);
ContextState *nc = new ContextState;
contextState.push_back(nc);
}
vvRenderer *&renderer = contextState[ctx]->renderer;
if (vd && !renderer)
{
// Debug level value may be either [NO_MESSAGES|FEW_MESSAGES|MOST_MESSAGES|ALL_MESSAGES]
// Or, in the same order and meaning the same as the string equivalents [0|1|2|3]
bool debugLevelExists = false;
const int debugLevelInt = covise::coCoviseConfig::getInt("COVER.Plugin.Volume.DebugLevel", 0, &debugLevelExists);
if (debugLevelExists)
{
if ((debugLevelInt >= 0) && (debugLevelInt <= 9))
{
vvDebugMsg::setDebugLevel(debugLevelInt);
}
else
{
// In that case, the debug level was specified as a string literal
std::string debugLevelStr = covise::coCoviseConfig::getEntry("COVER.Plugin.Volume.DebugLevel");
if (!debugLevelStr.empty())
{
if (strcasecmp(debugLevelStr.c_str(), "NO_MESSAGES") == 0)
{
vvDebugMsg::setDebugLevel(vvDebugMsg::NO_MESSAGES);
}
else if (strcasecmp(debugLevelStr.c_str(), "FEW_MESSAGES") == 0)
{
vvDebugMsg::setDebugLevel(vvDebugMsg::FEW_MESSAGES);
}
else if (strcasecmp(debugLevelStr.c_str(), "MOST_MESSAGES") == 0)
{
vvDebugMsg::setDebugLevel(vvDebugMsg::MOST_MESSAGES);
}
else if (strcasecmp(debugLevelStr.c_str(), "ALL_MESSAGES") == 0)
{
vvDebugMsg::setDebugLevel(vvDebugMsg::ALL_MESSAGES);
}
}
}
}
bool imageScalingExists = false;
const bool useOffscreenBuffer = covise::coCoviseConfig::isOn("imageScaling", "COVER.Plugin.Volume.Renderer", false, &imageScalingExists);
bool numGPUSlavesExists = false;
const char **displayNames = NULL;
virvo::BufferPrecision multiGpuPrecision = virvo::Short;
const int numGPUSlaves = covise::coCoviseConfig::getInt("COVER.Plugin.Volume.MultiGPU.NumSlaves", -1, &numGPUSlavesExists);
std::vector<const char *> hostnames;
std::vector<int> ports;
std::vector<const char *> alternativeFilenames;
const bool useMultiGPU = numGPUSlavesExists;
if (useMultiGPU)
{
// Buffer precision for multi gpu rendering slaves.
// As with debug level. May either be [BYTE|SHORT|FLOAT]
// or equivalently [8|16|32]
bool bufferPrecisionExists;
const int precisionInt = covise::coCoviseConfig::getInt("COVER.Plugin.Volume.MultiGPU.BufferPrecision", 16, &bufferPrecisionExists);
if (bufferPrecisionExists)
{
if ((precisionInt == 8) || (precisionInt == 16) || (precisionInt == 32))
{
if (precisionInt == 8)
multiGpuPrecision = virvo::Byte;
else if (precisionInt == 16)
multiGpuPrecision = virvo::Short;
else
multiGpuPrecision = virvo::Float;
}
else
{
// In that case, the buffer precision was specified as a string literal
std::string precisionStr = covise::coCoviseConfig::getEntry("COVER.Plugin.Volume.MultiGPU.BufferPrecision");
if (strcasecmp(precisionStr.c_str(), "BYTE") == 0)
{
multiGpuPrecision = virvo::Byte;
}
else if (strcasecmp(precisionStr.c_str(), "SHORT") == 0)
{
multiGpuPrecision = virvo::Short;
}
else if (strcasecmp(precisionStr.c_str(), "FLOAT") == 0)
{
multiGpuPrecision = virvo::Float;
}
}
//.........这里部分代码省略.........