本文整理汇总了C++中SDL_ClearError函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_ClearError函数的具体用法?C++ SDL_ClearError怎么用?C++ SDL_ClearError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_ClearError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc, char *argv[])
{
char buffer[BUFSIZ + 1];
SDL_SetError("Hi there!");
printf("Error 1: %s\n", SDL_GetError());
SDL_ClearError();
SDL_memset(buffer, '1', BUFSIZ);
buffer[BUFSIZ] = 0;
SDL_SetError("This is the error: %s (%f)", buffer, 1.0);
printf("Error 2: %s\n", SDL_GetError());
exit(0);
}
示例2: _checkInvalidNameError
/*
* Local helper to check for the invalid scancode error message
*/
void
_checkInvalidNameError()
{
const char *expectedError = "Parameter 'name' is invalid";
const char *error;
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
}
}
示例3: SDL_Init
int SDL_Init(Uint32 flags)
{
/* Clear the error message */
SDL_ClearError();
/* Initialize the desired subsystems */
if ( SDL_InitSubSystem(flags) < 0 ) {
return(-1);
}
/* Everything is initialized */
if ( !(flags & SDL_INIT_NOPARACHUTE) ) {
SDL_InstallParachute();
}
return(0);
}
示例4: IMG_Load
/*
Returns the first image found at the provided path
This method attempts all the suffices stored in Texture::IMAGE_EXTS
@imagePath Path to search for images
*/
SDL_Surface *Texture::findImage(const char *imagePath)
{
if (!imagePath)
return 0;
SDL_Surface *image=0;
for (int i = 0; i < sizeof(IMAGE_EXTS) / sizeof(char*);i++)
{
image = IMG_Load(std::string(imagePath).append(IMAGE_EXTS[i]).c_str());
if (image)
{
SDL_ClearError();//Clear the img errorS
break;
}
}
return image;
}
示例5: SDL_WAYLAND_LoadSymbols
/* returns non-zero if all needed symbols were loaded. */
int
SDL_WAYLAND_LoadSymbols(void)
{
int rc = 1; /* always succeed if not using Dynamic WAYLAND stuff. */
/* deal with multiple modules (dga, wayland, etc) needing these symbols... */
if (wayland_load_refcount++ == 0) {
#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
int i;
int *thismod = NULL;
for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) {
if (waylandlibs[i].libname != NULL) {
waylandlibs[i].lib = SDL_LoadObject(waylandlibs[i].libname);
}
}
#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */
#include "SDL_waylandsym.h"
#define SDL_WAYLAND_MODULE(modname) thismod = &SDL_WAYLAND_HAVE_##modname;
#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn) WAYLAND_GetSym(#fn,thismod);
#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = (struct wl_interface *) WAYLAND_GetSym(#iface,thismod);
#include "SDL_waylandsym.h"
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT) {
/* all required symbols loaded. */
SDL_ClearError();
} else {
/* in case something got loaded... */
SDL_WAYLAND_UnloadSymbols();
rc = 0;
}
#else /* no dynamic WAYLAND */
#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */
#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = fn;
#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = &iface;
#include "SDL_waylandsym.h"
#endif
}
return rc;
}
示例6: main
int
main(int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
fprintf(stderr, "Could not initialize SDL: %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
SDL_ClearError();
printf("SDL initialized\n");
atexit(end_SDL);
/* Creat a SDL window, and get the window's surface. */
SDL_Surface *screen = NULL;
screen = SDL_SetVideoMode(459, 732, 24, SDL_SWSURFACE);
if (screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode() failed: %\n", SDL_GetError());
exit(EXIT_FAILURE);
}
/* Load a BMP file, and convert it as a surface */
SDL_Surface *bmp = NULL;
bmp = SDL_LoadBMP("1.bmp");
if (bmp == NULL) {
fprintf(stderr, "SDL_LoadBMP() failed: %\n", SDL_GetError());
exit(EXIT_FAILURE);
}
/* Put the BMP's surface on the SDL window's surface. */
if (SDL_BlitSurface(bmp, NULL, screen, NULL) == -1) {
fprintf(stderr, "SDL_BlitSurface() failed: %\n", SDL_GetError());
exit(EXIT_FAILURE);
}
/* Show the SDL window's surface */
if (SDL_Flip(screen) == -1) {
fprintf(stderr, "SDL_Flip() failed: %\n", SDL_GetError());
exit(EXIT_FAILURE);
}
press_ESC_to_quit();
return 0;
}
示例7: LS_LOG_GL_ERR
/*-------------------------------------
* System Runtime
-------------------------------------*/
void MainState::on_run() {
LS_LOG_GL_ERR();
renderContext.make_current(*global::pDisplay);
LS_LOG_GL_ERR();
renderContext.flip(*global::pDisplay);
LS_LOG_GL_ERR();
const char* const pSdlErr = SDL_GetError();
if (pSdlErr && pSdlErr[0] != '\0') {
LS_LOG_ERR("SDL_ERROR: ", pSdlErr);
SDL_ClearError();
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
LS_LOG_GL_ERR();
}
示例8: assert
void MainManager::run() {
assert(basicRender_ && "You need a renderer, fool!");
SDL_Event event;
uint frameNumber = 0;
float previousTime = runtime_->getSeconds();
while (isRunning_) {
#ifndef NDEBUG
const char* err = SDL_GetError();
if (err[0] != '\0') {
log_.e() << "SDL_GetError(): " << err << Log::end;
}
#endif
SDL_ClearError();
while (SDL_PollEvent(&event)) {
handleEvent(event);
basicRender_->handleEvent(event);
if (scene_) scene_->handleEvent(event);
}
++frameNumber;
if (scene_) scene_->refresh();
basicRender_->refresh();
textRenderer_.refresh();
currentTimeDelta_ = runtime_->getSeconds() - previousTime;
previousTime = runtime_->getSeconds();
physics_->stepSimulation(currentTimeDelta_);
basicRender_->render(runtime_->getSeconds());
textRenderer_.render(0);
graphics_->swapBuffers();
fpsCounter_.tic();
if (frameNumber % 30 == 0)
updateFpsText(fpsCounter_.getFps());
}
}
示例9: SDL_X11_LoadSymbols
/* returns non-zero if all needed symbols were loaded. */
int SDL_X11_LoadSymbols(void)
{
int rc = 1; /* always succeed if not using Dynamic X11 stuff. */
#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
/* deal with multiple modules (dga, x11, etc) needing these symbols... */
if (x11_load_refcount++ == 0) {
int i;
int *thismod = NULL;
for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
if (x11libs[i].libname != NULL) {
x11libs[i].lib = SDL_LoadObject(x11libs[i].libname);
}
}
#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
#define SDL_X11_SYM(a,fn,x,y,z) X11_GetSym(#fn,thismod,(void**)&p##fn);
#include "SDL_x11sym.h"
#undef SDL_X11_MODULE
#undef SDL_X11_SYM
#ifdef X_HAVE_UTF8_STRING
X11_GetSym("XCreateIC",&SDL_X11_HAVE_UTF8,(void **)&pXCreateIC);
X11_GetSym("XGetICValues",&SDL_X11_HAVE_UTF8,(void **)&pXGetICValues);
#endif
if (SDL_X11_HAVE_BASEXLIB) { /* all required symbols loaded. */
SDL_ClearError();
} else {
SDL_X11_UnloadSymbols(); /* in case something got loaded... */
rc = 0;
}
}
#else
#if DEBUG_DYNAMIC_X11
printf("X11: No dynamic X11 support in this build of SDL.\n");
#endif
#ifdef X_HAVE_UTF8_STRING
pXCreateIC = XCreateIC;
pXGetICValues = XGetICValues;
#endif
#endif
return rc;
}
示例10: main
int
main(int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
fprintf(stderr, "Could not initialize SDL: %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
SDL_ClearError();
printf("SDL initialized\n");
atexit(end_SDL);
/* Creat a SDL window, and get the window's surface. */
//SDL_Surface *screen = NULL;
screen = SDL_SetVideoMode(640, 480, 32, SDL_FULLSCREEN);
if (screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode() failed: %\n", SDL_GetError());
exit(EXIT_FAILURE);
}
/* Load a BMP file, and convert it as a surface */
//SDL_Surface *back = NULL;
back = SDL_LoadBMP("back.bmp");
if (back == NULL) {
fprintf(stderr, "SDL_LoadBMP() failed: %\n", SDL_GetError());
exit(EXIT_FAILURE);
}
/* Load a BMP file, and convert it as a surface */
//SDL_Surface *front = NULL;
front = SDL_LoadBMP("front.bmp");
if (front == NULL) {
fprintf(stderr, "SDL_LoadBMP() failed: %\n", SDL_GetError());
exit(EXIT_FAILURE);
}
press_ESC_to_quit();
return 0;
}
示例11: music_play
void music_play (const char *file,
const char *alias,
uint32_t rate)
{
int audio_format = MIX_DEFAULT_FORMAT;
int audio_channels = 2;
int audio_buffers = 4096;
if (!music_init_done) {
if (Mix_OpenAudio(rate,
audio_format,
audio_channels,
audio_buffers) != 0) {
MSG_BOX("Mix_OpenAudio fail: %s %s",
Mix_GetError(), SDL_GetError());
SDL_ClearError();
}
music_init_done = true;
}
musicp music = music_load(file, alias);
music_update_volume();
static int sound_loaded;
if (!sound_loaded) {
sound_loaded = true;
sound_load_all();
}
if (HEADLESS) {
return;
}
if (Mix_FadeInMusicPos(music->music, -1, 2000, 0) == -1) {
// if (Mix_PlayMusic(music->music, -1) == -1) {
WARN("cannot play music %s: %s", music->tree.key, Mix_GetError());
}
}
示例12: keyboard_getScancodeNameNegative
/**
* @brief SDL_GetScancodeName negative cases
*
* @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeName
*/
int
keyboard_getScancodeNameNegative(void *arg)
{
SDL_Scancode scancode;
char *result;
char *expected = "";
/* Clear error message */
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
/* Out-of-bounds scancode */
scancode = (SDL_Scancode)SDL_NUM_SCANCODES;
result = (char *)SDL_GetScancodeName(scancode);
SDLTest_AssertPass("Call to SDL_GetScancodeName(%d/large)", scancode);
SDLTest_AssertCheck(result != NULL, "Verify result from call is not NULL");
SDLTest_AssertCheck(SDL_strcmp(result, expected) == 0, "Verify result from call is valid, expected: '%s', got: '%s'", expected, result);
_checkInvalidScancodeError();
return TEST_COMPLETED;
}
示例13: SDL_Init
DECLSPEC int SDLCALL SDL_Init(Uint32 flags) {
#if !SDL_THREADS_DISABLED && SDL_THREAD_PTH
if (!pth_init()) {
return -1;
}
#endif
/* Clear the error message */
SDL_ClearError();
/* Initialize the desired subsystems */
if ( SDL_InitSubSystem(flags) < 0 ) {
return(-1);
}
/* Everything is initialized */
if ( !(flags & SDL_INIT_NOPARACHUTE) ) {
SDL_InstallParachute();
}
return(0);
}
示例14: SDL_TTF_VERSION
TTF_system::TTF_system()
{
SDL_version compiled;
SDL_TTF_VERSION(&compiled);
SDL_version const* linked = TTF_Linked_Version();
log_status(log_scope::ENGINE, log_line_seperator);
log_status(log_scope::ENGINE, "Compiled against SDL_ttf version {}.{}.{}",
(unsigned)compiled.major, (unsigned)compiled.minor, (unsigned)compiled.patch);
log_status(log_scope::ENGINE, "Linked against SDL_ttf version {}.{}.{}",
(unsigned)linked->major, (unsigned)linked->minor, (unsigned)linked->patch);
log_status(log_scope::ENGINE, log_line_seperator);
if(TTF_Init() != 0)
{
log_error(log_scope::ENGINE, "Error initializing SDL_ttf: {}", TTF_GetError());
SDL_ClearError();
throw fatal_construction_exception{};
}
}
示例15: ConvertSurface
static SDL_Surface* ConvertSurface(bool* Continue, bool* Error, SDL_Surface* Source, const char* Name)
{
SDL_Surface* Dest;
if (Source->format->Amask != 0)
Dest = SDL_DisplayFormatAlpha(Source);
else
Dest = SDL_DisplayFormat(Source);
if (Dest == NULL)
{
*Continue = false; *Error = true;
printf("%s: SDL_ConvertSurface failed: %s\n", Name, SDL_GetError());
SDL_ClearError();
return NULL;
}
else
{
printf("Successfully converted %s to the screen's pixel format\n", Name);
SDL_FreeSurface(Source);
return Dest;
}
}