本文整理汇总了C++中Entity::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::Draw方法的具体用法?C++ Entity::Draw怎么用?C++ Entity::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GameRender
void GameRender(ShaderProgram* program, std::vector<Entity*>& entities, std::vector<Entity*> enemy_bullets, std::vector<DrawSpriteText> text, Entity& player_bullet, Entity& explosion, Entity& player){
glClear(GL_COLOR_BUFFER_BIT);
for (size_t i = 0; i < entities.size(); ++i){
if (!entities[i]->isDead){
entities[i]->Draw(program);
}
}
for (size_t i = 0; i < enemy_bullets.size(); ++i){
enemy_bullets[i]->Draw(program);
}
for (size_t i = 0; i < text.size(); ++i){
text[i].Draw(program);
}
if (!player.isDead){
player.Draw(program);
}
player_bullet.Draw(program);
explosion.Draw(program);
SDL_GL_SwapWindow(displayWindow);
}
示例2: Draw
void Menu::Draw(bool nextImg, SDL_Surface *screen)
{
//Move the objects before drawing.
for (unsigned int i = PhysicObjects.size(); i; i-- )
{
PhysicObject* tempObj = PhysicObjects.front();
PhysicObjects.pop_front();
tempObj->Move(PhysicObjects);
PhysicObjects.push_back(tempObj);
}
//Draw the background.
SDL_Rect *pos = new SDL_Rect;
pos->x = 0;
pos->y = 0;
SDL_BlitSurface( background, NULL, screen, pos);
//Draw the enities.
for (unsigned int i = Entities.size(); i; i-- )
{
Entity* tempEnt = Entities.front();
Entities.pop_front();
tempEnt->Draw(nextImg, screen);
if (tempEnt->getVisible())
tempEnt->DrawText(screen);
Entities.push_back(tempEnt);
}
}
示例3: render
void Engine::render() {
sysTime.Resume();
for(uint32_t i = 0; i < modules.size(); ++i) {
modules[i]->DrawBefore();
}
sysTime.Pause();
drawTime.Resume();
Entity * base = universe.Identify();
if (base) base->Draw();
drawTime.Pause();
sysTime.Resume();
for(uint32_t i = 0; i < modules.size(); ++i) {
modules[i]->DrawAfter();
}
if (managers.Valid())
managers.Identify()->Draw();
sysTime.Pause();
drawTime.Resume();
if (Graphics::DrawEachFrame())
Graphics::Commit();
drawTime.Pause();
}
示例4: glLineWidth
void GraphicsWindow::Selection::Draw(void) {
Vector refp = Vector::From(0, 0, 0);
if(entity.v) {
Entity *e = SK.GetEntity(entity);
e->Draw();
if(emphasized) refp = e->GetReferencePos();
}
if(constraint.v) {
Constraint *c = SK.GetConstraint(constraint);
c->Draw();
if(emphasized) refp = c->GetReferencePos();
}
if(emphasized && (constraint.v || entity.v)) {
// We want to emphasize this constraint or entity, by drawing a thick
// line from the top left corner of the screen to the reference point
// of that entity or constraint.
double s = 0.501/SS.GW.scale;
Vector topLeft = SS.GW.projRight.ScaledBy(-SS.GW.width*s);
topLeft = topLeft.Plus(SS.GW.projUp.ScaledBy(SS.GW.height*s));
topLeft = topLeft.Minus(SS.GW.offset);
glLineWidth(40);
RgbColor rgb = Style::Color(Style::HOVERED);
glColor4d(rgb.redF(), rgb.greenF(), rgb.blueF(), 0.2);
glBegin(GL_LINES);
ssglVertex3v(topLeft);
ssglVertex3v(refp);
glEnd();
glLineWidth(1);
}
}
示例5: Draw
/**
* Default implementation of the Draw method for all entities
* @param Renderer* The renderer to use.
* @return void
*/
void Entity::Draw(Renderer* argPRenderer)
{
D3DXMatrixIdentity(&this->matWorld);
// Scaling
D3DXMATRIXA16 matScaling;
D3DXMatrixScaling(&matScaling, this->scaling.x, this->scaling.y, this->scaling.z);
D3DXMatrixMultiply(&this->matWorld, &this->matWorld, &matScaling);
// Rotation X
D3DXMATRIXA16 matRotationX;
D3DXMatrixRotationX(&matRotationX, this->rotation.x);
D3DXMatrixMultiply(&this->matWorld, &this->matWorld, &matRotationX);
// Rotation Y
D3DXMATRIXA16 matRotationY;
D3DXMatrixRotationY(&matRotationY, this->rotation.y);
D3DXMatrixMultiply(&this->matWorld, &this->matWorld, &matRotationY);
// Rotation Z
D3DXMATRIXA16 matRotationZ;
D3DXMatrixRotationZ(&matRotationZ, this->rotation.z);
D3DXMatrixMultiply(&this->matWorld, &this->matWorld, &matRotationZ);
// Position
D3DXMATRIXA16 matPosition;
D3DXMatrixTranslation(&matPosition, this->position.x, this->position.y, this->position.z);
D3DXMatrixMultiply(&this->matWorld, &this->matWorld, &matPosition);
// Multiplies the entity world matrix with the renderer's world matrix (this->matWorld * renderer->matWorld)
argPRenderer->AddToWorldMatrix(&this->matWorld);
// Apply the matrix transformations
argPRenderer->TransformWorldMatrix();
argPRenderer->TransformViewMatrix();
argPRenderer->TransformProjectionMatrix();
// Draw our sub entities
std::map<std::string, Entity*>::iterator entityIt;
for(entityIt = this->entities.begin(); entityIt != this->entities.end(); entityIt++)
{
Entity* pEntity = entityIt->second;
argPRenderer->Push();
pEntity->Draw(argPRenderer);
argPRenderer->Pop();
}
}
示例6: Render
void Render(ShaderProgram* program, Matrix* projectionMatrix, Matrix* viewMatrix, std::vector<Matrix>& modelM, std::vector<Entity>& entities, Entity ball, Matrix ballM){
program->setProjectionMatrix(*projectionMatrix);
program->setViewMatrix(*viewMatrix);
for (size_t i = 0; i < entities.size(); ++i){
modelM[i].identity();
modelM[i].Translate(entities[i].x, entities[i].y, 0);
modelM[i].Scale(entities[i].width, entities[i].height, 1.0f);
program->setModelMatrix(modelM[i]);
entities[i].Draw(program);
}
ballM.identity();
ballM.Translate(ball.x, ball.y, 0);
ballM.Scale(ball.width, ball.height, 1.0f);
program->setModelMatrix(ballM);
ball.Draw(program);
SDL_GL_SwapWindow(displayWindow);
}
示例7: RenderMainMenu
void gameApp::RenderMainMenu()
{
Entity ts = Entity(SpriteSheet(titlescreen, 1, 1, 1,1, 8.0f));
ts.Draw(program);
//implement shade in via shaders
modelMatrix.identity();
modelMatrix.Translate(-2.5f, 3.0f, 0.0f);
program->setModelMatrix(modelMatrix);
DrawText(fontSprites, "Touhou Quest", .45f, -.22f);
modelMatrix.identity();
modelMatrix.Translate(-2.0f, 2.4f, 0.0f);
program->setModelMatrix(modelMatrix);
DrawText(fontSprites, "Two Buttons To Play", .3f, -.189f);
modelMatrix.identity();
modelMatrix.Translate(-1.8f, 2.0f, 0.0f);
program->setModelMatrix(modelMatrix);
DrawText(fontSprites, "Z, X", .3f, -.189f);
SDL_GL_SwapWindow(displayWindow);
}
示例8: Render
void Render() {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
space.Draw();
ball.Draw();
paddle1.Draw();
paddle2.Draw();
top.Draw();
bottom.Draw();
SDL_GL_SwapWindow(displayWindow);
}
示例9: Draw
void Engine::Draw()
{
m_window->clear(sf::Color::Black);
// render world
m_world->Draw(m_window);
// render entities
for(entities_t::iterator it = m_entities.begin(); it != m_entities.end(); ++it)
{
Entity* entity = (*it);
entity->Draw(m_window);
}
// render characters
for(size_t i = 0; i < m_players.size(); ++i)
{
Player* player = m_players[i];
player->Draw(m_window);
}
m_window->display();
}
示例10: UpdateImposter
//.........这里部分代码省略.........
center += imposterVertices[i];
}
center /= 4.f;
//draw
RecreateFbo(screenSize);
//Logger::Info("%f, %f", screenSize.x, screenSize.y);
if(!block)
{
return;
}
direction = camera->GetPosition()-center;
direction.Normalize();
distanceSquaredToCamera = (center-cameraPos).SquareLength();
float32 nearPlane = sqrtf(distanceSquaredToCamera);
//float32 farPlane = nearPlane + (bbox.max.z-bbox.min.z);
float32 w = (imposterVertices[1]-imposterVertices[0]).Length();
float32 h = (imposterVertices[2]-imposterVertices[0]).Length();
//TODO: calculate instead of +50
imposterCamera->Setup(-w/2.f, w/2.f, -h/2.f, h/2.f, nearPlane, nearPlane+50.f);
Rect oldViewport = RenderManager::Instance()->GetViewport();
//Texture * target = fbo->GetTexture();
RenderManager::Instance()->AppendState(RenderState::STATE_SCISSOR_TEST);
RenderManager::Instance()->State()->SetScissorRect(Rect(block->offset.x, block->offset.y, block->size.dx, block->size.dy));
RenderManager::Instance()->FlushState();
//TODO: use one "clear" function instead of two
//if(block->size.x == 512.f)
//{
// RenderManager::Instance()->ClearWithColor(0.f, .8f, 0.f, 1.f);
//}
//else if(block->size.x == 256.f)
//{
// RenderManager::Instance()->ClearWithColor(0.f, .3f, 0.f, 1.f);
//}
//else if(block->size.x == 128.f)
//{
// RenderManager::Instance()->ClearWithColor(.3f, .3f, 0.f, 1.f);
//}
//else
//{
// RenderManager::Instance()->ClearWithColor(.3f, 0.f, 0.f, 1.f);
//}
RenderManager::Instance()->ClearWithColor(.0f, .0f, 0.f, .0f);
RenderManager::Instance()->ClearDepthBuffer();
RenderManager::Instance()->RemoveState(RenderState::STATE_SCISSOR_TEST);
RenderManager::Instance()->SetViewport(Rect(block->offset.x, block->offset.y, block->size.dx, block->size.dy), true);
imposterCamera->SetTarget(center);
imposterCamera->Set();
//TODO: remove this call
HierarchicalRemoveCull(child);
RenderManager::Instance()->FlushState();
child->Draw();
RenderManager::Instance()->SetViewport(oldViewport, true);
isReady = true;
state = STATE_IMPOSTER;
//unproject
screenBillboardVertices[0] = Vector3(screenBounds.min.x, screenBounds.min.y, bboxCenterZ);
screenBillboardVertices[1] = Vector3(screenBounds.max.x, screenBounds.min.y, bboxCenterZ);
screenBillboardVertices[2] = Vector3(screenBounds.min.x, screenBounds.max.y, bboxCenterZ);
screenBillboardVertices[3] = Vector3(screenBounds.max.x, screenBounds.max.y, bboxCenterZ);
for(int32 i = 0; i < 4; ++i)
{
//unproject
Vector4 out;
out.x = 2.f*(screenBillboardVertices[i].x-viewport.x)/viewport.dx-1.f;
out.y = 2.f*(screenBillboardVertices[i].y-viewport.y)/viewport.dy-1.f;
out.z = 2.f*screenBillboardVertices[i].z-1.f;
out.w = 1.f;
out = out*invMvp;
DVASSERT(out.w != 0.f);
out.x /= out.w;
out.y /= out.w;
out.z /= out.w;
imposterVertices[i] = Vector3(out.x, out.y, out.z);
}
SafeRelease(imposterCamera);
ClearGeometry();
CreateGeometry();
}
示例11: main
int main(int argc, char* argv) {
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window* window = nullptr;
SDL_Renderer* gRenderer = NULL;
window = SDL_CreateWindow("Hi", 50, 50, 1000, 500, SDL_WINDOW_SHOWN);
gRenderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
Uint32 tick;
bool pauseReset = true;
bool running = true;
float frame = 0.0f;
//Initialize renderer color
SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
//Initialize PNG loading
int imgFlags = IMG_INIT_PNG;
if (!(IMG_Init(imgFlags) & imgFlags))
{
printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError());
}
Game game;
Entity entity;
game.LoadMobList(gRenderer);
game.LoadPlayerAnims(gRenderer, &entity);
game.InitSpawnManager();
//IDENFITY A MOB
//Entity mush = *game.IdentifyMob("mush");
Input PlayerInput;
GameMap map;
SDL_Rect mapPos;
mapPos.w = 1387;
mapPos.h = 907;
mapPos.x = 0;
mapPos.y = -407;
map.InitMap("content\\maps\\hennesys\\map01.png", mapPos, gRenderer);
entity.SetPositionY(190);
while (running) {
tick = SDL_GetTicks();
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
break;
case SDL_KEYDOWN:
PlayerInput.KeyDown(event.key.keysym.scancode);
break;
case SDL_KEYUP:
PlayerInput.KeyUp(event.key.keysym.scancode);
break;
}
}
//Clear screen
SDL_RenderClear(gRenderer);
if (PlayerInput.IsKeyPressed(SDL_SCANCODE_LEFT)) {
entity.Walk(Left);
}
else if (PlayerInput.IsKeyPressed(SDL_SCANCODE_RIGHT)) {
entity.Walk(Right);
}
else {
entity.Station();
}
map.DrawMap(mapPos);
entity.Draw();
game.ManageMobPool();
//Update screen
SDL_RenderPresent(gRenderer);
//SpawnManager
game.spawn_manager.ManagePool(tick);
//LIMIT FPS
frame += 0.1f;
unsigned int fps = 60;
if ((1000 / fps) > SDL_GetTicks() - tick) {
SDL_Delay(1000 / fps - (SDL_GetTicks() - tick));
}
}
SDL_DestroyWindow(window);
return 1;
//.........这里部分代码省略.........
示例12: Render
void Render(ShaderProgram program, Matrix modelMatrix)
{
modelMatrix.identity();
modelMatrix.Translate(p1Score.xPosition, p1Score.yPosition, 0.0f);
program.setModelMatrix(modelMatrix);
switch (p1ScoreCount) {
case 0:
DrawSpriteSheetSprite(program, p1Score.EntityTexture, 48, 16, 16);
break;
case 1:
DrawSpriteSheetSprite(program, p1Score.EntityTexture, 49, 16, 16);
break;
case 2:
DrawSpriteSheetSprite(program, p1Score.EntityTexture, 50, 16, 16);
break;
case 3:
DrawSpriteSheetSprite(program, p1Score.EntityTexture, 51, 16, 16);
break;
case 4:
DrawSpriteSheetSprite(program, p1Score.EntityTexture, 52, 16, 16);
break;
case 5:
DrawSpriteSheetSprite(program, p1Score.EntityTexture, 53, 16, 16);
break;
case 6:
DrawSpriteSheetSprite(program, p1Score.EntityTexture, 54, 16, 16);
break;
default:
p1ScoreCount = 0;
DrawSpriteSheetSprite(program, p1Score.EntityTexture, 48, 16, 16);
break;
}
modelMatrix.identity();
modelMatrix.Translate(p2Score.xPosition, p2Score.yPosition, 0.0f);
program.setModelMatrix(modelMatrix);
switch (p2ScoreCount) {
case 0:
DrawSpriteSheetSprite(program, p2Score.EntityTexture, 48, 16, 16);
break;
case 1:
DrawSpriteSheetSprite(program, p2Score.EntityTexture, 49, 16, 16);
break;
case 2:
DrawSpriteSheetSprite(program, p2Score.EntityTexture, 50, 16, 16);
break;
case 3:
DrawSpriteSheetSprite(program, p2Score.EntityTexture, 51, 16, 16);
break;
case 4:
DrawSpriteSheetSprite(program, p2Score.EntityTexture, 52, 16, 16);
break;
case 5:
DrawSpriteSheetSprite(program, p2Score.EntityTexture, 53, 16, 16);
break;
case 6:
DrawSpriteSheetSprite(program, p2Score.EntityTexture, 54, 16, 16);
break;
default:
p2ScoreCount = 0;
DrawSpriteSheetSprite(program, p2Score.EntityTexture, 48, 16, 16);
break;
}
modelMatrix.identity();
modelMatrix.Translate(p1Paddle.xPosition, p1Paddle.yPosition, 0.0f);
program.setModelMatrix(modelMatrix);
p1Paddle.Draw(program);
modelMatrix.identity();
modelMatrix.Translate(pongBall.xPosition, pongBall.yPosition, 0.0f);
program.setModelMatrix(modelMatrix);
pongBall.Draw(program);
modelMatrix.identity();
modelMatrix.Translate(p2Paddle.xPosition, p2Paddle.yPosition, 0.0f);
program.setModelMatrix(modelMatrix);
p2Paddle.Draw(program);
}
示例13: Render
void MyGame::Render(SDL_Surface* pDestSurface) {
debugLevel.Draw( pDestSurface );
player.Draw( pDestSurface );
}
示例14: DrawAll
void Entity::DrawAll(void) {
// This handles points and line segments as a special case, because I
// seem to be able to get a huge speedup that way, by consolidating
// stuff to gl.
int i;
if(SS.GW.showPoints) {
double s = 3.5/SS.GW.scale;
Vector r = SS.GW.projRight.ScaledBy(s);
Vector d = SS.GW.projUp.ScaledBy(s);
ssglColorRGB(Style::Color(Style::DATUM));
ssglDepthRangeOffset(6);
glBegin(GL_QUADS);
for(i = 0; i < SK.entity.n; i++) {
Entity *e = &(SK.entity.elem[i]);
if(!e->IsPoint()) continue;
if(!(SK.GetGroup(e->group)->IsVisible())) continue;
if(e->forceHidden) continue;
Vector v = e->PointGetNum();
// If we're analyzing the sketch to show the degrees of freedom,
// then we draw big colored squares over the points that are
// free to move.
bool free = false;
if(e->type == POINT_IN_3D) {
Param *px = SK.GetParam(e->param[0]),
*py = SK.GetParam(e->param[1]),
*pz = SK.GetParam(e->param[2]);
free = (px->free) || (py->free) || (pz->free);
} else if(e->type == POINT_IN_2D) {
Param *pu = SK.GetParam(e->param[0]),
*pv = SK.GetParam(e->param[1]);
free = (pu->free) || (pv->free);
}
if(free) {
Vector re = r.ScaledBy(2.5), de = d.ScaledBy(2.5);
ssglColorRGB(Style::Color(Style::ANALYZE));
ssglVertex3v(v.Plus (re).Plus (de));
ssglVertex3v(v.Plus (re).Minus(de));
ssglVertex3v(v.Minus(re).Minus(de));
ssglVertex3v(v.Minus(re).Plus (de));
ssglColorRGB(Style::Color(Style::DATUM));
}
ssglVertex3v(v.Plus (r).Plus (d));
ssglVertex3v(v.Plus (r).Minus(d));
ssglVertex3v(v.Minus(r).Minus(d));
ssglVertex3v(v.Minus(r).Plus (d));
}
glEnd();
ssglDepthRangeOffset(0);
}
for(i = 0; i < SK.entity.n; i++) {
Entity *e = &(SK.entity.elem[i]);
if(e->IsPoint())
{
continue; // already handled
}
e->Draw();
}
}
示例15: main
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
displayWindow = SDL_CreateWindow("Simon Project 1", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL); // SDL Window, title, position,position,width,height, type of graphics?
SDL_GLContext context = SDL_GL_CreateContext(displayWindow);
SDL_GL_MakeCurrent(displayWindow, context);
glClearColor(0.5, 0.5, 0.0, .9);//Green-color
//Setup
glViewport(0, 0, 800, 600);
glMatrixMode(GL_PROJECTION);
glOrtho(-1.33, 1.33, -1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glOrtho(-1.33, 1.33, -1.0, 1.0, -1.0, 1.0);
//LoadTextures
GLuint paddleID = LoadTexture("pngs/paddle.png");
GLuint ballID = LoadTexture("pngs/ball.png");
GLuint leftwinID = LoadTexture24("pngs/leftwin.png");
GLuint rightwinID = LoadTexture24("pngs/rightwin.png");
//Init Entities
initBall(ballID);
initPaddleLeft(paddleID);
initPaddleRight(paddleID);
initRightwin(rightwinID);
initLeftwin(leftwinID);
//Time
float lastFrameTicks = 0.0;
SDL_Event event;
bool done = false;
while (!done) {
glClear(GL_COLOR_BUFFER_BIT);
float ticks = (float)SDL_GetTicks() / 1000.0f;
float elapsed = ticks - lastFrameTicks;
lastFrameTicks = ticks;
//Read Input and Update World
while (SDL_PollEvent(&event)) { // a lot of events could cue up, no?, could also get all keyboard states and check for those. I think I like that better. - specially for pong
if (event.type == SDL_QUIT || event.type == SDL_WINDOWEVENT_CLOSE) {
done = true;
}
}
const Uint8 *keys = SDL_GetKeyboardState(NULL);
if (keys[SDL_SCANCODE_UP]) {
paddleright.y += elapsed*paddleright.velocity_y;
if (paddleright.y > (1 - .2)){ paddleright.y = 1 - .2; }
}
else if (keys[SDL_SCANCODE_DOWN]) {
paddleright.y -= elapsed*paddleright.velocity_y;
if (paddleright.y < (-1 + .2)){ paddleright.y = -1 + .2; }
}
if (keys[SDL_SCANCODE_W]) {
paddleleft.y += elapsed*paddleleft.velocity_y;
if (paddleleft.y >(1 - .2)){ paddleleft.y = 1 - .2; }
}
else if (keys[SDL_SCANCODE_S]) {
paddleleft.y -= elapsed*paddleleft.velocity_y;
if (paddleleft.y < (-1 + .2)){ paddleleft.y = -1 + .2; }
}
updateBall(elapsed);
isWin();
//Render World
ball.Draw();
paddleleft.Draw();
paddleright.Draw();
if (rightwin)
{
endGame();
rightwinE.Draw();
}
if (leftwin)
{
endGame();
leftwinE.Draw();
}
SDL_GL_SwapWindow(displayWindow);//Swaps old modelview with new one?
}
SDL_Quit();
return 0;
}