本文整理汇总了C++中drawString函数的典型用法代码示例。如果您正苦于以下问题:C++ drawString函数的具体用法?C++ drawString怎么用?C++ drawString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drawString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: abs
void Bond::output_torsion(ofstream &out){
out << "r " << 0.01* abs(moment_torsion) << endl;
drawString(out);
}
开发者ID:ryseto,项目名称:demsd,代码行数:4,代码来源:bond.cpp
示例2: _main
//.........这里部分代码省略.........
// Define struct for global variables!
struct cGlobals caveGlobals;
// Variables n stuff!
caveGlobals.food = 0;
caveGlobals.row = 1;
caveGlobals.col = 1;
caveGlobals.level = 1;
caveGlobals.dogsteps = 0;
caveGlobals.dogalive = 1;
caveGlobals.mysteps = 0;
caveGlobals.maxhealth = 10;
caveGlobals.curhealth = 10;
// Start at level 1 (obviously!)
changelevel(&caveGlobals);
// Draw Buffers and Initial Screen
__os_snprintf(caveGlobals.mystat, 64, " ");
doclearstuff();
drawstuff(&caveGlobals);
flipBuffers();
int err;
while(1) {
VPADRead(0, &vpad_data, 1, &err);
// Quit
if (vpad_data.btn_trigger & BUTTON_HOME) {
doclearstuff();
__os_snprintf(caveGlobals.endgame, 256, "Thanks for Playing!\nYour Final Level: %d \n\n\nBy: SonyUSA", caveGlobals.level);
drawString(0, 0, caveGlobals.endgame);
flipBuffers();
t1 = 0x50000000;
while(t1--) ;
//Maybe fix for exit crash?
doclearstuff();
flipBuffers();
doclearstuff();
flipBuffers();
//Ape escape!
SYSLaunchMenu();
_Exit();
}
//Grab Stuff (A)
if (vpad_data.btn_release & BUTTON_A) {
//Checks for Food
if (caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] == 8) {
doclearstuff();
__os_snprintf(caveGlobals.mystat, 64, "Got it!");
drawString(25, 17, caveGlobals.mystat);
caveGlobals.food += 1;
caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] = 2;
drawstuff(&caveGlobals);
flipBuffers();
}
//Check for Potions
if (caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] == 11) {
doclearstuff();
__os_snprintf(caveGlobals.mystat, 64, "*Gulp!*");
drawString(25, 17, caveGlobals.mystat);
caveGlobals.curhealth += 5;
caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] = 2;
//Make sure we don't go over health limit
开发者ID:CreeperMario,项目名称:cave,代码行数:67,代码来源:loader.c
示例3: drawSample
static void
drawSample(int x, int y, int w, int h,
struct formatInfo *format, struct envModeInfo *envMode)
{
glViewport(x, y, w, h);
glScissor(x, y, w, h);
glClearColor(0.1, 0.1, 0.1, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
begin2D(w, h);
drawString(format->name, 10, h - 15, labelInfoColor);
drawString(envMode->name, 10, 5, labelInfoColor);
end2D();
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, envMode->mode);
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, envColors[envColor]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
loadTexture(textureWidth, textureHeight, format);
if (drawBackground) {
drawCheck(15, 15, lightCheck, darkCheck);
}
if (drawBlended) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
}
if (drawSmooth) {
glShadeModel(GL_SMOOTH);
}
if (drawTextured) {
glEnable(GL_TEXTURE_2D);
}
glBegin(GL_QUADS);
glColor4f(1.0, 0.0, 0.0, 1.0);
glTexCoord2f(0.0, 0.0);
glVertex2f(-0.8, -0.8);
glColor4f(0.0, 1.0, 0.0, 1.0);
glTexCoord2f(1.0, 0.0);
glVertex2f(0.8, -0.8);
glColor4f(0.0, 0.0, 1.0, 1.0);
glTexCoord2f(1.0, 1.0);
glVertex2f(0.8, 0.8);
glColor4f(1.0, 1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0);
glVertex2f(-0.8, 0.8);
glEnd();
glDisable(GL_BLEND);
glShadeModel(GL_FLAT);
glDisable(GL_TEXTURE_2D);
if (displayLevelInfo) {
GLint width, height, border, components;
#if GL_EXT_texture
GLint redSize, greenSize, blueSize, alphaSize;
GLint luminanceSize, intensitySize;
#endif
char buf[255];
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_WIDTH, &width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_HEIGHT, &height);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_BORDER, &border);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_COMPONENTS, &components);
#if GL_EXT_texture
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_RED_SIZE_EXT, &redSize);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_GREEN_SIZE_EXT, &greenSize);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_BLUE_SIZE_EXT, &blueSize);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_ALPHA_SIZE_EXT, &alphaSize);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_LUMINANCE_SIZE_EXT, &luminanceSize);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_INTENSITY_SIZE_EXT, &intensitySize);
#endif
begin2D(w, h);
sprintf(buf, "dimensions: %d x %d", width, height);
drawStringOutline(buf, 15, h / 2 + 20, labelLevelColor0, labelLevelColor1);
sprintf(buf, "border: %d", border);
drawStringOutline(buf, 15, h / 2 + 10, labelLevelColor0, labelLevelColor1);
sprintf(buf, "components: 0x%04X", components);
drawStringOutline(buf, 15, h / 2, labelLevelColor0, labelLevelColor1);
sprintf(buf, "sizes:");
//.........这里部分代码省略.........
开发者ID:BioTesseract,项目名称:Desktop,代码行数:101,代码来源:texenv.c
示例4: drawString
Vec2i drawString (const String& str, const Vec2f& pos, U32 abgr) { return drawString(str, Vec4f(pos, 0.0f, 1.0f), 0.5f, abgr); }
开发者ID:jtyot,项目名称:morse-pc,代码行数:1,代码来源:GLContext.hpp
示例5: switch
//-----------------------------------------------------------------------------
// name: render_2()
// desc: ...
//-----------------------------------------------------------------------------
void AudicleFaceShredder::render_2( t_CKFLOAT delta )
{
Shred_Stat * stat = NULL;
Shred_Data * data = NULL;
Color4D c;
Point3D p, v, a;
Point3D b;
t_CKFLOAT theta;
static char buffer[2048];
char * t;
char * d;
int i;
// loop through
t_CKFLOAT y = 1.15;
for( i = 0; i < m_stats.size(); i++ )
{
stat = m_stats[i];
data = (Shred_Data *)stat->data;
data->pos2[1] = y;
y -= .15;
}
// loop through
Shred_Stat * s;
t_CKFLOAT srate = Digitalio::sampling_rate() / 1000.0;
for( i = 0; i < m_stats.size(); i++ )
{
s = m_stats[i];
data = m_stats[i]->data;
c = data->color;
p = data->pos2;
switch( s->state )
{
case 0: t = "inactive"; break;
case 1: t = "active"; break;
case 2: t = "waiting"; break;
case 3: t = "done"; break;
default: t = "none"; break;
}
sprintf( buffer, "%i - %s - %s - %s - cycle(%i) - acts(%i) - c/a(%.2f) - avg(%.2fms)",
s->id, t, s->name.c_str(), s->source.c_str(), s->cycles, s->activations, s->average_cycles, s->average_ctrl / srate );
// push the name
glPushName( data->name );
glPushMatrix();
glColor4f( c[0], c[1], c[2], c[3] );
glTranslatef( p[0], p[1], p[2] );
glutSolidSphere( data->radius2, 15, 15 );
glTranslatef( .1, -.033, 0.0 );
glPushMatrix();
glColor4f( 0.0, 0.0, 0.0, 1.0 );
scaleFont( .052 );
drawString( buffer );
glPopMatrix();
glPopMatrix();
glPopName();
}
// loop through
map<Shred_Stat *, Shred_Stat *>::iterator iter;
for( iter = m_done.begin(); iter != m_done.end(); iter++ )
{
s = (*iter).second;
data = (Shred_Data *)(*iter).second->data;
c = data->color;
data->pos2[1] = y;
y -= .15;
p = data->pos2;
switch( s->state )
{
case 0: t = "inactive"; break;
case 1: t = "active"; break;
case 2: t = "waiting"; break;
case 3: t = "done"; break;
default: t = "none"; break;
}
sprintf( buffer, "%i - %s - %s - %s - cycle(%i) - acts(%i) - c/a(%.2f) - avg(%.2fms)",
s->id, t, s->name.c_str(), s->source.c_str(), s->cycles, s->activations, s->average_cycles, s->average_ctrl / srate );
// push the name
glPushName( data->name );
glPushMatrix();
glColor4f( c[0], c[1], c[2], c[3] );
glTranslatef( p[0], p[1], p[2] );
glutSolidSphere( data->radius2, 15, 15 );
glTranslatef( .1, -.033, 0.0 );
glPushMatrix();
glDisable( GL_LIGHTING );
glColor4f( 0.4, 0.4, 0.4, 1.0 );
scaleFont( .052 );
drawString( buffer );
glEnable( GL_LIGHTING );
//.........这里部分代码省略.........
开发者ID:ccrma,项目名称:audicle,代码行数:101,代码来源:audicle_face_shredder.cpp
示例6: twodigit
void SettingsSetTimeScreen::renderHour()
{
// numToStr(GetHour());
twodigit(buf, GetHour());
drawString(110, 175, buf, WHITE, BLACK, 2);
}
开发者ID:unregistered,项目名称:lg-activate,代码行数:6,代码来源:lgui.c
示例7: tsCalibCenterText
void tsCalibCenterText(char* text, uint16_t y, uint16_t color) {
drawString((lcdGetWidth() - drawGetStringWidth(&dejaVuSans9ptFontInfo, text)) / 2, y, color, &dejaVuSans9ptFontInfo, text);
}
开发者ID:fabienroyer,项目名称:NetduinoGo,代码行数:3,代码来源:touchscreen.c
示例8: pt
gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, int align, bool draw)
{
gfx::Point pt(0, rc.y);
if ((align & (JI_MIDDLE | JI_BOTTOM)) != 0) {
gfx::Size preSize = doUIStringAlgorithm(str, gfx::ColorNone, gfx::ColorNone, rc, 0, false);
if (align & JI_MIDDLE)
pt.y = rc.y + rc.h/2 - preSize.h/2;
else if (align & JI_BOTTOM)
pt.y = rc.y + rc.h - preSize.h;
}
gfx::Size calculatedSize(0, 0);
size_t beg, end, new_word_beg, old_end;
std::string line;
// Draw line-by-line
for (beg=end=0; end != std::string::npos; ) {
pt.x = rc.x;
// Without word-wrap
if ((align & JI_WORDWRAP) == 0) {
end = str.find('\n', beg);
}
// With word-wrap
else {
old_end = std::string::npos;
for (new_word_beg=beg;;) {
end = str.find_first_of(" \n", new_word_beg);
// If we have already a word to print (old_end != npos), and
// we are out of the available width (rc.w) using the new "end",
if ((old_end != std::string::npos) &&
(pt.x+m_font->textLength(str.substr(beg, end-beg).c_str()) > rc.w)) {
// We go back to the "old_end" and paint from "beg" to "end"
end = old_end;
break;
}
// If we have more words to print...
else if (end != std::string::npos) {
// Force line break, now we have to paint from "beg" to "end"
if (str[end] == '\n')
break;
// White-space, this is a beginning of a new word.
new_word_beg = end+1;
}
// We are in the end of text
else
break;
old_end = end;
}
}
// Get the entire line to be painted
line = str.substr(beg, end-beg);
gfx::Size lineSize(
m_font->textLength(line.c_str()),
m_font->height());
calculatedSize.w = MAX(calculatedSize.w, lineSize.w);
// Render the text
if (draw) {
int xout;
if ((align & JI_CENTER) == JI_CENTER)
xout = pt.x + rc.w/2 - lineSize.w/2;
else if ((align & JI_RIGHT) == JI_RIGHT)
xout = pt.x + rc.w - lineSize.w;
else
xout = pt.x;
drawString(line, fg, bg, gfx::Point(xout, pt.y));
if (!gfx::is_transparent(bg))
fillAreaBetweenRects(bg,
gfx::Rect(rc.x, pt.y, rc.w, lineSize.h),
gfx::Rect(xout, pt.y, lineSize.w, lineSize.h));
}
pt.y += lineSize.h;
calculatedSize.h += lineSize.h;
beg = end+1;
}
// Fill bottom area
if (draw && !gfx::is_transparent(bg)) {
if (pt.y < rc.y+rc.h)
fillRect(bg, gfx::Rect(rc.x, pt.y, rc.w, rc.y+rc.h-pt.y));
}
return calculatedSize;
}
开发者ID:ololo1982,项目名称:aseprite,代码行数:94,代码来源:graphics.cpp
示例9: drawPause
void drawPause() {
char *psChr = "PAUSE";
if ( (psCnt&63) < 32 ) {
drawString(psChr, 252, LAYER_HEIGHT/3, 20, 0, 200, 200, 180);
}
}
开发者ID:lambda-11235,项目名称:rrootage,代码行数:6,代码来源:attractmanager.c
示例10: main
int main(void)
{
//video mode 3, activate background 2
*REG_DISPCNT = MODE3 | BG2_ENABLE;
paddle.x = 113;
oldPaddle.x = 113;
//ball starts on top of paddle
setBallOnPaddle();
lives = 3;
bricksLeft = NUM_OF_BRICKS;
sprintf(livesString, "%d", lives); //store lives as a string
sprintf(bricksString, "%d", bricksLeft); //store bricks left as a string
drawBackground3(startscreen);
drawString(10, 125, "Press any key", WHITE);
drawString(10, 135, "to start", WHITE);
while(!ANY_KEY_DOWN)
{
//press key to advance
}
fillScreen(BLACK);
waitForVblank();
drawRect(GAME_WIDTH, 0, SCREEN_WIDTH - GAME_WIDTH, SCREEN_HEIGHT, RGB(6, 0, 6));
instantiateBrickArray();
drawString(205, 20, "Lives", WHITE);
drawString(215, 35, livesString, WHITE);
drawString(202, 60, "Bricks", WHITE);
drawString(208, 70, "left", WHITE);
drawString(215, 85, bricksString, WHITE);
while(lives > 0 && bricksLeft > 0)
{
updatePositions();
drawEverything();
}
if (bricksLeft <= 0)
{
drawBackground3(win);
}
else
{
drawBackground3(lose);
}
while(TRUE)
{
//do nothing
}
}
开发者ID:ClysmiC,项目名称:breakout_gba,代码行数:63,代码来源:main.c
示例11: beginSprite
/**
* CBitmapFont::drawStringView
* @date Modified Apr 04, 2006
*/
void CBitmapFont::drawStringView(CString str, RECT rView, unsigned int unOffset, D3DCOLOR dwColor, bool bHandleSprite)
{
std::vector<CString> vLines, vWords, vColors;
unsigned int unWidth = rView.right - rView.left,
unHeight = rView.bottom - rView.top,
unWordWidth = 0;
RECT rWord;
float fX = (float)rView.left, fY = (float)rView.top;
str.ToList(vLines, "\r\n");
if(bHandleSprite)
beginSprite();
// Calculate max number of lines
unsigned int unLineCount = unHeight / m_cLineHeight;
// Iterate lines in string.
size_t i = ((vLines.size() <= unLineCount) ? 0 : max(vLines.size() - unOffset - unLineCount, 0));
for(; i < ((vLines.size() <= unLineCount) ? vLines.size() : vLines.size() - unOffset); ++i)
{
// Iterate words in string.
vLines[i].ToList(vWords, " ");
for(size_t j = 0; j < vWords.size(); ++j)
{
bool bFirst = false;
vWords[j].ToList(vColors, "{}");
if(vWords[j].GetChar(0) == '{')
bFirst = true;
if(vColors.size())
{
for(size_t k = 0; k < vColors.size(); ++k)
{
if((bFirst && k % 2 == 0) || (!bFirst && k % 2 == 1))
{
dwColor = vColors[k].ToUlongFromHex();
continue;
}
// Take line length into consideration
unWordWidth = measureString(vColors[k], &rWord);
if(fX + unWordWidth >= unWidth)
{
fX = (float)rView.left;
fY += m_cLineHeight;
drawString(vColors[k], fX, fY, dwColor, false);
}
else
{
drawString(vColors[k], fX, fY, dwColor, false);
fX += unWordWidth + m_mCharMap[' '];
}
}
}
else
{
// Take line length into consideration
unWordWidth = measureString(vWords[j], &rWord);
if(fX + unWordWidth >= unWidth)
{
fX = (float)rView.left;
fY += m_cLineHeight;
drawString(vWords[j], fX, fY, dwColor, false);
}
else
{
drawString(vWords[j], fX, fY, dwColor, false);
fX += unWordWidth + m_mCharMap[' '];
}
}
}
fX = (float)rView.left;
fY += m_cLineHeight;
}
if(bHandleSprite)
endSprite();
}
开发者ID:mattrudder,项目名称:AckZombies,代码行数:83,代码来源:BitmapFont.cpp
示例12: updatePositions
void updatePositions()
{
oldPaddle = paddle;
oldBall = ball;
if (KEY_DOWN_NOW(BUTTON_RIGHT))
{
paddle.x = min(paddle.x + PADDLE_SPEED, GAME_WIDTH - PADDLE_WIDTH);
if (ball.onPaddle)
ball.x = paddle.x + PADDLE_WIDTH / 2;
}
if (KEY_DOWN_NOW(BUTTON_LEFT))
{
paddle.x = max(paddle.x - PADDLE_SPEED, 0);
if (ball.onPaddle)
ball.x = paddle.x + PADDLE_WIDTH / 2;
}
//release ball from paddle
if (ball.onPaddle && KEY_DOWN_NOW(BUTTON_A))
{
ball.onPaddle = FALSE;
ball.xspeed = 1;
ball.yspeed = -3;
ball.y -= 1; //give it one pixel of space so it doesn't "collide" with paddle right away
}
//--------------------------CHECK FOR COLLISIONS-------------------------------//
//check collision with right boundary
if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, GAME_WIDTH, 0, GAME_WIDTH + 10, GAME_HEIGHT))
{
ball.xspeed = -ball.xspeed;
ball.x -= 2;
}
//check collision with top boundary
if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, 0, -10, GAME_WIDTH, 0))
{
ball.yspeed = -ball.yspeed;
ball.y += 2;
}
//check collision with left boundary
if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, -10, 0, 0, GAME_HEIGHT))
{
ball.xspeed = -ball.xspeed;
ball.x += 2;
}
//check collision with bricks
for (int i = 0; i < NUM_OF_BRICKS; i++)
{
if (brickArray[i].health && collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, brickArray[i].x, brickArray[i].y,
brickArray[i].x + BRICK_WIDTH, brickArray[i].y + BRICK_HEIGHT))
{
int ballxmid = ball.x + BALL_SIZE/2;
int ballymid = ball.y + BALL_SIZE/2;
int brickxmid = brickArray[i].x + BRICK_WIDTH/2;
int brickymid = brickArray[i].y + BRICK_HEIGHT/2;
//slope of the vector pointing from the ball to the brick
int deltax = brickxmid - ballxmid;
int deltay = brickymid - ballymid;
//below or above brick
if (abs(deltax) < 2 * abs(deltay) + 2) // abs(dy/dx) > 1/2 (visual->) \_____/
{
ball.yspeed = -ball.yspeed;
ball.y += signOf(ball.yspeed) * 2; //"push it out of brick just a bit"
}
//side of brick
else
{
ball.xspeed = -ball.xspeed;
ball.x += signOf(ball.xspeed) * 2; //"push it out of brick just a bit"
}
brickArray[i].health -= 1;
if (!brickArray[i].health)
{
//draw part of the background image that was previously hidden
drawImageExt3(brickArray[i].x, brickArray[i].y, brickArray[i].x, brickArray[i].y, BRICK_WIDTH, BRICK_HEIGHT, gtech);
bricksLeft --;
sprintf(bricksString, "%d", bricksLeft); //store lives as a string
waitForVblank();
drawRect(215, 85, 12, 8, RGB(6, 0, 6));
drawString(215, 85, bricksString, WHITE);
}
}
}
//.........这里部分代码省略.........
开发者ID:ClysmiC,项目名称:breakout_gba,代码行数:101,代码来源:main.c
示例13: getWindowPos
void
Hud::Rebuild(int width, int height)
{
_requiresRebuildStatic = false;
_windowWidth = width;
_windowHeight = height;
_staticVboSource.clear();
int x, y;
// add UI elements
for (std::vector<Item>::const_iterator it = _labels.begin();
it != _labels.end(); ++it) {
getWindowPos(*it, &x, &y);
drawString(_staticVboSource, x, y, 1, 1, 1, it->label.c_str());
}
for (std::vector<RadioButton>::const_iterator it = _radioButtons.begin();
it != _radioButtons.end(); ++it) {
getWindowPos(*it, &x, &y);
if (it->checked) {
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_RADIO_BUTTON_ON);
drawString(_staticVboSource, x, y, 1, 1, 0, it->label.c_str());
} else {
x = drawChar(_staticVboSource, x, y, 1, 1, 1, ' ');
drawString(_staticVboSource, x, y, .5f, .5f, .5f, it->label.c_str());
}
}
for (std::vector<CheckBox>::const_iterator it = _checkBoxes.begin();
it != _checkBoxes.end(); ++it) {
getWindowPos(*it, &x, &y);
if (it->checked) {
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_CHECK_BOX_ON);
drawString(_staticVboSource, x, y, 1, 1, 0, it->label.c_str());
} else {
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_CHECK_BOX_OFF);
drawString(_staticVboSource, x, y, .5f, .5f, .5f, it->label.c_str());
}
}
for (std::vector<Slider>::const_iterator it = _sliders.begin();
it != _sliders.end(); ++it) {
getWindowPos(*it, &x, &y);
int sx = x;
x = drawString(_staticVboSource, x, y, 1, 1, 1, it->label.c_str());
char value[16];
snprintf(value, 16, " : %.2f", it->value);
drawString(_staticVboSource, x, y, 1, 1, 1, value);
// new line
y += FONT_CHAR_HEIGHT;
x = sx;
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_LEFT);
int nw = it->w / FONT_CHAR_WIDTH;
for (int i = 1; i < nw; ++i) {
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_MIDDLE);
}
drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_RIGHT);
int pos = (int)((it->value/float(it->max-it->min))*it->w);
drawChar(_staticVboSource, sx+pos, y, 1, 1, 0, FONT_SLIDER_CURSOR);
}
drawString(_staticVboSource, _windowWidth-80, _windowHeight-48, .5, .5, .5,
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f");
drawString(_staticVboSource, _windowWidth-80, _windowHeight-32, .5, .5, .5,
"\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f");
}
开发者ID:njlitke,项目名称:OpenSubdiv,代码行数:67,代码来源:hud.cpp
示例14: configureCFW
void configureCFW(const char *configPath, const char *firm90Path){
initScreens();
drawString(CONFIG_TITLE, 10, 10, COLOR_TITLE);
drawString("Press A to select, START to save and reboot", 10, 30, COLOR_WHITE);
const char *optionsText[] = { "( ) Updated SysNAND mode (A9LH-only)",
"( ) Use pre-patched FIRMs",
"( ) Force A9LH detection",
"( ) Use 9.0 FIRM as default",
"( ) Use second EmuNAND as default",
"( ) Show current NAND in System Settings" };
u32 optionsAmount = sizeof(optionsText) / sizeof(char *);
struct option options[optionsAmount];
//Read and parse the existing configuration
u32 tempConfig = 0;
fileRead(&tempConfig, configPath, 3);
for(u32 i = 0; i < optionsAmount; i++)
options[i].enabled = (tempConfig >> i) & 0x1;
//Pre-select the first configuration option
u32 selectedOption = 0;
//Boring configuration menu
while(1){
u16 pressed = 0;
do{
for(u32 i = 0; i < optionsAmount; i++){
options[i].posY = drawString(optionsText[i], 10, !i ? 60 : options[i - 1].posY + SPACING_Y, selectedOption == i ? COLOR_RED : COLOR_WHITE);
drawCharacter('x', 10 + SPACING_X, options[i].posY, options[i].enabled ? (selectedOption == i ? COLOR_RED : COLOR_WHITE) : COLOR_BLACK);
}
pressed = waitInput();
} while(!(pressed & MENU_BUTTONS));
switch(pressed){
case BUTTON_UP:
selectedOption = !selectedOption ? optionsAmount - 1 : selectedOption - 1;
break;
case BUTTON_DOWN:
selectedOption = selectedOption == optionsAmount - 1 ? 0 : selectedOption + 1;
break;
case BUTTON_LEFT:
selectedOption = 0;
break;
case BUTTON_RIGHT:
selectedOption = optionsAmount - 1;
break;
case BUTTON_A:
options[selectedOption].enabled = !options[selectedOption].enabled;
break;
}
if(pressed == BUTTON_START) break;
}
//If the user has been using A9LH and the "Updated SysNAND" setting changed, delete the patched 9.0 FIRM
if(((tempConfig >> 16) & 0x1) && ((tempConfig & 0x1) != options[0].enabled))
fileDelete(firm90Path);
//Preserve the last-used boot options (last 12 bits)
tempConfig &= 0xFFF000;
//Parse and write the selected options
for(u32 i = 0; i < optionsAmount; i++)
tempConfig |= options[i].enabled << i;
fileWrite(&tempConfig, configPath, 3);
//Zero the last booted FIRM flag
CFG_BOOTENV = 0;
//Reboot
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2);
while(1);
}
开发者ID:KaFOFO,项目名称:AuReiNand,代码行数:77,代码来源:utils.c
示例15: color565
void StatusScreen::render()
{
uint16_t stacolor = color565(51,153,204); //blue
fillScreen(stacolor);
makeRectangle(5,5, 225,310, BLACK, 4);
char* status = "STATUS";
drawString(225,50 , status, BLACK, stacolor, 2);
makeRectangle(85,15, 135, 300, BLACK, 3);
makeRectangle(15,15, 75, 300, BLACK, 3);
drawString(210, 20, "Adapters", BLACK, stacolor, 2);
drawString(85, 20, "Sensors ", BLACK, stacolor, 2);
makeRectangle(100,50, 50,45, BLUE, 3);
makeRectangle(100,95, 50,45, BLUE, 3);
makeRectangle(100,180, 50,45, BLUE, 3);
makeRectangle(100,225, 50,45, BLUE, 3);
makeRectangle(155,50, 50,45, BLUE, 3);
makeRectangle(155,95, 50,45, BLUE, 3);
makeRectangle(155,180, 50,45, BLUE, 3);
makeRectangle(155,225, 50,45, BLUE, 3);
drawString(120, 58, "-3-", BLACK, stacolor,2);
drawString(120, 188, "-4-", BLACK, stacolor, 2);
drawString(178, 58, "-1-", BLACK, stacolor, 2);
drawString(178, 188, "-2-", BLACK, stacolor, 2);
drawString(120, 113, "ON", BLACK, stacolor,2);
drawString(120, 233, "OFF", BLACK, stacolor, 2);
drawString(178 , 102, "AUT", BLACK, stacolor, 2);
drawString(178, 233, "OFF", BLACK, stacolor, 2);
drawString(20, 30 , "2. ", BLACK, stacolor, 2);
drawString(50, 30, "1. ", BLACK, stacolor, 2);
drawString(20, 55, "ENABLED", BLACK, stacolor, 2);
drawString(50, 55, "DISABLED", BLACK, stacolor, 2);
}
开发者ID:unregistered,项目名称:lg-activate,代码行数:36,代码来源:lgui.c
示例16: strlen
void ONScripterLabel::setupAnimationInfo( AnimationInfo *anim, FontInfo *info )
{
anim->deleteSurface();
anim->abs_flag = true;
if ( anim->trans_mode == AnimationInfo::TRANS_STRING ){
FontInfo f_info = sentence_font;
if (info) f_info = *info;
if ( anim->font_size_xy[0] >= 0 ){ // in case of Sprite, not rclick menu
f_info.setTateyokoMode(0);
f_info.top_xy[0] = anim->pos.x * screen_ratio2 / screen_ratio1;
f_info.top_xy[1] = anim->pos.y * screen_ratio2 / screen_ratio1;
if (anim->is_single_line)
f_info.setLineArea( strlen(anim->file_name)/2+1 );
f_info.clear();
f_info.pitch_xy[0] = f_info.pitch_xy[0] - f_info.font_size_xy[0] + anim->font_size_xy[0];
f_info.font_size_xy[0] = anim->font_size_xy[0];
f_info.pitch_xy[1] = f_info.pitch_xy[1] - f_info.font_size_xy[1] + anim->font_size_xy[1];
f_info.font_size_xy[1] = anim->font_size_xy[1];
if ( anim->font_pitch >= 0 )
f_info.pitch_xy[0] = anim->font_pitch;
f_info.ttf_font = NULL;
}
SDL_Rect pos;
if (anim->is_tight_region){
drawString( anim->file_name, anim->color_list[ anim->current_cell ], &f_info, false, NULL, &pos );
}
else{
int xy_bak[2];
xy_bak[0] = f_info.xy[0];
xy_bak[1] = f_info.xy[1];
int xy[2] = {0, 0};
f_info.setXY(f_info.num_xy[0], f_info.num_xy[1]);
pos = f_info.calcUpdatedArea(xy, screen_ratio1, screen_ratio2);
f_info.xy[0] = xy_bak[0];
f_info.xy[1] = xy_bak[1];
}
if (info != NULL){
info->xy[0] = f_info.xy[0];
info->xy[1] = f_info.xy[1];
}
anim->allocImage( pos.w*anim->num_of_cells, pos.h );
anim->fill( 0, 0, 0, 0 );
f_info.setRubyOnFlag(anim->is_ruby_drawable);
f_info.top_xy[0] = f_info.top_xy[1] = 0;
for ( int i=0 ; i<anim->num_of_cells ; i++ ){
f_info.clear();
drawString( anim->file_name, anim->color_list[i], &f_info, false, NULL, NULL, anim );
f_info.top_xy[0] += anim->pos.w * screen_ratio2 / screen_ratio1;
}
}
else{
bool has_alpha;
SDL_Surface *surface = loadImage( anim->file_name, &has_alpha );
SDL_Surface *surface_m = NULL;
if (anim->trans_mode == AnimationInfo::TRANS_MASK)
surface_m = loadImage( anim->mask_file_name );
anim->setupImage(surface, surface_m, has_alpha);
if ( surface ) SDL_FreeSurface(surface);
if ( surface_m ) SDL_FreeSurface(surface_m);
}
}
开发者ID:nuo0024,项目名称:onscripter-zh,代码行数:73,代码来源:ONScripterLabel_animation.cpp
示例17: game
int game(int seed)
{
REG_DISPCTL = MODE3 | BG2_ENABLE;
int live = 5;
char buffer[41];
int speed = 1;
int num = 100;
int objx = 70;
int objy = 50;
drawPicture(black);
WALL wall0;
wall0.i = 80;
wall0.gate = 90;
wall0.gateSize = 10;
wall0.color = WHITE;
WALL wall1;
wall1.i = 100;
wall1.gate = 90;
wall1.gateSize = 10;
wall1.color = MAGENTA;
WALL wall2;
wall2.i = 120;
wall2.gate = 30;
wall2.gateSize = 30;
wall2.color = RED;
WALL wall3;
wall3.i = 140;
wall3.gate = 150;
wall3.gateSize = 30;
wall3.color = BLUE;
WALL wall4;
wall4.i = 160;
wall4.gate = 0;
wall4.gateSize = 20;
wall4.color = GREEN;
WALL wall5;
wall5.i = 180;
wall5.gate = 130;
wall5.gateSize = 20;
wall5.color = BLUE;
WALL wall6;
wall6.i = 200;
wall6.gate = 130;
wall6.gateSize = 15;
wall6.color = CYAN;
// Game Loop
while(1)
{
int oldx = objx;
int oldy = objy;
drawRect(oldx,oldy,1,1, BLACK);
if(KEY_DOWN_NOW(BUTTON_SELECT))
{
objx = 70;
objy = 50;
live = 5;
drawRect(150,0,60,30,BLACK);
drawString(150, 0, "Score: 0", YELLOW);
}
if(KEY_DOWN_NOW(BUTTON_UP))
{
objx-=speed;
if(objx < 0)
{
objx = 0;
}
}
if(KEY_DOWN_NOW(BUTTON_DOWN))
{
objx+=speed;
if(objx > 159)
{
objx = 159;
}
}
if(KEY_DOWN_NOW(BUTTON_A))
{
speed = 2;
//.........这里部分代码省略.........
开发者ID:chongwenguo,项目名称:gba-game-DMA-version,代码行数:101,代码来源:main.c
示例18: main
int main()
{
REG_DISPCTL = MODE3 | BG2_ENABLE;
reset();
while(1) {
waitForVblank();
switch (state) {
case START:
drawImage3(0, 0, 240, 160, StartScreen); //The start screen
state = READY;
break;
case READY:
if (KEY_DOWN_NOW(BUTTON_B)) {
drawBg();
state = PLAY;
}
break;
case PLAY:
if(KEY_DOWN_NOW(BUTTON_A)) {
reset();
}
eraseImage3(150, 0, 240, 10);
sprintf(buffer, "%d bugs left", bugsNum);
drawString(150, 0, buffer, red);
sprintf(buffer, "%d lives left", lives);
drawString(150, 100, buffer, red);
sprintf(buffer, "level %d", level);
drawString(150, 190, buffer, red);
updateShip(&ship);
updateBugs(bugs, &ship, &state);
if (bugsNum == 0 && lives > 0) {
state = WON;
}
break;
case WON:
if (level == 1) {
drawString(100, 10, "Almost there! Press enter to continue!", red);
if(KEY_DOWN_NOW(BUTTON_A)) {
reset();
}
if (KEY_DOWN_NOW(BUTTON_START)) {
level++;
drawBg();
setShip(&ship);
setBugs(bugs);
state = PLAY;
}
} else {
drawImage3(0, 0, 240, 160, Win);
if (KEY_DOWN_NOW(BUTTON_START) || KEY_DOWN_NOW(BUTTON_A)) {
reset();
}
}
break;
case DIE:
drawBg();
sprintf(buffer, "%d lives left", lives);
drawString(50, 75, buffer, red);
if(KEY_DOWN_NOW(BUTTON_A)) {
reset();
}
if (KEY_DOWN_NOW(BUTTON_START)) {
drawBg();
state = PLAY;
ship.x = START_X;
ship.y = START_Y;
for (int i = 0; i < bugsNum; i++) {
bugs[i].y = bugs[i].startY;
bugs[i].charge = 0;
}
}
break;
case LOSE:
drawImage3(0, 0, 240, 160, Ending);
if(KEY_DOWN_NOW(BUTTON_A)) {
reset();
}
if (KEY_DOWN_NOW(BUTTON_START)) {
reset();
}
break;
}
}
return 0;
}
开发者ID:JiazhengSun,项目名称:MyFirstGBAGame,代码行数:85,代码来源:main.c
示例19: drawString2
void drawString2(float x, float y, std::string text) {
drawString(x, y, text.c_str());
}
开发者ID:kartoFlane,项目名称:FTLAPI,代码行数:3,代码来源:TextHelper.cpp
示例20: while
void Engine::showInventory()
{
bool quit = false;
int selecteditem = 0;
std::vector< Item*> *inv = m_Player->getInventory();
while(!quit)
{
m_Screen->clear();
sf::Event event;
while(m_Screen->pollEvent(event))
{
if(event.type == sf::Event::KeyPressed)
{
if(event.key.code == sf::Keyboard::Escape) quit = true;
else if(event.key.code == sf::Keyboard::Down) selecteditem++;
else if(event.key.code == sf::Keyboard::Up) selecteditem--;
else if(event.key.code == sf::Keyboard::Return)
{
//if using liquid container
if( (*inv)[selecteditem]->getType() == OBJ_ITEM_CONTAINER_LIQUID)
{
ContainerLiquid *cptr = dynamic_cast<ContainerLiquid*>( (*inv)[selecteditem]);
//if liquid container is not empty
if(!cptr->isEmpty() )
{
if(m_Player->drink(cptr->getLiquidType()))
{
cptr->removeLiquid(1);
}
}
}
}
}
}
if(selecteditem < 0) selecteditem = int(inv->size()-1);
else if(selecteditem >= int(inv->size())) selecteditem = 0;
//draw
if(inv->empty())
{
drawString(0,0,"You have nothing!\n");
}
else
{
drawString(0,0, "You are carrying:");
drawString(0,1, "-----------------");
for(int i = 0; i < int(inv->size()); i++)
{
std::stringstream istring;
istring << (*inv)[i]->getName();
//if item is a container
if( (*inv)[i]->getType() == OBJ_ITEM_CONTAINER)
{
//get container pointer
Container *cptr = NULL;
cptr = dynamic_cast<Container*>((*inv)[i]);
//if container is empty
if(cptr->getInventory()->empty()) istring << " (empty)";
}
else if( (*inv)[i]->getType() == OBJ_ITEM_CONTAINER_LIQUID)
{
ContainerLiquid *cptr = dynamic_cast<ContainerLiquid*>( (*inv)[i]);
if(cptr->getCurrentVolume() <= 0) istring << " (empty)";
else
{
istring << " (" << cptr->getCurrentVolume() << "/" << cptr->getMaxVolume() << " of " << cptr->getLiquidType()->getName() << ")";
}
}
if(selecteditem == i)
{
drawString(0, i+2, istring.str(), COLOR_BLACK, COLOR_WHITE);
}
else drawString(0, i+2, istring.str());
}
}
//update
m_Screen->display();
}
}
开发者ID:jastadj,项目名称:johnrl,代码行数:97,代码来源:engine.cpp
注:本文中的drawString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论