本文整理汇总了C++中EndDrawing函数的典型用法代码示例。如果您正苦于以下问题:C++ EndDrawing函数的具体用法?C++ EndDrawing怎么用?C++ EndDrawing使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EndDrawing函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EndDrawing
/* virtual */ bool EditPanel::MouseButton( int btn, bool up )
{
if ( mDrawing && up )
{
EndDrawing();
return true;
}
if ( DrawPanel::MouseButton( btn, up ) )
{
return true;
}
bool left = btn == wxMOUSE_BTN_LEFT;
bool right = btn == wxMOUSE_BTN_RIGHT;
if (mMousePoint.x == -1 || mMousePoint.y == -1 || PointInZone( mMousePoint ) || !this->HasFocus() )
{
return false;
}
if (left || right)
{
mCurrentColour = right ? mRightColour : mLeftColour;
}
if ( !up && ( left || right ) )
{
return BeginDrawing();
}
return false;
}
示例2: Test28
void Test28()
{
InitWindow();
static Bitmap bm;
bm.w = bm.h = 256; bm.form = BMFORMAT_B8G8R8A8; bm.pal = 0;
bm.pix = (uchar*)malloc(bm.w * bm.h * 4);
memset(bm.pix, 127, bm.w * bm.h * 4);
static int px = 61, py = 89, vx = 2, vy = -3;
*(uint*)(bm.pix + (py*bm.w + px) * 4) = -1;
static texture t = CreateTexture(&bm, 1);
while(!appexit)
{
px += vx; if(px < 0 || px >= 256) {px -= vx; vx = -vx;}
py += vy; if(py < 0 || py >= 256) {py -= vy; vy = -vy;}
*(uint*)(bm.pix + (py*bm.w + px) * 4) = -1;
renderer->UpdateTexture(t, &bm);
BeginDrawing();
InitRectDrawing();
SetTexture(0, t);
DrawRect(0, 0, 256, 256, -1);
EndDrawing();
HandleWindow();
}
}
示例3: DrawGame
// Draw game (one frame)
void DrawGame(void)
{
BeginDrawing();
ClearBackground(RAYWHITE);
if (!gameOver)
{
DrawRectangleRec(player.rec, player.color);
if (wave == FIRST) DrawText("FIRST WAVE", screenWidth/2 - MeasureText("FIRST WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha));
else if (wave == SECOND) DrawText("SECOND WAVE", screenWidth/2 - MeasureText("SECOND WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha));
else if (wave == THIRD) DrawText("THIRD WAVE", screenWidth/2 - MeasureText("THIRD WAVE", 40)/2, screenHeight/2 - 40, 40, Fade(BLACK, alpha));
for (int i = 0; i < activeEnemies; i++)
{
if (enemy[i].active) DrawRectangleRec(enemy[i].rec, enemy[i].color);
}
for (int i = 0; i < NUM_SHOOTS; i++)
{
if (shoot[i].active) DrawRectangleRec(shoot[i].rec, shoot[i].color);
}
DrawText(FormatText("%04i", score), 20, 20, 40, GRAY);
if (victory) DrawText("YOU WIN", screenWidth/2 - MeasureText("YOU WIN", 40)/2, screenHeight/2 - 40, 40, BLACK);
if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
}
else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY);
EndDrawing();
}
示例4: Test3
void Test3()
{
LoadBCP("data.bcp");
ReadLanguageFile();
InitWindow();
//InitRectDrawing();
//IDirect3DTexture9 *mytex = GetTexture("Interface\\LOADING SCREEN 1.tga");
//IDirect3DPixelShader9 *psh = LoadPixelShader("test.psh");
InitScene(); LoadMap("testmap.bcm");
while(!appexit)
{
BeginDrawing();
//ddev->SetRenderState(D3DRS_ZENABLE, FALSE);
//ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
//ddev->SetPixelShader(psh);
//ddev->SetTexture(0, mytex);
//DrawRect(0, 0, 640, 480, -1);
DrawScene();
EndDrawing();
HandleWindow();
if(keyheld[VK_UP]) camerapos += Vector3(0.0f, 0.0f, walkstep);
if(keyheld[VK_DOWN]) camerapos -= Vector3(0.0f, 0.0f, walkstep);
if(keyheld[VK_LEFT]) camerapos -= Vector3(walkstep, 0.0f, 0.0f);
if(keyheld[VK_RIGHT]) camerapos += Vector3(walkstep, 0.0f, 0.0f);
if(keyheld['E']) camerapos += Vector3(0.0f, walkstep, 0.0f);
if(keyheld['D']) camerapos -= Vector3(0.0f, walkstep, 0.0f);
}
}
示例5: main
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode");
// Define the camera to look into our 3d world
Camera camera;
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
Begin3dMode(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
DrawGrid(10, 1.0f);
End3dMode();
DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY);
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
示例6: main
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
// Define the camera to look into our 3d world
Camera camera = {{ 5.0, 4.0, 5.0 }, { 0.0, 2.0, 0.0 }, { 0.0, 1.0, 0.0 }};
Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
Vector3 billPosition = { 0.0, 2.0, 0.0 }; // Position where draw billboard
SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
SetCameraPosition(camera.position); // Set internal camera position to match our camera position
SetCameraTarget(camera.target); // Set internal camera target to match our camera target
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera); // Update internal camera and our camera
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
Begin3dMode(camera);
DrawBillboard(camera, bill, billPosition, 2.0f, WHITE);
DrawGrid(10.0, 1.0); // Draw a grid
End3dMode();
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(bill); // Unload texture
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
示例7: Test22
void Test22()
{
int curgrp = 0; char tb[512];
printf("Use LTTT? ");
int uselt = atoi(fgets(tb, 511, stdin));
LoadBCP("data.bcp");
InitWindow();
InitFont();
if(uselt) LoadLTTT("Maps\\Map_Textures\\128_4Peaks.lttt");
LoadMapTextures();
//MessageBox(hWindow, "Terrain textures loaded.", appName, 64);
printf("%u groups:\n", maptexgroup.len);
for(int i = 0; i < maptexgroup.len; i++)
{
MapTextureGroup *g = maptexgroup.getpnt(i);
printf(" * %s\n", g->name);
printf(" %u textures:\n", g->tex->len);
for(int j = 0; j < g->tex->len; j++)
printf(" - %u\n", g->tex->getpnt(j)->id);
}
//texture t = GetTexture("Warrior Kings Game Set\\Textures\\Tavern.pcx");
while(!appexit)
{
BeginDrawing();
InitRectDrawing();
//SetTexture(0, maptexgroup.getpnt(0)->tex->getpnt(0)->t);
//SetTexture(0, t);
//DrawRect(0, 0, 256, 256, -1);
MapTextureGroup *g = maptexgroup.getpnt(curgrp);
sprintf(tb, "%s (%u/%u)", g->name, curgrp, maptexgroup.len);
DrawFont(0, 0, tb);
for(int i = 0; i < g->tex->len; i++)
{
MapTexture *t = g->tex->getpnt(i);
SetTexture(0, t->t);
DrawRect(i * 65, 32, 64, 64, -1, t->x / 256.f, t->y / 256.f, t->w / 256.f, t->h / 256.f);
sprintf(tb, "%u", t->id);
DrawFont(i * 65, 96, tb);
}
if(keypressed[VK_LEFT])
{
if(curgrp > 0) curgrp--;
}
if(keypressed[VK_RIGHT])
{
if(curgrp < maptexgroup.len-1) curgrp++;
}
EndDrawing();
HandleWindow();
}
}
示例8: main
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing");
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY);
DrawLine(18, 42, screenWidth - 18, 42, BLACK);
DrawCircle(screenWidth/4, 120, 35, DARKBLUE);
DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE);
DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE);
DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
DrawRectangleGradient(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE);
DrawTriangle((Vector2){screenWidth/4*3, 80},
(Vector2){screenWidth/4*3 - 60, 150},
(Vector2){screenWidth/4*3 + 60, 150}, VIOLET);
DrawTriangleLines((Vector2){screenWidth/4*3, 160},
(Vector2){screenWidth/4*3 - 20, 230},
(Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE);
DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
示例9: main
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [texture] example - texture rectangle");
const char textLine1[] = "Lena image is a standard test image which has been in use since 1973.";
const char textLine2[] = "It comprises 512x512 pixels, and it is probably the most widely used";
const char textLine3[] = "test image for all sorts of image processing algorithms.";
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texture = LoadTexture("resources/lena.png"); // Texture loading
Rectangle eyesRec = { 225, 240, 155, 50 }; // Part of the texture to draw
Vector2 position = { 369, 241 };
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("LENA", 220, 100, 20, PINK);
DrawTexture(texture, screenWidth/2 - 256, 0, Fade(WHITE, 0.1f)); // Draw background image
DrawTextureRec(texture, eyesRec, position, WHITE); // Draw eyes part of image
DrawText(textLine1, 220, 140, 10, DARKGRAY);
DrawText(textLine2, 220, 160, 10, DARKGRAY);
DrawText(textLine3, 220, 180, 10, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
示例10: main
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };
Vector2 gamepadMovement = { 0.0f, 0.0f };
SetTargetFPS(60); // Set target frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsGamepadAvailable(GAMEPAD_PLAYER1))
{
gamepadMovement = GetGamepadMovement(GAMEPAD_PLAYER1);
ballPosition.x += gamepadMovement.x;
ballPosition.y -= gamepadMovement.y;
if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A))
{
ballPosition.x = (float)screenWidth/2;
ballPosition.y = (float)screenHeight/2;
}
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("move the ball with gamepad", 10, 10, 20, DARKGRAY);
DrawCircleV(ballPosition, 50, MAROON);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
示例11: DrawGame
// Draw game (one frame)
void DrawGame(void)
{
BeginDrawing();
ClearBackground(RAYWHITE);
if (!gameOver)
{
// Draw missiles
for (int i = 0; i < MAX_MISSILES; i++)
{
if (missile[i].active)
{
DrawLine(missile[i].origin.x, missile[i].origin.y, missile[i].position.x, missile[i].position.y, RED);
if (framesCounter % 16 < 8) DrawCircle(missile[i].position.x, missile[i].position.y, 3, YELLOW);
}
}
// Draw interceptors
for (int i = 0; i < MAX_INTERCEPTORS; i++)
{
if (interceptor[i].active)
{
DrawLine(interceptor[i].origin.x, interceptor[i].origin.y, interceptor[i].position.x, interceptor[i].position.y, GREEN);
if (framesCounter % 16 < 8) DrawCircle(interceptor[i].position.x, interceptor[i].position.y, 3, BLUE);
}
}
// Draw explosions
for (int i = 0; i < MAX_EXPLOSIONS; i++)
{
if (explosion[i].active) DrawCircle(explosion[i].position.x, explosion[i].position.y, EXPLOSION_RADIUS*explosion[i].radiusMultiplier, EXPLOSION_COLOR);
}
// Draw buildings and launchers
for (int i = 0; i < LAUNCHERS_AMOUNT; i++)
{
if (launcher[i].active) DrawRectangle(launcher[i].position.x - LAUNCHER_SIZE/2, launcher[i].position.y - LAUNCHER_SIZE/2, LAUNCHER_SIZE, LAUNCHER_SIZE, GRAY);
}
for (int i = 0; i < BUILDINGS_AMOUNT; i++)
{
if (building[i].active) DrawRectangle(building[i].position.x - BUILDING_SIZE/2, building[i].position.y - BUILDING_SIZE/2, BUILDING_SIZE, BUILDING_SIZE, LIGHTGRAY);
}
// Draw score
DrawText(FormatText("SCORE %4i", score), 20, 20, 40, LIGHTGRAY);
if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
}
else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY);
EndDrawing();
}
示例12: Test5
void Test5()
{
LoadBCP("data.bcp");
ReadLanguageFile();
InitWindow();
LoadGameSet("Warrior Kings Game Set\\small extensions.cpp");
printf("Game set loaded!\n");
printf("Declared items:\n");
for(int i = 0; i < strItems.len; i++)
printf(" - %s\n", strItems[i]);
printf("Defined values:\n");
for(int i = 0; i < defvalue.len; i++)
printf(" - %s = %f\n", strDefValue[i], defvalue[i]);
printf("Appearance tags:\n");
for(int i = 0; i < strAppearTag.len; i++)
printf(" - %s\n", strAppearTag[i]);
printf("ObjDefs:\n");
for(int i = 0; i < strObjDef.len; i++)
printf(" - %s (%s)\n", strObjDef[i], CLASS_str[typeObjDef[i]]);
printf("Looking at first object:\n");
printf(" - Tooltip: %s\n", objdef[0].tooltip);
printf(" - First start item: %f\n", objdef[0].startItems[0]);
printf(" - Shadow: %i\n", objdef[0].shadowtype);
printf("2nd's subtypes:\n");
for(int i = 0; i < pstObjDef[1]->len; i++)
printf(" - %s\n", (pstObjDef[1])->getdp(i));
printf("1st's subtypes (%i):\n", pstObjDef[0]->len);
for(int i = 0; i < pstObjDef[0]->len; i++)
printf(" - %s\n", (pstObjDef[0])->getdp(i));
printf("These ObjDefs have \"Default\" subtype and \"Default\" appearance:\n");
for(int i = 0; i < strObjDef.len; i++)
printf("- %s: %s\n", strObjDef[i], objdef[i].subtypes[0].appear[0].def?"Yes":"No"); // :S
getch();
//InitMeshDrawing();
int a = FindObjDef(CLASS_BUILDING, "Manor");
while(!appexit)
{
BeginDrawing();
BeginMeshDrawing();
SetModelMatrices();
objdef[a].subtypes[0].appear[0].def->draw(); // :S
EndDrawing();
HandleWindow();
}
}
示例13: main
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading");
const char msgBm[64] = "THIS IS AN AngelCode SPRITE FONT";
const char msgTtf[64] = "THIS SPRITE FONT has been GENERATED from a TTF";
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont fontBm = LoadSpriteFont("resources/fonts/bmfont.fnt"); // BMFont (AngelCode)
SpriteFont fontTtf = LoadSpriteFont("resources/fonts/pixantiqua.ttf"); // TTF font
Vector2 fontPosition;
fontPosition.x = screenWidth/2 - MeasureTextEx(fontBm, msgBm, fontBm.size, 0).x/2;
fontPosition.y = screenHeight/2 - fontBm.size/2 - 80;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update variables here...
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawTextEx(fontBm, msgBm, fontPosition, fontBm.size, 0, MAROON);
DrawTextEx(fontTtf, msgTtf, (Vector2){ 75.0f, 240.0f }, fontTtf.size*0.8f, 2, LIME);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadSpriteFont(fontBm); // AngelCode SpriteFont unloading
UnloadSpriteFont(fontTtf); // TTF SpriteFont unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
示例14: StartDrawing
void SpriteRenderer3D::DrawCache()
{
StartDrawing();
for (auto& s : sprites)
{
Draw(s);
}
EndDrawing();
}
示例15: Test21
void Test21()
{
InitWindow();
while(!appexit)
{
BeginDrawing();
EndDrawing();
HandleWindow();
Sleep(1000/30);
}
}