本文整理汇总了C++中LTexture::render方法的典型用法代码示例。如果您正苦于以下问题:C++ LTexture::render方法的具体用法?C++ LTexture::render怎么用?C++ LTexture::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LTexture
的用法示例。
在下文中一共展示了LTexture::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void LButton::render()
{
//Show current button sprite
gButtonSpriteSheetTexture.render( mPosition.x, mPosition.y, &gSpriteClips[ mCurrentSprite ] );
gButtonSpriteSheetTexture1.render( mPosition.x, mPosition.y, &gSpriteClips[ mCurrentSprite ] );
gButtonSpriteSheetTexture2.render( mPosition.x, mPosition.y, &gSpriteClips[ mCurrentSprite ] );
}
示例2: main
int main( int argc, char* args[] )
{
//Start up SDL and create window
if( !init() )
{
printf( "Failed to initialize!\n" );
}
else
{
//Load media
if( !loadMedia() )
{
printf( "Failed to load media!\n" );
}
else
{
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//While application is running
while( !quit )
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
}
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render background texture to screen
gBackgroundTexture.render( 0, 0 );
//Render Foo' to the screen
gFooTexture.render( 240, 190 );
//Update screen
SDL_RenderPresent( gRenderer );
}
}
}
//Free resources and close SDL
close();
return 0;
}
示例3: render
void Particle::render() {
//Show image
mTexture->render( mPosX, mPosY );
//Show shimmer
if( mFrame % 2 == 0 ) {
gShimmerTexture.render( mPosX, mPosY );
}
//Animate
mFrame++;
}
示例4: main
int main(int argc, const char * argv[]) {
init();
loadMedia();
bool quit = false;
SDL_Event e;
int frame = 0;
int scrollingOffset = gameState.scrollingOffset;
while (!quit) {
while (SDL_PollEvent(&e) != 0) {
if (e.type == SDL_QUIT) {
quit = true;
}
batman->handleEvent(e);
}
SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
SDL_RenderClear(gRenderer);
// load background first with offset
if (batman->isMovingFwd()) {
-- scrollingOffset;
if (scrollingOffset < -gBackGroundTexture.getWidth()) {
scrollingOffset = 0;
}
}
gBackGroundTexture.render(scrollingOffset, 0, gRenderer);
gBackGroundTexture.render(scrollingOffset + gBackGroundTexture.getWidth(), 0, gRenderer);
batman->render(50, SCREEN_HEIGHT - 60);
SDL_RenderPresent(gRenderer);
}
// save game state
gameState.scrollingOffset = scrollingOffset;
printf("saving game state: scrolling offset %d\n", gameState.scrollingOffset);
// close
close();
return 0;
}
示例5: main
int main( int argc, char* args[] )
{
//Start up SDL and create window
if( !init() )
{
printf( "Failed to initialize!\n" );
}
else
{
//Load media
if( !loadMedia() )
{
printf( "Failed to load media!\n" );
}
else
{
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//Run the thread
int data = 101;
SDL_Thread* threadID = SDL_CreateThread( threadFunction, "LazyThread", (void*)data );
//While application is running
while( !quit )
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
}
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render prompt
gSplashTexture.render( 0, 0 );
//Update screen
SDL_RenderPresent( gRenderer );
}
//Remove timer in case the call back was not called
SDL_WaitThread( threadID, NULL );
}
}
//Free resources and close SDL
close();
return 0;
}
示例6: main
int main( int argc, char* args[] ) {
//Start up SDL and create window
if( !init() ) {
printf( "Failed to initialize!\n" );
} else {
//Load media
if( !loadMedia() ) {
printf( "Failed to load media!\n" );
} else {
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//Current rendered texture
LTexture* currentTexture = NULL;
//While application is running
while( !quit ) {
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 ) {
//User requests quit
if( e.type == SDL_QUIT ) {
quit = true;
}
}
//Set texture based on current keystate
const Uint8* currentKeyStates = SDL_GetKeyboardState( NULL );
if( currentKeyStates[ SDL_SCANCODE_UP ] ) {
currentTexture = &gUpTexture;
} else if( currentKeyStates[ SDL_SCANCODE_DOWN ] ) {
currentTexture = &gDownTexture;
} else if( currentKeyStates[ SDL_SCANCODE_LEFT ] ) {
currentTexture = &gLeftTexture;
} else if( currentKeyStates[ SDL_SCANCODE_RIGHT ] ) {
currentTexture = &gRightTexture;
} else {
currentTexture = &gPressTexture;
}
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render current texture
currentTexture->render( 0, 0 );
//Update screen
SDL_RenderPresent( gRenderer );
}
}
}
//Free resources and close SDL
close();
return 0;
}
示例7: render
void render()
{
GLfloat half_width = SCREEN_WIDTH / 2.f;
GLfloat half_height = SCREEN_HEIGHT / 2.f;
//Clear color buffer
glClear( GL_COLOR_BUFFER_BIT );
//Reset transformations
glLoadIdentity();
//Screen quad fills render surface
glTranslatef( half_width, half_height, 0.0 );
glBegin( GL_QUADS );
glColor3f( 1.f, 1.f, 1.f );
glVertex2f( -half_width, -half_height );
glVertex2f( half_width, -half_height );
glVertex2f( half_width, half_height );
glVertex2f( -half_width, half_height );
glEnd();
//Render the texture
gOpenGLTexture.render( 0.0, 0.0 );
//Update screen
glutSwapBuffers();
}
示例8: main
int main( int argc, char* args[] )
{
//Start up SDL and create window
if( !init() )
{
printf( "Failed to initialize!\n" );
}
else
{
//Load media
if( !loadMedia() )
{
printf( "Failed to load media!\n" );
}
else
{
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//While application is running
while( !quit )
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
//Handle window events
gWindow.handleEvent( e );
}
//Only draw when not minimized
if( !gWindow.isMinimized() )
{
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render text textures
gSceneTexture.render( ( gWindow.getWidth() - gSceneTexture.getWidth() ) / 2, ( gWindow.getHeight() - gSceneTexture.getHeight() ) / 2 );
//Update screen
SDL_RenderPresent( gRenderer );
}
}
}
}
//Free resources and close SDL
close();
return 0;
}
示例9: render
void Tile::render( SDL_Rect& camera )
{
//If the tile is on screen
if( checkCollision( camera, mBox ) )
{
//Show the tile
gTileTexture.render( mBox.x - camera.x, mBox.y - camera.y, &gTileClips[ mType ] );
}
}
示例10: render
void Scoreboard::render( SDL_Renderer* gRenderer, TTF_Font* gFont, LTexture gTextTexture ) {
string s = std::to_string( static_cast<long long>( score ) );
s = string( 10 - s.size(), ' ' ) + s;
string text = "Score: " + s;
gTextTexture.loadFromRenderedText( text, textColor );
gTextTexture.setBlendMode( SDL_BLENDMODE_BLEND );
gTextTexture.setAlpha( 150 );
gTextTexture.render( xPos, yPos, gRenderer );
}
示例11: IntroRender
bool IntroRender (int x, int y)
{
//Event handler
SDL_Event e;
LTexture texture;
std::string counter="";
for (int i=0; i<1502; i+=2)
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0, 0, 0, 0 );
SDL_RenderClear( gRenderer );
//User requests quit
if( e.type == SDL_QUIT )
{
return false;
}
}
bool quit=false;
counter+="IntroPics/Intro";
counter+=IntToString(i+1);
counter+=".jpg";
Intro [i]=texture.loadFromFile( counter.c_str(),gScreenRect.w, gScreenRect.h);
gSplashTexture.render(x, y,Intro[i],IntroW, IntroH);
//Update screen
SDL_RenderPresent( gRenderer );
if (Intro [i]!=NULL)
{
SDL_DestroyTexture( Intro [i] );
Intro [i] = NULL;
};
printf(counter.c_str());
counter="";
SDL_Delay(10);
}
// //Render splash
// for (int i=0 ; i<1410; i++)
//
// {
// if (Intro [i]!=NULL)
//
// {
// SDL_DestroyTexture( Intro [i] );
// Intro [i] = NULL;
// };
// if (i<910)
// Intro [i+500]=texture.loadFromFile( counter.c_str(),gScreenRect.w, gScreenRect.h);
// }
return true;
}
示例12: main
int main( int argc, char* args[] ) {
//Start up SDL and create window
if( !init() ) {
printf( "Failed to initialize!\n" );
} else {
//Load media
if( !loadMedia() ) {
printf( "Failed to load media!\n" );
} else {
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//Current animation frame
int frame = 0;
//While application is running
while( !quit ) {
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 ) {
//User requests quit
if( e.type == SDL_QUIT ) {
quit = true;
}
}
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render current frame
SDL_Rect* currentClip = &gSpriteClips[ frame / 4 ];
gSpriteSheetTexture.render( ( SCREEN_WIDTH - currentClip->w ) / 2, ( SCREEN_HEIGHT - currentClip->h ) / 2, currentClip );
//Update screen
SDL_RenderPresent( gRenderer );
//Go to next frame
++frame;
//Cycle animation
if( frame / 4 >= WALKING_ANIMATION_FRAMES ) {
frame = 0;
}
}
}
}
//Free resources and close SDL
close();
return 0;
}
示例13: render
void render()
{
//Clear color buffer
glClear( GL_COLOR_BUFFER_BIT );
//Initialize modelview matrix
glLoadIdentity();
//Render textured quad using VBOs
gVBOTexture.render( ( SCREEN_WIDTH - gVBOTexture.imageWidth() ) / 2.f, ( SCREEN_HEIGHT - gVBOTexture.imageHeight() ) / 2.f );
}
示例14: render
void render()
{
//Clear color buffer
glClear( GL_COLOR_BUFFER_BIT );
//Render texture stretched
gStretchedTexture.render( 0.f, 0.f, NULL, &gStretchRect );
//Update screen
glutSwapBuffers();
}
示例15: main
int main( int argc, char* args[] )
{
//Start up SDL and create window
if( !init() )
{
printf( "Failed to initialize!\n" );
}
else
{
//Load media
if( !loadMedia() )
{
printf( "Failed to load media!\n" );
}
else
{
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//While application is running
while( !quit )
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
}
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render current frame
gTextTexture.render( ( SCREEN_WIDTH - gTextTexture.getWidth() ) / 2, ( SCREEN_HEIGHT - gTextTexture.getHeight() ) / 2 );
//Update screen
SDL_RenderPresent( gRenderer );
}
}
}
//Free resources and close SDL
close();
return 0;
}