本文整理汇总了C++中RenderContext类的典型用法代码示例。如果您正苦于以下问题:C++ RenderContext类的具体用法?C++ RenderContext怎么用?C++ RenderContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gatherLinksLocal
// only find local links
void EntityLinkDecorator::gatherLinksLocal(Vec4f::List& vList, RenderContext& context, Model::Entity& curEnt) {
if (!context.filter().entityVisible(curEnt))
return;
Model::EntityList::const_iterator it, end;
const Model::EntityList& targetList = curEnt.linkTargets();
for (it = targetList.begin(), end = targetList.end(); it != end; ++it) {
const Model::Entity& targetEnt = **it;
if (!context.filter().entityVisible(targetEnt))
continue;
addArrowVerts(vList, curEnt.center(), targetEnt.center());
}
const Model::EntityList& sourceList = curEnt.linkSources();
for (it = sourceList.begin(), end = sourceList.end(); it != end; ++it) {
const Model::Entity& sourceEnt = **it;
if (!context.filter().entityVisible(sourceEnt))
continue;
addArrowVerts(vList, sourceEnt.center(), curEnt.center());
}
}
示例2: render
void DefaultPointHandleRenderer::render(Vbo& vbo, RenderContext& context) {
const Vec4f::List& positionList = positions();
if (positionList.empty())
return;
SetVboState activateVbo(vbo, Vbo::VboActive);
if (m_vertexArray == NULL) {
Vec3f::List vertices = sphere();
unsigned int vertexCount = static_cast<unsigned int>(vertices.size());
m_vertexArray = new VertexArray(vbo, GL_TRIANGLES, vertexCount,
Attribute::position3f());
SetVboState mapVbo(vbo, Vbo::VboMapped);
Vec3f::List::const_iterator vIt, vEnd;
for (vIt = vertices.begin(), vEnd = vertices.end(); vIt != vEnd; ++vIt) {
const Vec3f& vertex = *vIt;
m_vertexArray->addAttribute(vertex);
}
}
Renderer::ActivateShader shader(context.shaderManager(), Renderer::Shaders::PointHandleShader);
shader.currentShader().setUniformVariable("Color", color());
shader.currentShader().setUniformVariable("CameraPosition", context.camera().position());
shader.currentShader().setUniformVariable("ScalingFactor", scalingFactor());
shader.currentShader().setUniformVariable("MaximumDistance", maximumDistance());
Vec4f::List::const_iterator pIt, pEnd;
for (pIt = positionList.begin(), pEnd = positionList.end(); pIt != pEnd; ++pIt) {
const Vec4f& position = *pIt;
shader.currentShader().setUniformVariable("Position", position);
m_vertexArray->render();
}
}
示例3: l
void Video::renderImpl(RenderContext& ctxt) const
{
Mutex::Lock l(mutex);
if(skipRender())
return;
//Video is especially optimized for GL rendering
//It needs special treatment for SOFTWARE contextes
if(ctxt.contextType != RenderContext::GL)
{
LOG(LOG_NOT_IMPLEMENTED, "Video::renderImpl on SOFTWARE context is not yet supported");
return;
}
if(!netStream.isNull() && netStream->lockIfReady())
{
//All operations here should be non blocking
//Get size
videoWidth=netStream->getVideoWidth();
videoHeight=netStream->getVideoHeight();
const MATRIX totalMatrix=getConcatenatedMatrix();
float m[16];
totalMatrix.get4DMatrix(m);
ctxt.lsglLoadMatrixf(m);
//Enable YUV to RGB conversion
//width and height will not change now (the Video mutex is acquired)
ctxt.renderTextured(netStream->getTexture(), 0, 0, width, height,
clippedAlpha(), RenderContext::YUV_MODE);
netStream->unlock();
}
}
示例4: renderModels
void EntityRenderer::renderModels(RenderContext& context) {
if (m_modelRenderers.empty())
return;
Preferences::PreferenceManager& prefs = Preferences::PreferenceManager::preferences();
EntityModelRendererManager& modelRendererManager = m_document.sharedResources().modelRendererManager();
ShaderManager& shaderManager = m_document.sharedResources().shaderManager();
ShaderProgram& entityModelProgram = shaderManager.shaderProgram(Shaders::EntityModelShader);
if (entityModelProgram.activate()) {
modelRendererManager.activate();
entityModelProgram.setUniformVariable("Brightness", prefs.getFloat(Preferences::RendererBrightness));
entityModelProgram.setUniformVariable("ApplyTinting", m_applyTinting);
entityModelProgram.setUniformVariable("TintColor", m_tintColor);
entityModelProgram.setUniformVariable("GrayScale", m_grayscale);
EntityModelRenderers::iterator it, end;
for (it = m_modelRenderers.begin(), end = m_modelRenderers.end(); it != end; ++it) {
Model::Entity* entity = it->first;
if (context.filter().entityVisible(*entity)) {
EntityModelRenderer* renderer = it->second.renderer;
renderer->render(entityModelProgram, context.transformation(), *entity);
}
}
modelRendererManager.deactivate();
entityModelProgram.deactivate();
}
}
示例5: onRenderItem
void WindowTree::onRenderItem( RenderContext & context, const RectInt & window, PointInt & pos, Item * pItem )
{
WindowStyle * pStyle = windowStyle();
ASSERT( pStyle );
Font * pFont = windowStyle()->font();
ASSERT( pFont );
// get the depth of this item
int depth = itemDepth( pItem );
// determine the X position based on it's depth
pos.x = window.left + (depth * m_Indent);
// get the size of the label text
SizeInt labelSize( pFont->size( pItem->sLabel ) );
// determine the height of this item
int height = (int)(labelSize.height + TREE_ITEM_BUFFER);
RectInt itemRect( window.left, pos.y, window.right, pos.y + height );
// check if this item is highlighted or not
if ( m_CursorInWindow && itemRect.inRect( m_LastCursorPosition ) )
onHighlight( pItem );
PrimitiveMaterial::push( context.display(), WHITE, PrimitiveMaterial::ALPHA );
if ( pItem->dwFlags & BUTTON )
{
bool expanded = (pItem->dwFlags & EXPANDED) != 0;
Color backColor( expanded ? pStyle->backColor() * TREE_SHADE_COLOR : pStyle->backColor() );
Color shadeColor( expanded ? pStyle->borderColor() * TREE_LIGHT_COLOR : pStyle->borderColor() * TREE_SHADE_COLOR );
Color lightColor( expanded ? pStyle->borderColor() * TREE_SHADE_COLOR : pStyle->borderColor() * TREE_LIGHT_COLOR );
// render the button
pushBackground( context, itemRect, backColor, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER );
pushBorder( context, itemRect, lightColor, shadeColor, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER );
// draw glow around this object if the mouse is currently over this button
if ( m_pCursorOver == pItem )
pushGlow( context, itemRect, TREE_GLOW_SIZE, TREE_GLOW_INNER, TREE_GLOW_OUTER, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER );
// place the label in the center of the button
PointInt labelPos( itemRect.center() - PointInt( labelSize.width / 2, labelSize.height / 2 ) );
// draw the label
Font::push( context.display(), pFont, labelPos, pItem->sLabel, pItem->cColor );
}
else
{
if ( m_pSelected == pItem )
pushBackground( context, itemRect, pStyle->highColor(), 0, 0 );
if ( m_pCursorOver == pItem )
pushGlow( context, itemRect, TREE_GLOW_SIZE, TREE_GLOW_INNER, TREE_GLOW_OUTER, 0, 0 );
PointInt labelPos( pos.x, (int)(pos.y + (TREE_ITEM_BUFFER / 2)) );
// render the label text`
Font::push( context.display(), pFont, labelPos, pItem->sLabel, pItem->cColor );
}
// move y down
pos.y += (int)(height + WINDOW_TREE_SPACING);
}
示例6: onRender
void ButtonBuildStructure::onRender( RenderContext & context, const RectInt & window )
{
WindowButton::onRender( context, window );
if ( enabled() && m_Build.valid() )
{
DisplayDevice * pDisplay = context.display();
ASSERT( pDisplay );
// draw the eta to build this structure
Font * pFont = windowStyle()->font();
if ( pFont != NULL )
{
WideString eta;
GameDocument * pDoc = (GameDocument *)document();
if ( pDoc != NULL )
{
NounShip::Ref pShip = pDoc->ship();
if ( pShip.valid() )
{
int buildTime = m_Build->buildTime()* pShip->calculateModifier(MT_BUILD_SPEED,true);
eta.format( "%d:%2.2d", buildTime / 60, buildTime % 60);
SizeInt etaSize( pFont->size( eta ) );
PointInt etaPos( window.right - etaSize.width, window.bottom - etaSize.height );
Font::push( context.display(), pFont, etaPos, eta, WHITE );
}
}
}
}
}
示例7: render
void ToggleButton::render(RenderContext& rc) const
{
rc.image(x(), y(), width(), height(), texture);
if (enabled)
rc.border(x(), y(), width(), height(), colour::WHITE);
}
示例8: renderItself
void TextNode::renderItself(RenderContext& renderContext)
{
NVGcontext& nanoVgContext = renderContext.getNanoVgContext();
nvgSave(&nanoVgContext);
setupContext(nanoVgContext);
Color finalColor = mFontColor.getBlendedColor(renderContext.getBlendColors());
nvgFillColor(&nanoVgContext, nvgRGBAf(finalColor.getRed(), finalColor.getGreen(),
finalColor.getBlue(), finalColor.getAlpha()));
for(const Text& text : mTexts)
{
const char* charArray = text.getString().getCharArray();
float positionX = text.getPosition().getX();
float positionY = text.getPosition().getY();
if(isPositive(text.getBoxWidth()))
{
nvgTextBox(&nanoVgContext, positionX, positionY, text.getBoxWidth(), charArray, nullptr);
}
else
{
nvgText(&nanoVgContext, positionX, positionY, charArray, nullptr);
}
}
nvgRestore(&nanoVgContext);
Node::renderItself(renderContext);
}
示例9: render
void ThrottleMeter::render(RenderContext& rc) const
{
IFontPtr font = rc.theme().font(font_name);
int ox = x(), oy = y();
rc.offset(ox, oy);
static const string LABEL = "Power: ";
font->print(ox, oy, colour::WHITE, LABEL);
glPushMatrix();
const int off = (height() - METER_HEIGHT) / 2;
glTranslatef(ox + static_cast<float>(font->text_width(LABEL)),
static_cast<float>(oy + off), 0.0f);
const int unit = METER_WIDTH / (max_value + 1);
// Neutral bit
glColor3f(1.0f, 1.0f, 0.0f);
glBegin(GL_QUADS);
glVertex2i(0, 0);
glVertex2i(0, METER_HEIGHT);
glVertex2i(unit, METER_HEIGHT);
glVertex2i(unit, 0);
glEnd();
int square_len = value_ >= max_value
? (max_value - 1) * unit
: (value_ > 0 ? unit * (value_ - 1) : 0);
glTranslatef(static_cast<float>(unit), 0.0f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f);
// Forwards bit
if (square_len > 0) {
glBegin(GL_QUADS);
glVertex2i(0, 0);
glVertex2i(0, METER_HEIGHT);
glVertex2i(square_len, METER_HEIGHT);
glVertex2i(square_len, 0);
glEnd();
}
const bool want_triangle = value_ < max_value && value_ > 0;
if (want_triangle) {
// Triangle bit
glBegin(GL_TRIANGLES);
glVertex2i(square_len, 0);
glVertex2i(square_len, METER_HEIGHT);
glVertex2i(square_len + unit, METER_HEIGHT / 2);
glEnd();
}
glPopMatrix();
}
示例10: renderBackground
void Compass::renderBackground(RenderContext& renderContext) {
PreferenceManager& prefs = PreferenceManager::instance();
const MultiplyModelMatrix rotate(renderContext.transformation(), Mat4x4f::Rot90XCCW);
ActiveShader shader(renderContext.shaderManager(), Shaders::CompassBackgroundShader);
shader.set("Color", prefs.get(Preferences::CompassBackgroundColor));
m_backgroundRenderer.render();
shader.set("Color", prefs.get(Preferences::CompassBackgroundOutlineColor));
m_backgroundOutlineRenderer.render();
}
示例11: Draw
void SkyRenderer::Draw(RenderContext& renderContext,
const SceneConstants& sceneConstants)
{
ID3D11DeviceContext& context = m_graphicsDevice.GetD3DContext();
//
// Update the constant buffer.
//
m_constants.viewMatrix = sceneConstants.viewMatrix;
m_constants.projectionMatrix = sceneConstants.projectionMatrix;
D3D11_MAPPED_SUBRESOURCE map;
D3DCHECK(m_graphicsDevice.GetD3DContext().Map(m_constantBuffer.get(), // pResource
0, // Subresource
D3D11_MAP_WRITE_DISCARD, // MapType
0, // MapFlags
&map)); // pMappedResource
memcpy(map.pData, &m_constants, sizeof(m_constants));
m_graphicsDevice.GetD3DContext().Unmap(m_constantBuffer.get(), 0);
//
// Execute the render op.
//
ID3D11Buffer* vertexBufferPtr = m_shared->vertexBuffer.get();
size_t offset = 0,
stride = sizeof(Vertex);
ID3D11ShaderResourceView* shaderResourceViewPtrs[] =
{
m_shared->skyTextureView.get()
};
ID3D11SamplerState* samplerPtr = m_shared->samplerState.get();
context.IASetVertexBuffers(0, 1, &vertexBufferPtr, &stride, &offset);
context.IASetIndexBuffer(m_shared->indexBuffer.get(), DXGI_FORMAT_R16_UINT, 0);
context.IASetInputLayout(m_shared->inputLayout.get());
context.IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ID3D11Buffer* constantBufferPtr = m_constantBuffer.get();
context.VSSetConstantBuffers(0, 1, &constantBufferPtr);
context.VSSetShader(m_shared->vertexShader.get(), NULL, 0);
context.GSSetShader(NULL, NULL, 0);
context.PSSetShader(m_shared->pixelShader.get(), NULL, 0);
context.PSSetShaderResources(0, 1, shaderResourceViewPtrs);
context.PSSetSamplers(0, 1, &samplerPtr);
renderContext.PushRasterizerState(m_shared->rasterizerState);
renderContext.PushDepthStencilState(m_shared->depthStencilState);
context.DrawIndexed(36, 0, 0);
renderContext.PopRasterizerState();
renderContext.PopDepthStencilState();
}
示例12: render
void Force::render(RenderContext& context, const gameplay::Rectangle& rect)
{
context.activateLayer(m_tiler);
std::vector<Unit*>::iterator it = m_units.begin();
std::vector<Unit*>::iterator last = m_units.end();
for (; it != last; it++)
(*it)->render(context);
context.deactivateLayer();
}
示例13: onRender
void ButtonUnit::onRender( RenderContext & context, const RectInt & window )
{
WindowButton::onRender( context, window );
if ( enabled() && m_Unit.valid() )
{
GameDocument * pDoc = (GameDocument *)document();
ASSERT( pDoc );
NounShip * pShip = pDoc->ship();
if (! pShip )
return;
DisplayDevice * pDisplay = context.display();
ASSERT( pDisplay );
// draw the gadget icon
if ( m_Icon.valid() )
{
RectInt iconBox( PointInt( window.left, window.top ), SizeInt( 32, 16 ) );
RectFloat iconUV(0,0,1,1);
Material::push( context, m_Icon );
PrimitiveWindow::push( pDisplay, iconBox, iconUV,
pShip->isFriend( m_Unit ) ? GREEN : pShip->isEnemy( m_Unit ) ? RED : YELLOW );
}
// draw the unit health on the button
Font * pFont = windowStyle()->font();
ASSERT( pFont );
WideString sHealth;
sHealth.format( STR("%d%%"), 100 - ((m_Unit->damage() * 100) / m_Unit->maxDamage()) );
SizeInt szHealth( pFont->size( sHealth ) );
PointInt ptHealth( window.right - szHealth.width, window.bottom - szHealth.height );
Font::push( context.display(), pFont, ptHealth, sHealth, WHITE );
// display damage bar
if ( m_Unit->damage() > 0 )
{
float damage = 1.0f - (m_Unit->damage() / m_Unit->maxDamage());
RectInt bar( window.m_Left, window.m_Bottom + 1,
window.m_Right - (window.width() * (1.0f - damage)), window.m_Bottom + 3 );
RectFloat barUV(0,0,1,1);
Color barColor( 255 * (1.0f - damage), 255 * damage,0,255 );
PrimitiveMaterial::push( pDisplay, PrimitiveMaterial::NONE );
PrimitiveWindow::push( pDisplay, bar, barUV, barColor );
}
// display blinking border if this unit is the current target
if ( pDoc->target() == m_Unit && (pDoc->tick() % 10) < 6)
renderGlow( context );
}
}
示例14: createDevicePrimitives
void Material::createDevicePrimitives( RenderContext & context )
{
DisplayDevice * pDisplay = context.display();
ASSERT( pDisplay );
m_Material = NULL; // clear any previous primitive
pDisplay->create( m_Material );
if ( context.alpha() < 1.0f )
{
m_Material->setMaterial( Color( m_Diffuse.r, m_Diffuse.g, m_Diffuse.b, (u8)(context.alpha() * m_Diffuse.a) ),
m_Ambient, m_Emissive, m_Specular, m_SpecularPower );
m_Material->setPass( DisplayDevice::SECONDARY );
if ( m_Blending == PrimitiveMaterial::NONE )
m_Material->setBlending( PrimitiveMaterial::ALPHA );
else
m_Material->setBlending( m_Blending );
}
else
{
m_Material->setMaterial( m_Diffuse, m_Ambient, m_Emissive, m_Specular, m_SpecularPower );
m_Material->setPass( m_nPass );
m_Material->setBlending( m_Blending );
}
m_Material->setLightEnable( m_LightEnable );
m_Material->setDoubleSided( m_DoubleSided );
if ( m_sShader.length() > 0 )
m_Material->setShader( m_sShader );
if (! m_bSurfaceReady )
createDeviceSurfaces( context.display() );
// attach the surfaces to the material now
if ( m_Surfaces.size() > 0 )
{
Array< PrimitiveSurface::Ref > & surfaces = m_Surfaces[ 0 ];
ASSERT( surfaces.size() == m_Textures.size() );
for(int i=0;i<surfaces.size();++i)
{
Texture & texture = m_Textures[ i ];
m_Material->addSurface( surfaces[i],
texture.m_eType,
texture.m_nIndex,
texture.m_nUV,
texture.m_fParams );
}
}
m_nLastFrame = 0;
m_fLastAlpha = context.alpha();
}
示例15: initializeMaps
Ref<Material> Material::read(RenderContext& context, const std::string& name)
{
initializeMaps();
if (Material* cached = context.cache().find<Material>(name))
return cached;
const Path path = context.cache().findFile(name);
if (path.isEmpty())
{
logError("Failed to find material %s", name.c_str());
return nullptr;
}
pugi::xml_document document;
const pugi::xml_parse_result result = document.load_file(path.name().c_str());
if (!result)
{
logError("Failed to load material %s: %s",
name.c_str(),
result.description());
return nullptr;
}
pugi::xml_node root = document.child("material");
if (!root || root.attribute("version").as_uint() != MATERIAL_XML_VERSION)
{
logError("Material file format mismatch in %s", name.c_str());
return nullptr;
}
Ref<Material> material = Material::create(ResourceInfo(context.cache(), name, path), context);
for (auto pn : root.children("pass"))
{
const std::string phaseName(pn.attribute("phase").value());
if (!phaseMap.hasKey(phaseName))
{
logError("Invalid render phase %s in material %s",
phaseName.c_str(),
name.c_str());
return nullptr;
}
if (!parsePass(context, material->pass(phaseMap[phaseName]), pn))
{
logError("Failed to parse pass for material %s", name.c_str());
return nullptr;
}
}
return material;
}