Updated SDL 1.3 to the latest hg-5868:33245988e8a2 , video resize is not supported yet
This commit is contained in:
@@ -1,33 +1,36 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2010 Sam Lantinga
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_atomic.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_assert_c.h"
|
||||
#include "video/SDL_sysvideo.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
#ifdef __WIN32__
|
||||
#include "core/windows/SDL_windows.h"
|
||||
|
||||
#ifndef WS_OVERLAPPEDWINDOW
|
||||
#define WS_OVERLAPPEDWINDOW 0
|
||||
#endif
|
||||
#else /* fprintf, _exit(), etc. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -41,8 +44,7 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
|
||||
* We keep all triggered assertions in a singly-linked list so we can
|
||||
* generate a report later.
|
||||
*/
|
||||
static SDL_assert_data assertion_list_terminator = { 0, 0, 0, 0, 0, 0, 0 };
|
||||
static SDL_assert_data *triggered_assertions = &assertion_list_terminator;
|
||||
static SDL_assert_data *triggered_assertions = NULL;
|
||||
|
||||
static SDL_mutex *assertion_mutex = NULL;
|
||||
static SDL_AssertionHandler assertion_handler = SDL_PromptAssertion;
|
||||
@@ -56,11 +58,12 @@ debug_print(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
|
||||
static void
|
||||
debug_print(const char *fmt, ...)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
#ifdef __WIN32__
|
||||
/* Format into a buffer for OutputDebugStringA(). */
|
||||
char buf[1024];
|
||||
char *startptr;
|
||||
char *ptr;
|
||||
LPTSTR tstr;
|
||||
int len;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
@@ -77,15 +80,19 @@ debug_print(const char *fmt, ...)
|
||||
for (ptr = startptr; *ptr; ptr++) {
|
||||
if (*ptr == '\n') {
|
||||
*ptr = '\0';
|
||||
OutputDebugStringA(startptr);
|
||||
OutputDebugStringA("\r\n");
|
||||
tstr = WIN_UTF8ToString(startptr);
|
||||
OutputDebugString(tstr);
|
||||
SDL_free(tstr);
|
||||
OutputDebugString(TEXT("\r\n"));
|
||||
startptr = ptr+1;
|
||||
}
|
||||
}
|
||||
|
||||
/* catch that last piece if it didn't have a newline... */
|
||||
if (startptr != ptr) {
|
||||
OutputDebugStringA(startptr);
|
||||
tstr = WIN_UTF8ToString(startptr);
|
||||
OutputDebugString(tstr);
|
||||
SDL_free(tstr);
|
||||
}
|
||||
#else
|
||||
/* Unix has it easy. Just dump it to stderr. */
|
||||
@@ -98,7 +105,7 @@ debug_print(const char *fmt, ...)
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#ifdef __WIN32__
|
||||
static SDL_assert_state SDL_Windows_AssertChoice = SDL_ASSERTION_ABORT;
|
||||
static const SDL_assert_data *SDL_Windows_AssertData = NULL;
|
||||
|
||||
@@ -112,6 +119,7 @@ SDL_Assertion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
/* !!! FIXME: all this code stinks. */
|
||||
const SDL_assert_data *data = SDL_Windows_AssertData;
|
||||
char buf[1024];
|
||||
LPTSTR tstr;
|
||||
const int w = 100;
|
||||
const int h = 25;
|
||||
const int gap = 10;
|
||||
@@ -120,14 +128,14 @@ SDL_Assertion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
int len;
|
||||
int i;
|
||||
static const struct {
|
||||
const char *name;
|
||||
LPCTSTR name;
|
||||
SDL_assert_state state;
|
||||
} buttons[] = {
|
||||
{"Abort", SDL_ASSERTION_ABORT },
|
||||
{"Break", SDL_ASSERTION_BREAK },
|
||||
{"Retry", SDL_ASSERTION_RETRY },
|
||||
{"Ignore", SDL_ASSERTION_IGNORE },
|
||||
{"Always Ignore", SDL_ASSERTION_ALWAYS_IGNORE },
|
||||
{TEXT("Abort"), SDL_ASSERTION_ABORT },
|
||||
{TEXT("Break"), SDL_ASSERTION_BREAK },
|
||||
{TEXT("Retry"), SDL_ASSERTION_RETRY },
|
||||
{TEXT("Ignore"), SDL_ASSERTION_IGNORE },
|
||||
{TEXT("Always Ignore"), SDL_ASSERTION_ALWAYS_IGNORE },
|
||||
};
|
||||
|
||||
len = (int) SDL_snprintf(buf, sizeof (buf),
|
||||
@@ -139,14 +147,16 @@ SDL_Assertion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
buf[sizeof (buf) - 1] = '\0';
|
||||
}
|
||||
|
||||
CreateWindowA("STATIC", buf,
|
||||
tstr = WIN_UTF8ToString(buf);
|
||||
CreateWindow(TEXT("STATIC"), tstr,
|
||||
WS_VISIBLE | WS_CHILD | SS_LEFT,
|
||||
x, y, 550, 100,
|
||||
hwnd, (HMENU) 1, NULL, NULL);
|
||||
SDL_free(tstr);
|
||||
y += 110;
|
||||
|
||||
for (i = 0; i < (sizeof (buttons) / sizeof (buttons[0])); i++) {
|
||||
CreateWindowA("BUTTON", buttons[i].name,
|
||||
CreateWindow(TEXT("BUTTON"), buttons[i].name,
|
||||
WS_VISIBLE | WS_CHILD,
|
||||
x, y, w, h,
|
||||
hwnd, (HMENU) buttons[i].state, NULL, NULL);
|
||||
@@ -206,7 +216,8 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data)
|
||||
{
|
||||
/* (data) is always a static struct defined with the assert macros, so
|
||||
we don't have to worry about copying or allocating them. */
|
||||
if (data->next == NULL) { /* not yet added? */
|
||||
data->trigger_count++;
|
||||
if (data->trigger_count == 1) { /* not yet added? */
|
||||
data->next = triggered_assertions;
|
||||
triggered_assertions = data;
|
||||
}
|
||||
@@ -215,19 +226,14 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data)
|
||||
|
||||
static void SDL_GenerateAssertionReport(void)
|
||||
{
|
||||
const SDL_assert_data *item;
|
||||
const SDL_assert_data *item = triggered_assertions;
|
||||
|
||||
/* only do this if the app hasn't assigned an assertion handler. */
|
||||
if (assertion_handler != SDL_PromptAssertion)
|
||||
return;
|
||||
|
||||
item = SDL_GetAssertionReport();
|
||||
if (item->condition)
|
||||
{
|
||||
if ((item != NULL) && (assertion_handler != SDL_PromptAssertion)) {
|
||||
debug_print("\n\nSDL assertion report.\n");
|
||||
debug_print("All SDL assertions between last init/quit:\n\n");
|
||||
|
||||
while (item->condition) {
|
||||
while (item != NULL) {
|
||||
debug_print(
|
||||
"'%s'\n"
|
||||
" * %s (%s:%d)\n"
|
||||
@@ -247,7 +253,7 @@ static void SDL_GenerateAssertionReport(void)
|
||||
|
||||
static void SDL_ExitProcess(int exitcode)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
#ifdef __WIN32__
|
||||
ExitProcess(42);
|
||||
#else
|
||||
_exit(42);
|
||||
@@ -310,10 +316,10 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
|
||||
|
||||
/* platform-specific UI... */
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#ifdef __WIN32__
|
||||
state = SDL_PromptAssertion_windows(data);
|
||||
|
||||
#elif __MACOSX__
|
||||
#elif defined __MACOSX__ && defined SDL_VIDEO_DRIVER_COCOA
|
||||
/* This has to be done in an Objective-C (*.m) file, so we call out. */
|
||||
extern SDL_assert_state SDL_PromptAssertion_cocoa(const SDL_assert_data *);
|
||||
state = SDL_PromptAssertion_cocoa(data);
|
||||
@@ -331,16 +337,16 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
|
||||
if (SDL_strcmp(buf, "a") == 0) {
|
||||
state = SDL_ASSERTION_ABORT;
|
||||
break;
|
||||
} else if (SDL_strcmp(envr, "b") == 0) {
|
||||
} else if (SDL_strcmp(buf, "b") == 0) {
|
||||
state = SDL_ASSERTION_BREAK;
|
||||
break;
|
||||
} else if (SDL_strcmp(envr, "r") == 0) {
|
||||
} else if (SDL_strcmp(buf, "r") == 0) {
|
||||
state = SDL_ASSERTION_RETRY;
|
||||
break;
|
||||
} else if (SDL_strcmp(envr, "i") == 0) {
|
||||
} else if (SDL_strcmp(buf, "i") == 0) {
|
||||
state = SDL_ASSERTION_IGNORE;
|
||||
break;
|
||||
} else if (SDL_strcmp(envr, "A") == 0) {
|
||||
} else if (SDL_strcmp(buf, "A") == 0) {
|
||||
state = SDL_ASSERTION_ALWAYS_IGNORE;
|
||||
break;
|
||||
}
|
||||
@@ -387,8 +393,6 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
|
||||
|
||||
SDL_AddAssertionToReport(data);
|
||||
|
||||
data->trigger_count++;
|
||||
|
||||
assertion_running++;
|
||||
if (assertion_running > 1) { /* assert during assert! Abort. */
|
||||
if (assertion_running == 2) {
|
||||
@@ -461,16 +465,16 @@ const SDL_assert_data *SDL_GetAssertionReport(void)
|
||||
|
||||
void SDL_ResetAssertionReport(void)
|
||||
{
|
||||
SDL_assert_data *item = triggered_assertions;
|
||||
SDL_assert_data *next = NULL;
|
||||
for (item = triggered_assertions; item->condition; item = next) {
|
||||
SDL_assert_data *item;
|
||||
for (item = triggered_assertions; item != NULL; item = next) {
|
||||
next = (SDL_assert_data *) item->next;
|
||||
item->always_ignore = SDL_FALSE;
|
||||
item->trigger_count = 0;
|
||||
item->next = NULL;
|
||||
}
|
||||
|
||||
triggered_assertions = &assertion_list_terminator;
|
||||
triggered_assertions = NULL;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user