本文整理汇总了C++中Color4f函数的典型用法代码示例。如果您正苦于以下问题:C++ Color4f函数的具体用法?C++ Color4f怎么用?C++ Color4f使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Color4f函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ManageFade
void ManageFade()
{
arxtime.update();
// TODO can this really become negative ?
long tim = long(arxtime.now_ul() - FADESTART);
if(tim <= 0)
return;
float Visibility = tim / (float)FADEDURATION;
if(FADEDIR > 0)
Visibility = 1.f - Visibility;
if(Visibility > 1.f)
Visibility = 1.f;
if(Visibility < 0.f) {
FADEDIR = 0;
return;
}
LAST_FADEVALUE=Visibility;
GRenderer->SetBlendFunc(BlendSrcAlpha, BlendInvSrcAlpha);
GRenderer->SetRenderState(Renderer::DepthWrite, false);
GRenderer->SetRenderState(Renderer::AlphaBlending, true);
Color color = Color4f(FADECOLOR, Visibility).to<u8>();
EERIEDrawBitmap(Rectf(g_size), 0.0001f, NULL, color);
GRenderer->SetRenderState(Renderer::AlphaBlending, false);
GRenderer->SetRenderState(Renderer::DepthWrite, true);
}
示例2: GL
void GL2HudRenderer::render() {
if (client->getStateId() != Client::StateId::PLAYING)
return;
const Character &character = client->getLocalCharacter();
if (!character.isValid())
return;
GL(Enable(GL_TEXTURE_2D));
vec2f texs[4];
GL2TextureManager::Entry tex_entry = renderer->getTextureManager()->get(client->getLocalCharacter().getBlock());
GL2TextureManager::getTextureCoords(tex_entry.index, tex_entry.type, texs);
GL(BindTexture(GL_TEXTURE_2D, tex_entry.tex));
GL(Color4f(1.0f, 1.0f, 1.0f, 1.0f));
GL(PushMatrix());
float d = (client->getGraphics()->getWidth() < client->getGraphics()->getHeight() ? client->getGraphics()->getWidth() : client->getGraphics()->getHeight()) * 0.05f;
GL(Translatef(-client->getGraphics()->getDrawWidth() * 0.48f, -client->getGraphics()->getDrawHeight() * 0.48f, 0));
glBegin(GL_QUADS);
glTexCoord2f(texs[0][0], texs[0][1]); glVertex2f(0, 0);
glTexCoord2f(texs[1][0], texs[1][1]); glVertex2f(d, 0);
glTexCoord2f(texs[2][0], texs[2][1]); glVertex2f(d, d);
glTexCoord2f(texs[3][0], texs[3][1]); glVertex2f(0, d);
glEnd();
LOG_OPENGL_ERROR;
GL(PopMatrix());
}
示例3: mousePressed
virtual void mousePressed(const MouseEventUnrecPtr e)
{
if(dynamic_cast<WindowEventProducer*>(e->getSource())->getKeyModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
{
mgr->mouseButtonPress(e->getButton(), e->getLocation().x(), e->getLocation().y());
}
else
{
Line TheRay;
if(e->getButton() == MouseEvent::BUTTON1)
{
mgr->getCamera()->calcViewRay(TheRay,e->getLocation().x(),e->getLocation().y(),*(mgr->getWindow()->getPort(0)));
std::cout<<"Velocity "<<TheRay.getDirection()<<std::endl;
}
RocketParticleSystem->addParticle(TheRay.getPosition(),
Vec3f(0.0,1.0f,0.0f),
Color4f(1.0,0.0,0.0,1.0),
Vec3f(1.0,1.0,1.0),
10,
Vec3f(TheRay.getDirection()*50), //Velocity
Vec3f(0.0f,0.0f,0.0f)
);
}
}
示例4: Color4f
//-----------------------------------------------------------------------------
void Particle::Update(long _lTime)
{
ulTime += _lTime;
iTexTime += _lTime;
fTimeSec = _lTime * ( 1.0f / 1000 );
if (ulTime < ulTTL)
{
float ft = fOneOnTTL * ulTime;
// backup old pos
p3OldPos.x = p3Pos.x;
p3OldPos.y = p3Pos.y;
p3OldPos.z = p3Pos.z;
// update new pos
p3Pos.x += p3Velocity.x * fTimeSec;
p3Pos.y += p3Velocity.y * fTimeSec;
p3Pos.z += p3Velocity.z * fTimeSec;
fSize = fSizeStart + (fSizeEnd - fSizeStart) * ft;
fColor[0] = fColorStart[0] + (fColorEnd[0] - fColorStart[0]) * ft;
fColor[1] = fColorStart[1] + (fColorEnd[1] - fColorStart[1]) * ft;
fColor[2] = fColorStart[2] + (fColorEnd[2] - fColorStart[2]) * ft;
fColor[3] = fColorStart[3] + (fColorEnd[3] - fColorStart[3]) * ft;
ulColor = Color4f(fColor[0], fColor[1], fColor[2], fColor[3]).to<u8>();
}
}
示例5: addChannel
bool SampleBase::onInit()
{
m_frameCount = 0;
m_fps = 0.0f;
addChannel( MSG_DEV );
if ( !WinFrame::create( "Sample Test" , g_ScreenWidth , g_ScreenHeight ,
SysMsgHandler::MsgProc , false ) )
return false;
if ( !CFly::initSystem() )
return false;
mWorld = WorldManager::getInstance().createWorld( getHWnd() , g_ScreenWidth , g_ScreenHeight , 32 , false );
CFly::PluginManager::getInstance().registerLinker( "CW3" , new Cw3FileLinker );
if ( !mWorld )
return false;
mWorld->setDir( DIR_OBJECT , SAMPLE_DATA_DIR );
mWorld->setDir( DIR_ACTOR , SAMPLE_DATA_DIR"/NPC" );
mWorld->setDir( DIR_TEXTURE, SAMPLE_DATA_DIR );
mWorld->setDir( DIR_SHADER , SAMPLE_DATA_DIR"/Shader" );
mMainViewport = mWorld->createViewport( 0 , 0 , g_ScreenWidth , g_ScreenHeight );
mMainScene = mWorld->createScene( 1 );
mMainScene->setAmbientLight( Color4f(1,1,1) );
mMainCamera = mMainScene->createCamera();
mMainCamera->setAspect( float( g_ScreenWidth ) / g_ScreenHeight );
mMainCamera->setNear(5.0f);
mMainCamera->setFar(100000.0f);
return onSetupSample();
}
示例6: Renderer
Panzerfaust::Panzerfaust()
{
m_renderer = Renderer();
//debugUnitTest(m_elements);
m_internalTime = 0.f;
m_isQuitting = m_renderer.m_fatalError;
m_console.m_log = ConsoleLog();
//m_world = World();
m_worldCamera = Camera();
m_displayConsole = false;
//HACK test values
m_console.m_log.appendLine("This is a test of the emergency broadcast system");
m_console.m_log.appendLine("Do not be alarmed or concerned");
m_console.m_log.appendLine("This is only a test");
UnitTestXMLParser(".\\Data\\UnitTest.xml");
unitTestEventSystem();
//g_serverConnection = new Connection("129.119.246.221", "5000");
g_serverConnection = new Connection("127.0.0.1", "8080");
g_localUser = User();
g_localUser.m_unit = Entity();
g_localUser.m_unit.m_color = Color4f(0.2f, 1.0f, 0.2f, 1.f);
g_localUser.m_userType = USER_LOCAL;
g_localUser.m_unit.m_position = Vector2f(0,0);
CommandParser::RegisterCommand("connect", ChangeServer);
CommandParser::RegisterCommand("color", ChangeColor);
}
示例7: onSetupSample
bool onSetupSample()
{
createCoorditeAxis( 120 );
mMainCamera->setLookAt( Vector3( 0,0,150 ) , Vector3(0,0,0), Vector3(0,1,0) );
Vertex vtx[4] =
{
{ 0 , 0 , 0 , 0 , 0 , 1 } ,
{ 100 , 0 , 0 , 1 , 0 , 0 } ,
{ 100 , 100 , 0 , 1 , 1 , 1 } ,
{ 0 , 100 , 0 , 0 , 1 , 0 } ,
};
int idx[6] =
{
0 , 1 , 2 ,
0 , 2 , 3 ,
};
Material* mat = mWorld->createMaterial( 0 , 0 , 0 , 1 , Color4f( 1 , 1 , 1 , 1 ) );
ShaderEffect* shader = mat->addShaderEffect( "CoordTest" ,"CoordTest" );
shader->addParam( SP_WVP , "mWVP" );
mat->setLightingColor( CFLC_EMISSIVE , CFMC_VERTEX_C1 );
Object* obj = mMainScene->createObject();
obj->createIndexedTriangle( mat , CFVT_XYZ_CF1 , (float*)vtx , 4 , idx , 2 );
return true;
}
示例8: getTexCoord1
void TexturedQuadUIDrawObject::draw(const GraphicsWeakPtr Graphics, Real32 Opacity) const
{
//TODO: add Color Field to TexturedQuadUIDrawObject
Graphics->drawQuad(getPoint1(),getPoint2(),getPoint3(),getPoint4(),
getTexCoord1(), getTexCoord2(), getTexCoord3(), getTexCoord4(),
Color4f(1.0f,1.0f,1.0f,1.0f), getTexture(),
getOpacity()*Opacity);
}
示例9: GD_ASSERT
void ModelBrowserTool::Render()
{
Renderer* renderer = GraphicSubsystem::Instance()->GetRenderer();
GD_ASSERT(renderer);
renderer->SetViewport( 0, 0, mModelBrowserWindow->mViewerFrame->width(), mModelBrowserWindow->mViewerFrame->height() );
renderer->SetClearColor( Color4f( 0.1f, 0.2f, 0.4f, 1.0f) );
renderer->SetCulling( Renderer::CullBackFace );
// Render.
renderer->Clear( Renderer::ColorBuffer | Renderer::DepthBuffer );
renderer->SetRenderState( Renderer::DepthTest, true );
// Camera.
renderer->SetMatrixMode(Renderer::ProjectionMatrix);
renderer->LoadIdentity();
renderer->Perspective(mCamera.GetFovAngle(),
(float)mModelBrowserWindow->mViewerFrame->width() / (float)mModelBrowserWindow->mViewerFrame->height(),
mCamera.GetNearView(), mCamera.GetFarView());
renderer->SetMatrixMode(Renderer::ModelViewMatrix);
renderer->LoadIdentity();
renderer->SetView( mCamera.GetPosition(), mObjectCenter - mCamera.GetPosition(), mCamera.GetUp() );
Light light;
light.mPosition = mCamera.GetPosition();
light.mAmbient = Color4f(0.1f,0.1f, 0.1f,1.0f);
light.mDiffuse = Color4f(0.9f,0.9f, 0.9f,1.0f);
light.mType = Renderer::LightPoint;
renderer->SetRenderState( Renderer::Light_i, true, 0 );
renderer->SetLight( 0, light );
renderer->SetRenderState( Renderer::Lighting, true );
renderer->SetColor(Color4f(1.0f, 1.0f, 1.0f, 1.0f));
// Change the orientation.
static Float pAngle = 0;
pAngle += 0.05f;
mModel->SetOrientation(Quaternionf( Vector3f(0,1,0), pAngle ));
renderer->Translate(mModel->GetPosition());
renderer->Rotate(mModel->GetOrientation());
mModel->Render();
}
示例10: Color3b
void Panzerfaust::update(float deltaTime)
{
bool forwardVelocity = m_IOHandler.m_keyIsDown['W'];
bool backwardVelocity = m_IOHandler.m_keyIsDown['S'];
bool leftwardVelocity = m_IOHandler.m_keyIsDown['A'];
bool rightwardVelocity = m_IOHandler.m_keyIsDown['D'];
//HACK
const float SPEED_OF_CAMERA = 50.f;
g_localUser.m_unit.m_target.x += (rightwardVelocity - leftwardVelocity)*SPEED_OF_CAMERA*deltaTime;
g_localUser.m_unit.m_target.y += (forwardVelocity - backwardVelocity)*SPEED_OF_CAMERA*deltaTime;
g_localUser.update(deltaTime);
GamePacket currentPacket;
do
{
bool newUser = true;
currentPacket = g_serverConnection->receivePackets();
if (currentPacket.ID != 0)
{
Color3b packetColor = Color3b();
packetColor.r = currentPacket.r;
packetColor.g = currentPacket.g;
packetColor.b = currentPacket.b;
for (unsigned int ii = 0; ii < g_users.size(); ii++)
{
if (Color3b(g_users[ii].m_unit.m_color) == packetColor)
{
newUser = false;
g_users[ii].m_unit.m_target = Vector2f(currentPacket.x, currentPacket.y);
}
}
if (newUser)
{
User tempUser = User();
tempUser.m_unit.m_position = Vector2f(currentPacket.x, currentPacket.y);
tempUser.m_unit.m_target = Vector2f(currentPacket.x, currentPacket.y);
tempUser.m_unit.m_color = Color4f(packetColor.r/255.f, packetColor.g/255.f, packetColor.b/255.f, 1.f);
tempUser.m_userType = USER_REMOTE;
g_users.push_back(tempUser);
}
}
} while (currentPacket.ID != 0);
for (unsigned int ii = 0; ii < g_users.size(); ii++)
{
g_users[ii].update(deltaTime);
}
mouseUpdate();
m_internalTime += deltaTime;
//m_world.update(deltaTime);
}
示例11: ComponentTransitPtr
ComponentTransitPtr DefaultTableCellEditor::getTableCellEditorComponent(Table* const table, const boost::any& value, bool isSelected, UInt32 row, UInt32 column)
{
if(value.empty()){
return ComponentTransitPtr(NULL);
}
TextFieldRefPtr TheTextField = TextField::create();
std::string tempString;
try
{
tempString = lexical_cast(value);
}
catch (boost::bad_lexical_cast &)
{
//Could not convert to string
}
TheTextField->setText(tempString);
TheTextField->setPreferredSize(Vec2f(100,30));
TheTextField->setAlignment(Vec2f(0.5,0.5));
TheTextField->selectAll();
TheTextField->setCaretPosition(TheTextField->getText().size());
ColorLayerRefPtr tempBackground;
tempBackground = ColorLayer::create();
TheTextField->setBackground(tempBackground);
//if(isSelected){
// tempBackground->setColor(Color4f(0.4, 0.4, 1.0, 1.0));
//}
//else{
tempBackground->setColor(Color4f(1.0, 1.0, 1.0, 1.0));
//}
LineBorderRefPtr tempBorder;
tempBorder = LineBorder::create();
tempBorder->setColor(Color4f(0.0, 0.0, 1.0, 1.0));
TheTextField->setBorder(tempBorder);
setDefaultStringEditor(TheTextField);
_EditorActionConnection = getDefaultStringEditor()->connectActionPerformed(boost::bind(&DefaultTableCellEditor::handleEditorAction, this, _1));
_EditorFocusLostConnection = getDefaultStringEditor()->connectFocusLost(boost::bind(&DefaultTableCellEditor::handleEditorFocusLost, this, _1));
_EditorKeyPressedConnection = getDefaultStringEditor()->connectKeyPressed(boost::bind(&DefaultTableCellEditor::handleEditorKeyPressed, this, _1));
return ComponentTransitPtr(getDefaultStringEditor());
}
示例12: Inherited
FogChunkBase::FogChunkBase(void) :
Inherited(),
_sfMode (GLenum(GL_EXP)),
_sfColor (Color4f(0.f, 0.f, 0.f, 0.f)),
_sfStart (Real32(0.f)),
_sfEnd (Real32(1.f)),
_sfDensity (Real32(1.f))
{
}
示例13:
MaterialUnrecPtr Graphics3DExtrude::createDefaultMaterial(void)
{
MaterialChunkUnrecPtr TheMaterialChunk = MaterialChunk::create();
TheMaterialChunk->setAmbient(Color4f(0.4,0.4,0.4,1.0));
TheMaterialChunk->setDiffuse(Color4f(0.8,0.8,0.8,1.0));
TheMaterialChunk->setSpecular(Color4f(0.85,0.85,0.85,1.0));
TheMaterialChunk->setEmission(Color4f(0.0,0.0,0.0,1.0));
TheMaterialChunk->setShininess(50.0);
TheMaterialChunk->setLit(true);
TheMaterialChunk->setColorMaterial(true);
ChunkMaterialUnrecPtr TheMaterial = ChunkMaterial::create();
TheMaterial->addChunk(TheMaterialChunk);
return TheMaterial;
}
示例14: Inherited
LineUIDrawObjectBase::LineUIDrawObjectBase(void) :
Inherited(),
_sfTopLeft (Pnt2f(0,0)),
_sfBottomRight (Pnt2f(0,0)),
_sfWidth (Real32(1)),
_sfColor (Color4f(1.0,1.0,1.0,1.0)),
_sfOpacity (Real32(1.0))
{
}
示例15: Inherited
LabelBase::LabelBase(void) :
Inherited(),
_sfPosition (Pnt3f(0,0,0)),
_sfPixelOffset (Vec2f(0,0)),
_sfOrientation (Real32(0.0)),
_sfHorizontalAlign (UInt8(1)),
_sfVerticalAlign (UInt8(1)),
_sfMargin (Vec2f(0,0)),
_sfColor (Color4f(1,1,1,1)),
_sfBgColor (Color4f(0,0,0,0)),
_sfShadowColor (Color4f(0,0,0,1)),
_sfShadowOffset (Vec2f(1,-1)),
_sfBorderColor (Color4f(0,0,0,0)),
_sfBorderOffset (Vec2f(4,4)),
_sfImportance (Real32(1)),
_sfTextureObject (NULL)
{
}