本文整理汇总了C++中SDL_GetVideoSurface函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_GetVideoSurface函数的具体用法?C++ SDL_GetVideoSurface怎么用?C++ SDL_GetVideoSurface使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_GetVideoSurface函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_GetVideoSurface
Game::Game()
{
gui.reset(loadGUIFile("gui/app.xml"));
gui->resize(SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h);
Button* gameMenu = getButton( *gui, "GameMenuButton" );
gameMenu->clicked.connect( makeCallback(*this, &Game::gameButtonClicked ));
Button* helpButton = getButton( *gui, "HelpButton" );
helpButton->clicked.connect( makeCallback(*this, &Game::gameButtonClicked ));
Button* statButton = getButton( *gui, "StatButton" );
statButton->clicked.connect( makeCallback(*this, &Game::gameButtonClicked ));
Desktop* desktop = dynamic_cast<Desktop*> (gui.get());
if(desktop == 0)
throw std::runtime_error("Game UI is not a Desktop Component");
helpWindow.reset(new HelpWindow(desktop));
gameptr = this;
}
示例2: catch
surface& surface::get_video_surface() {
bool init=false;
try {
main_surface.get_low();
} catch (sdlw::exception_sdl&) {
init=true;
}
if(init)
main_surface.build(SDL_GetVideoSurface(),false);
return main_surface;
}
示例3: SetPalette
void SetPalette()
{
SDL_Color clColor;
for (int i=0;i<16;i++)
{
clColor.r=(ColorMap[i]&0xFF0000)>>16;
clColor.g=(ColorMap[i]&0xFF00)>>8;
clColor.b=ColorMap[i]&0xFF;
SDL_SetColors(SDL_GetVideoSurface(), &clColor, i, 1);
}
}
示例4: glMatrixMode
void HUD_Lua_Class::end_draw(void)
{
m_drawing = false;
#ifdef HAVE_OPENGL
if (m_opengl)
{
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
}
else
#endif
if (m_surface)
{
// SDL_BlitSurface(m_surface, NULL, SDL_GetVideoSurface(), NULL);
SDL_SetAlpha(SDL_GetVideoSurface(), 0, 0xff);
SDL_SetClipRect(SDL_GetVideoSurface(), 0);
}
}
示例5: SDLX_Get_Screen_Info
//--------------------------------------------------------------------------------------------
SDL_bool SDLX_Get_Screen_Info( SDLX_screen_info_t * psi, SDL_bool make_report )
{
Uint32 init_flags = 0;
SDL_Surface * ps;
const SDL_VideoInfo * pvi;
memset( psi, 0, sizeof( *psi ) );
init_flags = SDL_WasInit( SDL_INIT_EVERYTHING );
if ( 0 == init_flags )
{
if ( make_report ) fprintf( LOCAL_STDOUT, "ERROR: SDLX_Get_Screen_Info() called before initializing SDL\n" );
return SDL_FALSE;
}
else if ( HAS_NO_BITS( init_flags, SDL_INIT_VIDEO ) )
{
if ( make_report ) fprintf( LOCAL_STDOUT, "ERROR: SDLX_Get_Screen_Info() called before initializing SDL video driver\n" );
return SDL_FALSE;
}
ps = SDL_GetVideoSurface();
pvi = SDL_GetVideoInfo();
// store the screen info for everyone to use
psi->pscreen = ps;
psi->d = ps->format->BitsPerPixel;
psi->x = ps->w;
psi->y = ps->h;
// Grab all the available video modes
psi->video_mode_list = SDL_ListModes( ps->format, ps->flags | SDL_FULLSCREEN );
// log the video driver info
SDL_VideoDriverName( psi->szDriver, sizeof( psi->szDriver ) );
// grab all SDL_GL_* attributes
SDLX_read_sdl_gl_attrib( &( psi->gl_att ) );
// translate the surface flags into the bitfield
SDLX_download_sdl_video_flags( ps->flags, &( psi->flags ) );
psi->hw_available = pvi->hw_available;
psi->wm_available = pvi->wm_available;
psi->blit_hw = pvi->blit_hw;
psi->blit_hw_CC = pvi->blit_hw_CC;
psi->blit_hw_A = pvi->blit_hw_A;
psi->blit_sw = pvi->blit_sw;
psi->blit_sw_CC = pvi->blit_sw_CC;
psi->blit_sw_A = pvi->blit_sw_A;
if ( make_report ) SDLX_Report_Screen_Info( psi );
return SDL_TRUE;
}
示例6: SDL_FillRect
static void OPTIONS_Draw (const char* aDescription, OPTIONS_Draw_GetString aCallback, uint32_t aSelected)
{
SDL_Surface* text;
int32_t index = 0;
SDL_Color c_active = {0xFF, 0xFF, 0xFF, 0xFF}, c_inactive = {0x50, 0x50, 0x50, 0xFF}, bg = {0, 32, 64, 0};
SDL_Rect DrawPosition = {10, 50, 0, 0};
/* Clear the screen */
SDL_FillRect(SDL_GetVideoSurface(), 0, SDL_MapRGB(SDL_GetVideoSurface()->format, 0, 32, 64));
/* Draw the description */
if(aDescription)
{
SDL_Rect descposition = {10, 10, 0, 0};
text = STRING_Render(aDescription, c_active, bg);
SDL_BlitSurface(text, 0, SDL_GetVideoSurface(), &descposition);
SDL_FreeSurface(text);
}
/* Draw the strings */
while(1)
{
const char* string = aCallback(index);
if(string)
{
text = STRING_Render(string, (index == aSelected) ? c_active : c_inactive, bg);
SDL_BlitSurface(text, 0, SDL_GetVideoSurface(), &DrawPosition);
DrawPosition.y += text->h;
SDL_FreeSurface(text);
}
else
{
break;
}
index ++;
}
SDL_Flip(SDL_GetVideoSurface());
}
示例7: prepare_raster
void prepare_raster()
{
// int real_w, real_h;
// bool rotated;
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
// real_w = 320;
// real_h = 480;
// rotated = true;
#else
const SDL_Surface* fb = SDL_GetVideoSurface();
if(fb == NULL) {
std::cerr << "Framebuffer was null in prepare_raster\n";
return;
}
// real_w = fb->w;
// real_h = fb->h;
// rotated = false;
#endif
glViewport(0, 0, preferences::actual_screen_width(), preferences::actual_screen_height());
// glClearColor(0.0, 0.0, 0.0, 0.0);
// glClear(GL_COLOR_BUFFER_BIT);
glShadeModel(GL_FLAT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(preferences::screen_rotated()) {
// glOrtho(0, 640, 960, 0, -1.0, 1.0);
glOrtho(0, screen_height(), screen_width(), 0, -1.0, 1.0);
} else {
glOrtho(0, screen_width(), screen_height(), 0, -1.0, 1.0);
}
//glOrtho(0, real_w, real_h, 0, -1.0, 1.0);
if(preferences::screen_rotated()) {
// Rotate 90 degrees ccw, then move real_h pixels down
// This has to be in opposite order since A(); B(); means A(B(x))
glTranslatef(screen_height(), 0.0f, 0.0f);
glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
//glTranslatef(0.0f, 0.5f, 0.0f);
//glScalef(0.5f, 0.5f, 1.0f);
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);
glColor4f(1.0, 1.0, 1.0, 1.0);
}
示例8: scrnmng_menudraw
void
scrnmng_menudraw(const RECT_T *rct)
{
DRAWRECT dr;
SDL_Surface *surface;
const BYTE *p;
const BYTE *q;
BYTE *r;
BYTE *a;
int salign;
int dalign;
int x;
if ((!scrnmng.enable) && (menuvram == NULL))
return;
surface = SDL_GetVideoSurface();
if (surface == NULL)
return;
SDL_LockSurface(surface);
if (calcdrawrect(surface, &dr, menuvram, rct) == SUCCESS) {
if (scrnmng.sm.bpp == 16) {
p = scrnmng.vram->ptr + (dr.srcpos * 2);
q = menuvram->ptr + (dr.srcpos * 2);
r = (BYTE *)surface->pixels + dr.dstpos;
a = menuvram->alpha + dr.srcpos;
salign = menuvram->width;
dalign = dr.yalign - (dr.width * dr.xalign);
do {
x = 0;
do {
if (a[x]) {
if (a[x] & 2) {
*(UINT16 *)r = *(UINT16 *)(q + (x * 2));
}
else {
a[x] = 0;
*(UINT16 *)r = *(UINT16 *)(p + (x * 2));
}
}
r += dr.xalign;
} while (++x < dr.width);
p += salign * 2;
q += salign * 2;
r += dalign;
a += salign;
} while (--dr.height);
}
}
SDL_UnlockSurface(surface);
SDL_Flip(surface);
}
示例9: SDL_GetVideoSurface
void Map::render()
{
SDL_Surface * screen = SDL_GetVideoSurface();
SDL_Rect rect = Camera::getInstance()->getRect();
SDL_BlitSurface( m_pSurface.get(), &rect, screen, NULL );
//Rendering Entities
std::for_each( m_Bullets.begin(), m_Bullets.end(), std::mem_fun_ref( &Bullet::render ));
std::for_each( m_Shields.begin(), m_Shields.end(), std::mem_fun_ref( &Shield::render ));
std::for_each( m_Stars.begin(), m_Stars.end(), std::mem_fun_ref( &Star::render ));
std::for_each( m_Obstacles.begin(), m_Obstacles.end(), std::mem_fun_ref( &Obstacle::render ));
}
示例10: render_list
void render_list(struct game *game)
{
SDL_Surface *message = NULL, *screen = NULL;
SDL_Color color_norm = {0,0,0};
SDL_Color color_high = {255,255,255};
int i, j, tmp;
for(i=0; i<game->num_buttonlist; i++)
{
message = TTF_RenderText_Blended(game->font_yo_frankie, game->buttonlist[i].label, color_norm);
screen = SDL_GetVideoSurface();
tmp = game->buttonlist[i].selected;
if( game->mouse.x_input >= game->buttonlist[i].x - game->button_l->w && game->mouse.x_input <= game->buttonlist[i].x + message->w + game->button_r->w &&
game->mouse.y_input >= game->buttonlist[i].y && game->mouse.y_input <= game->buttonlist[i].y + game->button_c->h)
{
SDL_FreeSurface(message);
message = TTF_RenderText_Blended(game->font_yo_frankie, game->buttonlist[i].label, color_high);
game->buttonlist[i].selected = 1;
}
else
game->buttonlist[i].selected = 0;
if(tmp != game->buttonlist[i].selected && game->buttonlist[i].menu == game->menu)
game->update = 1;
game->buttonlist[i].w = message->w + game->button_l->w + game->button_r->w;
if(message->h > game->button_c->h)
game->buttonlist[i].h = message->h;
else
game->buttonlist[i].h = game->button_c->h;
if(game->buttonlist[i].menu == game->menu)
{
if(game->buttonlist[i].selected)
{
for(j=0; j<message->w; j+=game->button_ch->w)
apply_surface(game->buttonlist[i].x+j, game->buttonlist[i].y, game->button_ch, screen, NULL);
apply_surface(game->buttonlist[i].x - game->button_lh->w, game->buttonlist[i].y, game->button_lh, screen, NULL);
apply_surface(game->buttonlist[i].x + j, game->buttonlist[i].y, game->button_rh, screen, NULL);
}
else
{
for(j=0; j<message->w; j+=game->button_c->w)
apply_surface(game->buttonlist[i].x+j, game->buttonlist[i].y, game->button_c, screen, NULL);
apply_surface(game->buttonlist[i].x - game->button_l->w, game->buttonlist[i].y, game->button_l, screen, NULL);
apply_surface(game->buttonlist[i].x + j, game->buttonlist[i].y, game->button_r, screen, NULL);
}
apply_surface(game->buttonlist[i].x, game->buttonlist[i].y + (game->button_c->h - message->h) / 2, message, screen, NULL);
}
SDL_FreeSurface(message);
}
}
示例11: HotKey_ToggleFullScreen
void HotKey_ToggleFullScreen(void)
{
SDL_Surface *screen;
screen = SDL_GetVideoSurface();
if ( SDL_WM_ToggleFullScreen(screen) ) {
printf("Toggled fullscreen mode - now %s\n",
(screen->flags&SDL_FULLSCREEN) ? "fullscreen" : "windowed");
} else {
printf("Unable to toggle fullscreen mode\n");
}
}
示例12: LeaveInteractiveMode
// Отмена интерактьивного режима
// После вызова этой функции можно вызывать CheckKeys()
void LeaveInteractiveMode()
{
// SDL_WM_SetCaption("Not Interactive",0);
bInteractive=0;
SDL_EnableKeyRepeat(0, 0);
SDL_EnableUNICODE(0);
bBlinkCursor=1;
StartSound();
FlushKeys();
if (vmVideoMode==vmGraph512)
SDL_FillRect(SDL_GetVideoSurface(),0,0);
//............
}
示例13: mSDLSWDeinit
void mSDLSWDeinit(struct mSDLRenderer* renderer) {
if (renderer->ratio > 1) {
free(renderer->outputBuffer);
}
#if !SDL_VERSION_ATLEAST(2, 0, 0)
SDL_Surface* surface = SDL_GetVideoSurface();
SDL_UnlockSurface(surface);
#ifdef USE_PIXMAN
pixman_image_unref(renderer->pix);
pixman_image_unref(renderer->screenpix);
#endif
#endif
}
示例14: draw
bool Sprite::draw(int x, int y) {
rect.x = x;
rect.y = y;
if(SDL_BlitSurface(image, NULL, SDL_GetVideoSurface(), &rect) < 0) { // attempt to draw sprite
cout<<"BlitSurface error" << SDL_GetError() <<"\n";
return false;
}
else {
return true;
}
} // end draw
示例15: getScreenSize
IntSize getScreenSize()
{
__gfx__assert_open();
SDL_Surface *screen;
screen = SDL_GetVideoSurface();
if(screen != NULL)
return IntSize(screen->w, screen->h);
else
return IntSize(0, 0);
}