本文整理汇总了C++中SDL_CreateRGBSurface函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_CreateRGBSurface函数的具体用法?C++ SDL_CreateRGBSurface怎么用?C++ SDL_CreateRGBSurface使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_CreateRGBSurface函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: surface
surface surface::create_surface(uint32_t flags, int width, int height, int depth,
uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask) {
return surface().build(SDL_CreateRGBSurface(flags,width,height,depth
,Rmask,Gmask,Bmask,Amask));
}
示例2: Draw
void Draw(SDL_Surface *screen)
{
int rate,x,y,s;
SDL_Rect dest,clip;
SDL_Surface *texture_image;
SDL_Surface *texture_target1;
SDL_Surface *texture_target2;
FPSmanager fpsm;
Uint32 rmask, gmask, bmask, amask;
int width_half = screen->w/2;
int height_half = screen->h/2;
Uint32 text_color = 0xffffffff;
/* Define masks for 32bit surface */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
/* Create semi-transparent textured surface */
s=64;
texture_image = SDL_DisplayFormatAlpha(SDL_CreateRGBSurface(SDL_SWSURFACE, s, s, 32, rmask, gmask, bmask, amask));
/* Add some color */
boxRGBA(texture_image, 0, 0, s/2, s/2, 255, 0, 0, 255);
boxRGBA(texture_image, s/2, 0, s, s/2, 0, 255, 0, 255);
boxRGBA(texture_image, 0, s/2, s/2, s, 0, 0, 255, 255);
boxRGBA(texture_image, s/2, s/2, s, s, 255, 255, 255, 255);
/* Make 75%-transparent */
SDL_gfxSetAlpha(texture_image, 96);
/* Set alpha channel use to per-pixel blending */
SDL_SetAlpha(texture_image, SDL_SRCALPHA, 255);
/* Create an all transparent surface */
texture_target1 = SDL_DisplayFormatAlpha(SDL_CreateRGBSurface(SDL_SWSURFACE, 256, 256, 32, rmask, gmask, bmask, amask));
/* Make 75%-transparent */
SDL_gfxSetAlpha(texture_target1, 64);
/* Set alpha channel use to per-pixel blending */
SDL_SetAlpha(texture_target1, SDL_SRCALPHA, 255);
/* Create an all transparent surface (2) */
texture_target2 = SDL_DisplayFormatAlpha(SDL_CreateRGBSurface(SDL_SWSURFACE, 256, 256, 32, rmask, gmask, bmask, amask));
/* Make 75%-transparent */
SDL_gfxSetAlpha(texture_target2, 64);
/* Set alpha channel use to per-pixel blending */
SDL_SetAlpha(texture_target2, SDL_SRCALPHA, 255);
/* Define clipping region for left box */
clip.x = width_half-256-10 ;
clip.y = height_half-256/2 ;
clip.w = 256;
clip.h = 256;
/* Initialize Framerate manager */
SDL_initFramerate(&fpsm);
/* Set/switch framerate */
rate=5;
SDL_setFramerate(&fpsm,rate);
/* --- Drawing loop */
while (1) {
/* Event handler */
HandleEvent();
/* Black screen */
ClearScreen(screen);
/* Random position of new texture */
x=(rand() % (256+2*s))-s;
y=(rand() % (256+2*s))-s;
/* Same for comparison texture */
dest.x = x;
dest.y = y;
dest.w = texture_image->w;
dest.h = texture_image->h;
SDL_BlitSurface(texture_image, NULL, texture_target1, &dest);
/* Blit image into the target using custom Blit function. */
dest.x = x;
dest.y = y;
dest.w = texture_image->w;
dest.h = texture_image->h;
SDL_gfxBlitRGBA(texture_image, NULL, texture_target2, &dest);
/* Draw comparison target on screen (left) */
dest.x = width_half-256-10;
dest.y = height_half-256/2;
dest.w = 256;
dest.h = 256;
SDL_BlitSurface(texture_target1, NULL, screen, &dest);
//.........这里部分代码省略.........
示例3: SDL_SetVideoMode
//------------------------------------------------------------------------
bool platform_support::init(unsigned width, unsigned height, unsigned flags)
{
m_window_flags = flags;
unsigned wflags = SDL_SWSURFACE;
if(m_window_flags & window_hw_buffer)
{
wflags = SDL_HWSURFACE;
}
if(m_window_flags & window_resize)
{
wflags |= SDL_RESIZABLE;
}
if(m_specific->m_surf_screen) SDL_FreeSurface(m_specific->m_surf_screen);
m_specific->m_surf_screen = SDL_SetVideoMode(width, height, m_bpp, wflags);
if(m_specific->m_surf_screen == 0)
{
fprintf(stderr,
"Unable to set %dx%d %d bpp video: %s\n",
width,
height,
m_bpp,
::SDL_GetError());
return false;
}
SDL_WM_SetCaption(m_caption, 0);
if(m_specific->m_surf_window) SDL_FreeSurface(m_specific->m_surf_window);
m_specific->m_surf_window =
SDL_CreateRGBSurface(SDL_HWSURFACE,
m_specific->m_surf_screen->w,
m_specific->m_surf_screen->h,
m_specific->m_surf_screen->format->BitsPerPixel,
m_specific->m_rmask,
m_specific->m_gmask,
m_specific->m_bmask,
m_specific->m_amask);
if(m_specific->m_surf_window == 0)
{
fprintf(stderr,
"Unable to create image buffer %dx%d %d bpp: %s\n",
width,
height,
m_bpp,
SDL_GetError());
return false;
}
m_rbuf_window.attach((unsigned char*)m_specific->m_surf_window->pixels,
m_specific->m_surf_window->w,
m_specific->m_surf_window->h,
m_flip_y ? -m_specific->m_surf_window->pitch :
m_specific->m_surf_window->pitch);
if(!m_specific->m_initialized)
{
m_initial_width = width;
m_initial_height = height;
on_init();
m_specific->m_initialized = true;
}
on_resize(m_rbuf_window.width(), m_rbuf_window.height());
m_specific->m_update_flag = true;
return true;
}
示例4: PAL_ScrollFBP
VOID
PAL_ScrollFBP(
WORD wChunkNum,
WORD wScrollSpeed,
BOOL fScrollDown
)
/*++
Purpose:
Scroll up an FBP picture to the screen.
Parameters:
[IN] wChunkNum - number of chunk in fbp.mkf file.
[IN] wScrollSpeed - scrolling speed of showing the picture.
[IN] fScrollDown - TRUE if scroll down, FALSE if scroll up.
Return value:
None.
--*/
{
SDL_Surface *p;
PAL_LARGE BYTE buf[320 * 200];
PAL_LARGE BYTE bufSprite[320 * 200];
int i, l;
SDL_Rect rect, dstrect;
if (PAL_MKFDecompressChunk(buf, 320 * 200, wChunkNum, gpGlobals->f.fpFBP) <= 0)
{
return;
}
if (g_wCurEffectSprite != 0)
{
PAL_MKFDecompressChunk(bufSprite, 320 * 200, g_wCurEffectSprite, gpGlobals->f.fpMGO);
}
p = SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
gpScreen->format->Rmask, gpScreen->format->Gmask,
gpScreen->format->Bmask, gpScreen->format->Amask);
if (p == NULL)
{
return;
}
VIDEO_BackupScreen();
PAL_FBPBlitToSurface(buf, p);
if (wScrollSpeed == 0)
{
wScrollSpeed = 1;
}
rect.x = 0;
rect.w = 320;
dstrect.x = 0;
dstrect.w = 320;
for (l = 0; l < 220; l++)
{
i = l;
if (i > 200)
{
i = 200;
}
if (fScrollDown)
{
rect.y = 0;
dstrect.y = i;
rect.h = 200 - i;
dstrect.h = 200 - i;
}
else
{
rect.y = i;
dstrect.y = 0;
rect.h = 200 - i;
dstrect.h = 200 - i;
}
SDL_BlitSurface(gpScreenBak, &rect, gpScreen, &dstrect);
if (fScrollDown)
{
rect.y = 200 - i;
dstrect.y = 0;
rect.h = i;
dstrect.h = i;
}
else
{
rect.y = 0;
dstrect.y = 200 - i;
rect.h = i;
//.........这里部分代码省略.........
示例5: PAL_ShowFBP
VOID
PAL_ShowFBP(
WORD wChunkNum,
WORD wFade
)
/*++
Purpose:
Draw an FBP picture to the screen.
Parameters:
[IN] wChunkNum - number of chunk in fbp.mkf file.
[IN] wFade - fading speed of showing the picture.
Return value:
None.
--*/
{
PAL_LARGE BYTE buf[320 * 200];
PAL_LARGE BYTE bufSprite[320 * 200];
const int rgIndex[6] = {0, 3, 1, 5, 2, 4};
SDL_Surface *p;
int i, j, k;
BYTE a, b;
if (PAL_MKFDecompressChunk(buf, 320 * 200, wChunkNum, gpGlobals->f.fpFBP) <= 0)
{
memset(buf, 0, sizeof(buf));
}
if (g_wCurEffectSprite != 0)
{
PAL_MKFDecompressChunk(bufSprite, 320 * 200, g_wCurEffectSprite, gpGlobals->f.fpMGO);
}
if (wFade)
{
wFade++;
wFade *= 10;
p = SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
gpScreen->format->Rmask, gpScreen->format->Gmask,
gpScreen->format->Bmask, gpScreen->format->Amask);
PAL_FBPBlitToSurface(buf, p);
VIDEO_BackupScreen();
for (i = 0; i < 16; i++)
{
for (j = 0; j < 6; j++)
{
//
// Blend the pixels in the 2 buffers, and put the result into the
// backup buffer
//
for (k = rgIndex[j]; k < gpScreen->pitch * gpScreen->h; k += 6)
{
a = ((LPBYTE)(p->pixels))[k];
b = ((LPBYTE)(gpScreenBak->pixels))[k];
if (i > 0)
{
if ((a & 0x0F) > (b & 0x0F))
{
b++;
}
else if ((a & 0x0F) < (b & 0x0F))
{
b--;
}
}
((LPBYTE)(gpScreenBak->pixels))[k] = ((a & 0xF0) | (b & 0x0F));
}
SDL_BlitSurface(gpScreenBak, NULL, gpScreen, NULL);
if (g_wCurEffectSprite != 0)
{
int f = SDL_GetTicks() / 150;
PAL_RLEBlitToSurface(PAL_SpriteGetFrame(bufSprite, f % PAL_SpriteGetNumFrames(bufSprite)),
gpScreen, PAL_XY(0, 0));
}
VIDEO_UpdateScreen(NULL);
UTIL_Delay(wFade);
}
}
SDL_FreeSurface(p);
}
//
// HACKHACK: to make the ending show correctly
//
if (wChunkNum != 49)
//.........这里部分代码省略.........
示例6: ilutConvertToSDLSurface
// Does not account for converting luminance...
SDL_Surface * ILAPIENTRY ilutConvertToSDLSurface(unsigned int flags)
{
SDL_Surface *Bitmap;
ILuint i = 0, Pad, BppPal;
ILubyte *Dest;
ilutCurImage = ilGetCurImage();
if (ilutCurImage == NULL) {
ilSetError(ILUT_ILLEGAL_OPERATION);
return NULL;
}
InitSDL();
// Should be IL_BGR(A).
if (ilutCurImage->Format == IL_RGB || ilutCurImage->Format == IL_RGBA) {
if (!isBigEndian)
iluSwapColours();
}
if (ilutCurImage->Origin == IL_ORIGIN_LOWER_LEFT)
iluFlipImage();
if (ilutCurImage->Type > IL_UNSIGNED_BYTE) {} // Can't do anything about this right now...
if (ilutCurImage->Type == IL_BYTE) {} // Can't do anything about this right now...
Bitmap = SDL_CreateRGBSurface(flags,ilutCurImage->Width,ilutCurImage->Height,ilutCurImage->Bpp * 8,
rmask,gmask,bmask,amask);
if (Bitmap == NULL) {
return IL_FALSE;
}
if (SDL_MUSTLOCK(Bitmap))
SDL_LockSurface(Bitmap);
Pad = Bitmap->pitch - ilutCurImage->Bps;
if (Pad == 0) {
memcpy(Bitmap->pixels, ilutCurImage->Data, ilutCurImage->SizeOfData);
}
else { // Must pad the lines on some images.
Dest = Bitmap->pixels;
for (i = 0; i < ilutCurImage->Height; i++) {
memcpy(Dest, ilutCurImage->Data + i * ilutCurImage->Bps, ilutCurImage->Bps);
imemclear(Dest + ilutCurImage->Bps, Pad);
Dest += Bitmap->pitch;
}
}
if (SDL_MUSTLOCK(Bitmap))
SDL_UnlockSurface(Bitmap);
if (ilutCurImage->Bpp == 1) {
BppPal = ilGetBppPal(ilutCurImage->Pal.PalType);
switch (ilutCurImage->Pal.PalType)
{
case IL_PAL_RGB24:
case IL_PAL_RGB32:
case IL_PAL_RGBA32:
for (i = 0; i < ilutCurImage->Pal.PalSize / BppPal; i++) {
(Bitmap->format)->palette->colors[i].r = ilutCurImage->Pal.Palette[i*BppPal+0];
(Bitmap->format)->palette->colors[i].g = ilutCurImage->Pal.Palette[i*BppPal+1];
(Bitmap->format)->palette->colors[i].b = ilutCurImage->Pal.Palette[i*BppPal+2];
(Bitmap->format)->palette->colors[i].unused = 255;
}
break;
case IL_PAL_BGR24:
case IL_PAL_BGR32:
case IL_PAL_BGRA32:
for (i = 0; i < ilutCurImage->Pal.PalSize / BppPal; i++) {
(Bitmap->format)->palette->colors[i].b = ilutCurImage->Pal.Palette[i*BppPal+0];
(Bitmap->format)->palette->colors[i].g = ilutCurImage->Pal.Palette[i*BppPal+1];
(Bitmap->format)->palette->colors[i].r = ilutCurImage->Pal.Palette[i*BppPal+2];
(Bitmap->format)->palette->colors[i].unused = 255;
}
break;
default:
ilSetError(IL_INTERNAL_ERROR); // Do anything else?
}
}
return Bitmap;
}
示例7: power_of_two
GLuint Graphic::SDL_GL_LoadTexture( SDL_Surface *surface, GLfloat *texcoord ) {
GLuint tex;
int w, h;
SDL_Surface *image;
SDL_Rect area;
SDL_BlendMode saved_mode;
/* Use the surface width and height expanded to powers of 2 */
w = power_of_two(surface->w);
h = power_of_two(surface->h);
texcoord[0] = 0.0f; /* Min X */
texcoord[1] = 0.0f; /* Min Y */
texcoord[2] = (GLfloat)surface->w / w; /* Max X */
texcoord[3] = (GLfloat)surface->h / h; /* Max Y */
image = SDL_CreateRGBSurface(
SDL_SWSURFACE,
w, h,
32,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
0x000000FF,
0x0000FF00,
0x00FF0000,
0xFF000000
#else
0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF
#endif
);
if ( image == NULL ) {
return 0;
}
SDL_GetSurfaceBlendMode(surface, &saved_mode);
SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
/* Copy the surface into the GL texture image */
area.x = 0;
area.y = 0;
area.w = surface->w;
area.h = surface->h;
SDL_BlitSurface(surface, &area, image, &area);
SDL_SetSurfaceBlendMode(surface, saved_mode);
/* Create an OpenGL texture for the image */
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA,
w, h,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
image->pixels);
SDL_FreeSurface(image); /* No longer needed */
return tex;
}
示例8: SDL_RWgets
/* Load a XPM type image from an SDL datasource */
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
{
SDL_Surface *image;
char line[1024];
char *here;
int index;
int x, y;
int w, h, ncolors, cpp;
int pixels_len;
char *pixels = NULL;
int indexed;
Uint8 *dst;
struct color_hash *colors;
SDL_Color *im_colors = NULL;
char *keystrings, *nextkey;
char *error = NULL;
/* Skip to the first string, which describes the image */
do {
here = SDL_RWgets(line, sizeof(line), src);
if ( !here ) {
IMG_SetError("Premature end of data");
return(NULL);
}
here = skipspace(here);
} while(*here != '"');
/*
* The header string of an XPMv3 image has the format
*
* <width> <height> <ncolors> <cpp> [ <hotspot_x> <hotspot_y> ]
*
* where the hotspot coords are intended for mouse cursors.
* Right now we don't use the hotspots but it should be handled
* one day.
*/
if(sscanf(here + 1, "%d %d %d %d", &w, &h, &ncolors, &cpp) != 4
|| w <= 0 || h <= 0 || ncolors <= 0 || cpp <= 0) {
IMG_SetError("Invalid format description");
return(NULL);
}
keystrings = malloc(ncolors * cpp);
if(!keystrings) {
IMG_SetError("Out of memory");
free(pixels);
return NULL;
}
nextkey = keystrings;
/* Create the new surface */
if(ncolors <= 256) {
indexed = 1;
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8,
0, 0, 0, 0);
im_colors = image->format->palette->colors;
image->format->palette->ncolors = ncolors;
} else {
indexed = 0;
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
0xff0000, 0x00ff00, 0x0000ff, 0);
}
if(!image) {
/* Hmm, some SDL error (out of memory?) */
free(pixels);
return(NULL);
}
/* Read the colors */
colors = create_colorhash(ncolors);
if ( ! colors ) {
error = "Out of memory";
goto done;
}
for(index = 0; index < ncolors; ++index ) {
char *key;
int len;
do {
here = SDL_RWgets(line, sizeof(line), src);
if(!here) {
error = "Premature end of data";
goto done;
}
here = skipspace(here);
} while(*here != '"');
++here;
len = strlen(here);
if(len < cpp + 7)
continue; /* cannot be a valid line */
key = here;
key[cpp] = '\0';
here += cpp + 1;
/* parse a colour definition */
for(;;) {
char nametype;
char *colname;
//.........这里部分代码省略.........
示例9: main
int main(int argc, char** argv)
{
srand(time(NULL));
struct chip8 cpu;
initialize(&cpu);
load_game(&cpu, argv[1]);
//setup graphics
SDL_Window *window = NULL;
SDL_Surface *screen = NULL;
if(SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
}
else
{
window = SDL_CreateWindow( "Chip8", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if(!window)
{
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
}
else
{
//Get window surface
screen = SDL_GetWindowSurface(window);
//Fill the surface white
SDL_FillRect( screen, NULL, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF ) );
//Update the surface
SDL_UpdateWindowSurface(window);
}
}
SDL_Surface *s;
s = SDL_CreateRGBSurface(0, 640, 320, 32, 0,0,0,0);
SDL_FillRect(s, NULL, SDL_MapRGB(s->format, 0, 0, 0));
SDL_Surface *pixel = NULL;
pixel = SDL_LoadBMP("pixel.bmp");
if(!pixel)
{
printf( "Unable to load image! SDL Error: %s\n", SDL_GetError() );
}
SDL_BlitSurface(s, NULL, screen, NULL);
SDL_BlitSurface(pixel, NULL, screen, NULL);
SDL_UpdateWindowSurface(window);
//init keys
reset_keys(&cpu);
int quit = 0;
while(!quit)
{
usleep(1000);
emulate_cycle(&cpu);
if(cpu.drawFlag)
{
//draw graphics
SDL_BlitSurface(s, NULL, screen, NULL);
for(int i = 0; i < DISP_T; i++)
{
if(cpu.gfx[i])
{
int x = (i % 64) * 10;
int y = (i / 64) *10;
SDL_Rect r;
r.x = x;
r.y = y;
r.w = 10;
r.h = 10;
SDL_BlitSurface(pixel, NULL, screen, &r);
}
}
SDL_UpdateWindowSurface(window);
cpu.drawFlag = 0;
}
//set keys
reset_keys(&cpu);
SDL_Event e;
SDL_PollEvent(&e);
if(e.type == SDL_QUIT) {
quit = 1;
} else if(e.type == SDL_KEYDOWN) {
long k = e.key.keysym.sym;
switch(k) {
case SDLK_1:
cpu.keys[0] = 1;
break;
case SDLK_2:
cpu.keys[1] = 1;
break;
case SDLK_3:
cpu.keys[2] = 1;
break;
case SDLK_4:
cpu.keys[3] = 1;
break;
case SDLK_q:
//.........这里部分代码省略.........
示例10: gui_init
int gui_init (void)
{
//Se ejecuta justo despues del MAIN
if (prSDLScreen==NULL)
#ifdef DREAMCAST
prSDLScreen=SDL_SetVideoMode(320,240,16,VIDEO_FLAGS);
#else
#ifdef PANDORA
if(hwScaled)
prSDLScreen = SDL_SetVideoMode(320, gfxHeight, 16, VIDEO_FLAGS);
else
{
prSDLScreen = SDL_CreateRGBSurface(SDL_SWSURFACE,320,240,16,0,0,0,0);
prSDLScaleScreen = SDL_SetVideoMode(640, 480, 16, VIDEO_FLAGS);
}
#else
prSDLScreen=SDL_SetVideoMode(320,240,16,VIDEO_FLAGS);
#endif
#endif
SDL_ShowCursor(SDL_DISABLE);
SDL_JoystickEventState(SDL_ENABLE);
SDL_JoystickOpen(0);
if (prSDLScreen!=NULL)
{
emulating=0;
#if !defined(DEBUG_UAE4ALL) && !defined(PROFILER_UAE4ALL) && !defined(AUTO_RUN) && !defined(AUTO_FRAMERATE)
//uae4all_image_file[0]=0;
//uae4all_image_file2[0]=0;
#else
//strcpy(uae4all_image_file,"prueba.adz");
//strcpy(uae4all_image_file2,"prueba2.adz");
#endif
init_text(1);
if (!uae4all_image_file0[0])
run_mainMenu();
quit_text();
vkbd_init();
#ifdef GP2X
inputmode_init();
#if !defined(PANDORA) && !defined(GCW0)
volumecontrol_init();
#endif
#endif
printf("4\n");
#if defined (PSP) || defined (GIZMONDO)
inputmode_init();
#endif
uae4all_pause_music();
printf("5\n");
emulating=1;
getChanges();
printf("6\n");
check_all_prefs();
printf("7\n");
reset_frameskip();
printf("8\n");
#ifdef DEBUG_FRAMERATE
uae4all_update_time();
#endif
#ifdef PROFILER_UAE4ALL
uae4all_prof_init();
uae4all_prof_add("M68K"); // 0
uae4all_prof_add("EVENTS"); // 1
uae4all_prof_add("HSync"); // 2
uae4all_prof_add("Copper"); // 3
uae4all_prof_add("Audio"); // 4
uae4all_prof_add("CIA"); // 5
uae4all_prof_add("Blitter"); // 6
uae4all_prof_add("Vsync"); // 7
uae4all_prof_add("update_fetch"); // 8
uae4all_prof_add("linetoscr"); // 9
uae4all_prof_add("do_long_fetch"); // 10
uae4all_prof_add("pfield_doline"); // 11
uae4all_prof_add("draw_sprites_ecs"); // 12
uae4all_prof_add("flush_block"); // 13
uae4all_prof_add("SET_INTERRUPT"); // 14
/*
uae4all_prof_add("15"); // 15
uae4all_prof_add("16"); // 16
uae4all_prof_add("17"); // 17
uae4all_prof_add("18"); // 18
uae4all_prof_add("19"); // 19
uae4all_prof_add("20"); // 20
uae4all_prof_add("21"); // 21
uae4all_prof_add("22"); // 22
*/
#endif
#ifdef DREAMCAST
SDL_DC_EmulateKeyboard(SDL_FALSE);
#endif
/*int test = pnd_evdev_open(pnd_evdev_nub1);
printf("nub1 open: %d\n", test);
//.........这里部分代码省略.........
示例11: Draw
//.........这里部分代码省略.........
picture = SDL_LoadBMP(bmpfile);
if ( picture == NULL ) {
fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError());
return;
}
fprintf (stderr,"2. shrink 24bit\n");
ShrinkPicture(screen,picture);
/* Free the picture */
SDL_FreeSurface(picture);
}
if (start<=4) {
/* Message */
fprintf (stderr,"Loading 24bit image\n");
/* Load the image into a surface */
bmpfile = "sample24.bmp";
fprintf(stderr, "Loading picture: %s\n", bmpfile);
picture = SDL_LoadBMP(bmpfile);
if ( picture == NULL ) {
fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError());
return;
}
fprintf (stderr,"2. shrink 24bit\n");
ShrinkPicture(screen,picture);
/* Free the picture */
SDL_FreeSurface(picture);
}
/* -------- 32 bit test --------- */
if (start<=5) {
/* Message */
fprintf (stderr,"Loading 24bit square image\n");
/* Load the image into a surface */
bmpfile = "sample24-box.bmp";
fprintf(stderr, "Loading picture: %s\n", bmpfile);
picture = SDL_LoadBMP(bmpfile);
if ( picture == NULL ) {
fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError());
return;
}
/* New source surface is 32bit with defined RGBA ordering */
/* Much faster to do this once rather than the routine on the fly */
fprintf (stderr,"Converting 24bit image into 32bit RGBA surface ...\n");
picture_again = SDL_CreateRGBSurface(SDL_SWSURFACE, picture->w, picture->h, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
SDL_BlitSurface(picture,NULL,picture_again,NULL);
/* Message */
fprintf (stderr,"3. shrink 32bit \n");
ShrinkPicture(screen,picture_again);
/* Free the picture2 */
SDL_FreeSurface(picture_again);
SDL_FreeSurface(picture);
}
if (start<=6) {
/* Message */
fprintf (stderr,"Loading 24bit image\n");
/* Load the image into a surface */
bmpfile = "sample24.bmp";
fprintf(stderr, "Loading picture: %s\n", bmpfile);
picture = SDL_LoadBMP(bmpfile);
if ( picture == NULL ) {
fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError());
return;
}
/* New source surface is 32bit with defined RGBA ordering */
/* Much faster to do this once rather than the routine on the fly */
fprintf (stderr,"Converting 24bit image into 32bit RGBA surface ...\n");
picture_again = SDL_CreateRGBSurface(SDL_SWSURFACE, picture->w, picture->h, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
SDL_BlitSurface(picture,NULL,picture_again,NULL);
/* Message */
fprintf (stderr,"3. shrink 32bit \n");
ShrinkPicture(screen,picture_again);
/* Free the picture2 */
SDL_FreeSurface(picture_again);
SDL_FreeSurface(picture);
}
return;
}
示例12: CGX_SetIcon
void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
{
#if 0
SDL_Surface *sicon;
XWMHints *wmhints;
XImage *icon_image;
Pixmap icon_pixmap;
Pixmap mask_pixmap;
#ifdef USE_ICON_WINDOW
Window icon_window;
#endif
GC GC;
XGCValues GCvalues;
int i, b, dbpp;
SDL_Rect bounds;
Uint8 *LSBmask, *color_tried;
Visual *dvis;
/* Lock the event thread, in multi-threading environments */
SDL_Lock_EventThread();
/* The icon must use the default visual, depth and colormap of the
screen, so it might need a conversion */
dbpp = DefaultDepth(SDL_Display, SDL_Screen);
switch(dbpp) {
case 15:
dbpp = 16; break;
case 24:
dbpp = 32; break;
}
dvis = DefaultVisual(SDL_Display, SDL_Screen);
/* The Visual struct is supposed to be opaque but we cheat a little */
sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
dbpp,
dvis->red_mask, dvis->green_mask,
dvis->blue_mask, 0);
if ( sicon == NULL ) {
goto done;
}
/* If we already have allocated colours from the default colormap,
copy them */
if(SDL_Visual == dvis && SDL_XColorMap == SDL_DisplayColormap
&& this->screen->format->palette && sicon->format->palette) {
memcpy(sicon->format->palette->colors,
this->screen->format->palette->colors,
this->screen->format->palette->ncolors * sizeof(SDL_Color));
}
bounds.x = 0;
bounds.y = 0;
bounds.w = icon->w;
bounds.h = icon->h;
if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 )
goto done;
/* Lock down the colors used in the colormap */
color_tried = NULL;
if ( sicon->format->BitsPerPixel == 8 ) {
SDL_Palette *palette;
Uint8 *p;
XColor wanted;
palette = sicon->format->palette;
color_tried = malloc(palette->ncolors);
if ( color_tried == NULL ) {
goto done;
}
if ( SDL_iconcolors != NULL ) {
free(SDL_iconcolors);
}
SDL_iconcolors = malloc(palette->ncolors
* sizeof(*SDL_iconcolors));
if ( SDL_iconcolors == NULL ) {
free(color_tried);
goto done;
}
memset(color_tried, 0, palette->ncolors);
memset(SDL_iconcolors, 0,
palette->ncolors * sizeof(*SDL_iconcolors));
p = (Uint8 *)sicon->pixels;
for ( i = sicon->w*sicon->h; i > 0; --i, ++p ) {
if ( ! color_tried[*p] ) {
wanted.pixel = *p;
wanted.red = (palette->colors[*p].r<<8);
wanted.green = (palette->colors[*p].g<<8);
wanted.blue = (palette->colors[*p].b<<8);
wanted.flags = (DoRed|DoGreen|DoBlue);
if (XAllocColor(SDL_Display,
SDL_DisplayColormap, &wanted)) {
++SDL_iconcolors[wanted.pixel];
}
color_tried[*p] = 1;
}
}
}
if ( color_tried != NULL ) {
free(color_tried);
//.........这里部分代码省略.........
示例13: SDL_ConvertSurface
/*
* Convert a surface into the specified pixel format.
*/
SDL_Surface *
SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
Uint32 flags)
{
SDL_Surface *convert;
Uint32 copy_flags;
SDL_Color copy_color;
SDL_Rect bounds;
/* Check for empty destination palette! (results in empty image) */
if (format->palette != NULL) {
int i;
for (i = 0; i < format->palette->ncolors; ++i) {
if ((format->palette->colors[i].r != 0xFF) ||
(format->palette->colors[i].g != 0xFF) ||
(format->palette->colors[i].b != 0xFF))
break;
}
if (i == format->palette->ncolors) {
SDL_SetError("Empty destination palette");
return (NULL);
}
}
/* Create a new surface with the desired format */
convert = SDL_CreateRGBSurface(flags, surface->w, surface->h,
format->BitsPerPixel, format->Rmask,
format->Gmask, format->Bmask,
format->Amask);
if (convert == NULL) {
return (NULL);
}
/* Copy the palette if any */
if (format->palette && convert->format->palette) {
SDL_memcpy(convert->format->palette->colors,
format->palette->colors,
format->palette->ncolors * sizeof(SDL_Color));
convert->format->palette->ncolors = format->palette->ncolors;
}
/* Save the original copy flags */
copy_flags = surface->map->info.flags;
copy_color.r = surface->map->info.r;
copy_color.g = surface->map->info.g;
copy_color.b = surface->map->info.b;
copy_color.a = surface->map->info.a;
surface->map->info.r = 0xFF;
surface->map->info.g = 0xFF;
surface->map->info.b = 0xFF;
surface->map->info.a = 0xFF;
surface->map->info.flags = 0;
SDL_InvalidateMap(surface->map);
/* Copy over the image data */
bounds.x = 0;
bounds.y = 0;
bounds.w = surface->w;
bounds.h = surface->h;
SDL_LowerBlit(surface, &bounds, convert, &bounds);
/* Clean up the original surface, and update converted surface */
convert->map->info.r = copy_color.r;
convert->map->info.g = copy_color.g;
convert->map->info.b = copy_color.b;
convert->map->info.a = copy_color.a;
convert->map->info.flags =
(copy_flags &
~(SDL_COPY_COLORKEY | SDL_COPY_BLEND
| SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY |
SDL_COPY_RLE_ALPHAKEY));
surface->map->info.r = copy_color.r;
surface->map->info.g = copy_color.g;
surface->map->info.b = copy_color.b;
surface->map->info.a = copy_color.a;
surface->map->info.flags = copy_flags;
SDL_InvalidateMap(surface->map);
if (copy_flags & SDL_COPY_COLORKEY) {
SDL_bool set_colorkey_by_color = SDL_FALSE;
if (surface->format->palette) {
if (format->palette &&
surface->format->palette->ncolors <= format->palette->ncolors &&
(SDL_memcmp(surface->format->palette->colors, format->palette->colors,
surface->format->palette->ncolors * sizeof(SDL_Color)) == 0)) {
/* The palette is identical, just set the same colorkey */
SDL_SetColorKey(convert, 1, surface->map->info.colorkey);
} else if (format->Amask) {
/* The alpha was set in the destination from the palette */
} else {
set_colorkey_by_color = SDL_TRUE;
}
} else {
set_colorkey_by_color = SDL_TRUE;
}
if (set_colorkey_by_color) {
//.........这里部分代码省略.........
示例14: PAL_StartBattle
//.........这里部分代码省略.........
}
}
g_Battle.wMaxEnemyIndex = i - 1;
//
// Store all players
//
for (i = 0; i <= gpGlobals->wMaxPartyMemberIndex; i++)
{
g_Battle.rgPlayer[i].flTimeMeter = 15.0f;
#ifndef PAL_CLASSIC
g_Battle.rgPlayer[i].flTimeSpeedModifier = 2.0f;
g_Battle.rgPlayer[i].sTurnOrder = -1;
#endif
g_Battle.rgPlayer[i].wHidingTime = 0;
g_Battle.rgPlayer[i].state = kFighterWait;
g_Battle.rgPlayer[i].action.sTarget = -1;
g_Battle.rgPlayer[i].fDefending = FALSE;
g_Battle.rgPlayer[i].wCurrentFrame = 0;
g_Battle.rgPlayer[i].iColorShift = FALSE;
}
//
// Load sprites and background
//
PAL_LoadBattleSprites();
PAL_LoadBattleBackground();
//
// Create the surface for scene buffer
//
g_Battle.lpSceneBuf =
SDL_CreateRGBSurface(gpScreen->flags & ~SDL_HWSURFACE, 320, 200, 8,
gpScreen->format->Rmask, gpScreen->format->Gmask,
gpScreen->format->Bmask, gpScreen->format->Amask);
if (g_Battle.lpSceneBuf == NULL)
{
TerminateOnError("PAL_StartBattle(): creating surface for scene buffer failed!");
}
PAL_UpdateEquipments();
g_Battle.iExpGained = 0;
g_Battle.iCashGained = 0;
g_Battle.fIsBoss = fIsBoss;
g_Battle.fEnemyCleared = FALSE;
g_Battle.fEnemyMoving = FALSE;
g_Battle.iHidingTime = 0;
g_Battle.wMovingPlayerIndex = 0;
g_Battle.UI.szMsg[0] = '\0';
g_Battle.UI.szNextMsg[0] = '\0';
g_Battle.UI.dwMsgShowTime = 0;
g_Battle.UI.state = kBattleUIWait;
g_Battle.UI.fAutoAttack = FALSE;
g_Battle.UI.wSelectedIndex = 0;
g_Battle.UI.wPrevEnemyTarget = 0;
memset(g_Battle.UI.rgShowNum, 0, sizeof(g_Battle.UI.rgShowNum));
g_Battle.lpSummonSprite = NULL;
g_Battle.sBackgroundColorShift = 0;
示例15: sdlAllocateBuffer
static DFBResult
sdlAllocateBuffer( CoreSurfacePool *pool,
void *pool_data,
void *pool_local,
CoreSurfaceBuffer *buffer,
CoreSurfaceAllocation *allocation,
void *alloc_data )
{
DFBResult ret;
CoreSurface *surface;
SDLAllocationData *alloc = alloc_data;
D_DEBUG_AT( SDL_Pool, "%s()\n", __FUNCTION__ );
D_MAGIC_ASSERT( pool, CoreSurfacePool );
D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer );
surface = buffer->surface;
D_MAGIC_ASSERT( surface, CoreSurface );
if (surface->type & CSTF_LAYER) {
dfb_sdl->screen = NULL; /* clear? */
ret = dfb_sdl_set_video_mode( dfb_sdl_core, &surface->config );
if (ret) {
D_DERROR( ret, "SDL/Surface: dfb_sdl_set_video_mode() failed!\n" );
return ret;
}
D_ASSERT( dfb_sdl->screen != NULL );
if (!dfb_sdl->screen) {
D_ERROR( "SDL/Surface: No screen surface!?\n" );
return DFB_BUG;
}
alloc->sdl_surf = dfb_sdl->screen;
D_DEBUG_AT( SDL_Pool, " -> screen surface %dx%d, %d, 0x%08x, pitch %d\n",
dfb_sdl->screen->w, dfb_sdl->screen->h, dfb_sdl->screen->format->BitsPerPixel,
dfb_sdl->screen->flags, dfb_sdl->screen->pitch );
allocation->flags |= CSALF_ONEFORALL;
}
else {
DFBSurfacePixelFormat format = surface->config.format;
Uint32 flags = SDL_HWSURFACE;// | SDL_ASYNCBLIT | SDL_FULLSCREEN;
Uint32 rmask;
Uint32 gmask;
Uint32 bmask;
Uint32 amask;
if (surface->config.caps & DSCAPS_FLIPPING)
flags |= SDL_DOUBLEBUF;
switch (format) {
case DSPF_A8:
rmask = 0x00;
gmask = 0x00;
bmask = 0x00;
amask = 0xff;
break;
case DSPF_RGB16:
rmask = 0xf800;
gmask = 0x07e0;
bmask = 0x001f;
amask = 0x0000;
break;
case DSPF_RGB32:
rmask = 0x00ff0000;
gmask = 0x0000ff00;
bmask = 0x000000ff;
amask = 0x00000000;
break;
case DSPF_ARGB:
rmask = 0x00ff0000;
gmask = 0x0000ff00;
bmask = 0x000000ff;
amask = 0xff000000;
break;
default:
D_ERROR( "SDL/Surface: %s() has no support for %s!\n",
__FUNCTION__, dfb_pixelformat_name(format) );
return DFB_UNSUPPORTED;
}
D_DEBUG_AT( SDL_Pool, " -> SDL_CreateRGBSurface( 0x%08x, "
"%dx%d, %d, 0x%08x, 0x%08x, 0x%08x, 0x%08x )\n",
flags, surface->config.size.w, surface->config.size.h,
DFB_BITS_PER_PIXEL(format), rmask, gmask, bmask, amask );
alloc->sdl_surf = SDL_CreateRGBSurface( flags,
surface->config.size.w,
surface->config.size.h,
DFB_BITS_PER_PIXEL(format),
rmask, gmask, bmask, amask );
//.........这里部分代码省略.........