本文整理汇总了C++中SDL_Log函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_Log函数的具体用法?C++ SDL_Log怎么用?C++ SDL_Log使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_Log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_Log
/**
* @brief Lock Surface to Modify Pixels
*/
void SurfaceManager::lockSurface(int surfaceType)
{
if(SDL_MUSTLOCK(m_surfaceList[surfaceType]->getSurface()))
{
if(SDL_LockSurface(m_surfaceList[surfaceType]->getSurface()) < 0)
{
SDL_Log("lockSurface(): %s", SDL_GetError());
assert(false);
}
}
}
示例2: Android_OnTouch
void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
{
SDL_TouchID touchDeviceId = 0;
SDL_FingerID fingerId = 0;
int window_x, window_y;
if (!Android_Window) {
return;
}
touchDeviceId = (SDL_TouchID)touch_device_id_in;
if (SDL_AddTouch(touchDeviceId, "") < 0) {
SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
}
fingerId = (SDL_FingerID)pointer_finger_id_in;
switch (action) {
case ACTION_DOWN:
case ACTION_POINTER_1_DOWN:
if (!leftFingerDown) {
Android_GetWindowCoordinates(x, y, &window_x, &window_y);
/* send moved event */
SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
/* send mouse down event */
SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
leftFingerDown = fingerId;
}
SDL_SendTouch(touchDeviceId, fingerId, SDL_TRUE, x, y, p);
break;
case ACTION_MOVE:
if (!leftFingerDown) {
Android_GetWindowCoordinates(x, y, &window_x, &window_y);
/* send moved event */
SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
}
SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p);
break;
case ACTION_UP:
case ACTION_POINTER_1_UP:
if (fingerId == leftFingerDown) {
/* send mouse up */
SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
leftFingerDown = 0;
}
SDL_SendTouch(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
break;
default:
break;
}
}
示例3: SDL_Log
void HudLayer::pauseGame(IMainGame* game, Music music) {
SDL_Log("Game Paused");
if (game->checkPaused() == false) {
game->setPaused();
music.audioPauseBG();
}
else {
game->setRunning();
music.audioResumeBG();
}
}
示例4: SDL_Log
FontManager::~FontManager()
{
for(auto kv : fonts)
{
SDL_Log("Releasing font %s", kv.first.c_str());
TTF_CloseFont(kv.second);
}
//TODO: Move the ttf out.
TTF_Quit();
}
示例5: getRealName
TTF_Font *FontManager::getFontWithName(const std::string &fontName, const int pointSize)
{
std::string realName = getRealName(fontName, pointSize);
std::map<std::string, TTF_Font *>::iterator finder = fonts.find(realName);
if(finder == fonts.end())
{
SDL_Log("Couldn't load font: %s, loading now", fontName.c_str());
loadFontWithName(fontName, pointSize);
}
return fonts.at(realName);
}
示例6: jeti_exit
void jeti_exit (void) {
if ( sdl_thread_serial_jeti != NULL ) {
SDL_Log("jeti: wait thread\n");
SDL_WaitThread(sdl_thread_serial_jeti, NULL);
sdl_thread_serial_jeti = NULL;
}
if (jeti_serial_fd >= 0) {
close(jeti_serial_fd);
jeti_serial_fd = -1;
}
}
示例7: jeti_init
uint8_t jeti_init (char *mdevice, uint32_t baud) {
strncpy(jeti_line1, "--- Jeti Box ---", 16);
strncpy(jeti_line2, " wait for data ", 16);
SDL_Log("jeti: init\n");
jeti_thread_running = 1;
SDL_Log("jeti: init serial port...\n");
jeti_serial_fd = serial_open9b(mdevice, baud);
if (jeti_serial_fd != -1) {
#ifdef SDL2
sdl_thread_serial_jeti = SDL_CreateThread(thread_serial_jeti, NULL, NULL);
#else
sdl_thread_serial_jeti = SDL_CreateThread(thread_serial_jeti, NULL);
#endif
if ( sdl_thread_serial_jeti == NULL ) {
fprintf(stderr, "* Unable to create thread_serial_jeti: %s\n", SDL_GetError());
return 1;
}
}
return 0;
}
示例8: button_messagebox
static int SDLCALL
button_messagebox(void *eventNumber)
{
const SDL_MessageBoxButtonData buttons[] = {
{
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT,
0,
"OK"
},{
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT,
1,
"Cancel"
},
};
SDL_MessageBoxData data = {
SDL_MESSAGEBOX_INFORMATION,
NULL, /* no parent window */
"Custom MessageBox",
"This is a custom messagebox",
2,
NULL,/* buttons */
NULL /* Default color scheme */
};
int button = -1;
int success = 0;
data.buttons = buttons;
if (eventNumber) {
data.message = "This is a custom messagebox from a background thread.";
}
success = SDL_ShowMessageBox(&data, &button);
if (success == -1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
if (eventNumber) {
SDL_UserEvent event;
event.type = (intptr_t)eventNumber;
SDL_PushEvent((SDL_Event*)&event);
return 1;
} else {
quit(2);
}
}
SDL_Log("Pressed button: %d, %s\n", button, button == -1 ? "[closed]" : button == 1 ? "Cancel" : "OK");
if (eventNumber) {
SDL_UserEvent event;
event.type = (intptr_t)eventNumber;
SDL_PushEvent((SDL_Event*)&event);
}
return 0;
}
示例9: test_sort
static void
test_sort(const char *desc, int *nums, const int arraylen)
{
int i;
int prev;
SDL_Log("test: %s arraylen=%d", desc, arraylen);
SDL_qsort(nums, arraylen, sizeof (nums[0]), num_compare);
prev = nums[0];
for (i = 1; i < arraylen; i++) {
const int val = nums[i];
if (val < prev) {
SDL_Log("sort is broken!");
return;
}
prev = val;
}
}
示例10: Texture_LockTexture
bool Texture_LockTexture(Texture* texture)
{
bool success = true;
if (texture->pixels != nullptr)
{
SDL_Log("Texture already locked!\n");
success = false;
}
else
{
if (SDL_LockTexture(texture->texture, NULL, &texture->pixels, &texture->pitch) != 0)
{
SDL_Log("Unable to lock texture! %s\n", SDL_GetError());
success = false;
}
}
return success;
}
示例11: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
if(!demo.init())
{
SDL_Log("Engine Init failed!");
}
demo.run();
return 0;
}
示例12: SDL_Init
Display::Display(float &WIDTH, float &HEIGHT, std::string title, bool fullscreen)
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetSwapInterval(0);
SDL_ShowCursor(0);
if(fullscreen){
SDL_DisplayMode dm;
if (SDL_GetDesktopDisplayMode(0, &dm) != 0){
SDL_Log("SDL_GetDesktopDisplayMode failed: %s", SDL_GetError());
}
this->width = dm.w;
this->height = dm.h;
WIDTH = this->width;
HEIGHT = this->height;
}else{
this->width = WIDTH;
this->height = HEIGHT;
}
window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, SDL_WINDOW_OPENGL | (fullscreen ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE));
glContext = SDL_GL_CreateContext(window);
GLenum status = glewInit();
if(status != GLEW_OK){
std::cerr << "Glew failed to initialize !" << std::endl;
}
isWindowClosed = false;
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glViewport(0.0f, 0.0f, WIDTH, HEIGHT);
lastFrameTime = SDL_GetTicks();
oneFrameDuration = 1000.0f / (float)MAX_FPS;
}
示例13: print_devices
static void
print_devices(int iscapture)
{
const char *typestr = ((iscapture) ? "capture" : "output");
int n = SDL_GetNumAudioDevices(iscapture);
SDL_Log("%s devices:\n", typestr);
if (n == -1)
SDL_Log(" Driver can't detect specific %s devices.\n\n", typestr);
else if (n == 0)
SDL_Log(" No %s devices found.\n\n", typestr);
else {
int i;
for (i = 0; i < n; i++) {
SDL_Log(" %s\n", SDL_GetAudioDeviceName(i, iscapture));
}
SDL_Log("\n");
}
}
示例14: FileLoaderSdlTexture
SDL_Texture* FileLoaderSdlTexture(std::string szFilePath)
{
//Load the texture
SDL_Texture* pTex = IMG_LoadTexture(CAsset::Get()->GetSdlRenderer(), szFilePath.c_str());
if (pTex == NULL)
{
SDL_Log("Error - IMG_LoadTexture - %s.\n", SDL_GetError());
assert(false);
}
return pTex;
}
示例15: KW_ProcessEvents
int KW_ProcessEvents(KW_GUI * gui) {
int i = 0;
SDL_LockMutex(gui->evqueuelock);
for (i = 0; i < gui->evqueuesize; i++) {
SDL_Event * event = gui->evqueue + i;
switch (event->type) {
case SDL_MOUSEMOTION:
MouseMoved(gui, event->motion.x, event->motion.y, event->motion.xrel, event->motion.yrel);
break;
case SDL_MOUSEBUTTONDOWN:
MousePressed(gui, event->button.x, event->button.y, event->button.button);
break;
case SDL_MOUSEBUTTONUP:
MouseReleased(gui, event->button.x, event->button.y, event->button.button);
break;
case SDL_TEXTINPUT:
SDL_Log("Got a textready: %s\n", event->text.text);
TextInputReady(gui, event->text.text);
break;
case SDL_TEXTEDITING:
SDL_Log("Got a textediting: %d %d %d %s\n", event->edit.start, event->edit.length, event->edit.type, event->edit.text);
break;
case SDL_KEYDOWN:
KeyDown(gui, event->key.keysym.sym, event->key.keysym.scancode);
break;
case SDL_KEYUP:
KeyUp(gui, event->key.keysym.sym, event->key.keysym.scancode);
break;
default:
break;
}
}
gui->evqueuesize = 0;
SDL_UnlockMutex(gui->evqueuelock);
return 0;
}