Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Removed libc dependency on Windows again, to fix building with Visual…
Browse files Browse the repository at this point in the history
… C++ 2005 Express Edition.

Fixed performance problem with testsprite2 on the D3D driver.
  • Loading branch information
slouken committed Jul 13, 2006
1 parent 0888dca commit dee4124
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/SDL_config_win32.h
Expand Up @@ -64,7 +64,7 @@ typedef unsigned int uintptr_t;
#define SDL_HAS_64BIT_TYPE 1

/* Enabled for SDL 1.2 (binary compatibility) */
#define HAVE_LIBC 1
//#define HAVE_LIBC 1
#ifdef HAVE_LIBC
/* Useful headers */
#define HAVE_STDIO_H 1
Expand Down
6 changes: 6 additions & 0 deletions include/SDL_stdinc.h
Expand Up @@ -413,6 +413,12 @@ extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2,
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
#endif

#ifdef HAVE_WCSLEN
#define SDL_wcslen wcslen
#else
extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *string);
#endif

#ifdef HAVE_STRLCPY
#define SDL_strlcpy strlcpy
#else
Expand Down
4 changes: 2 additions & 2 deletions src/audio/SDL_audio.c
Expand Up @@ -497,7 +497,7 @@ SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
if (desired->channels == 0) {
env = SDL_getenv("SDL_AUDIO_CHANNELS");
if (env) {
desired->channels = SDL_atoi(env);
desired->channels = (Uint8)SDL_atoi(env);
}
}
if (desired->channels == 0) {
Expand All @@ -517,7 +517,7 @@ SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
if (desired->samples == 0) {
env = SDL_getenv("SDL_AUDIO_SAMPLES");
if (env) {
desired->samples = SDL_atoi(env);
desired->samples = (Uint16)SDL_atoi(env);
}
}
if (desired->samples == 0) {
Expand Down
12 changes: 12 additions & 0 deletions src/stdlib/SDL_string.c
Expand Up @@ -336,6 +336,18 @@ SDL_strlen(const char *string)
}
#endif

#ifndef HAVE_WCSLEN
size_t
SDL_wcslen(const wchar_t *string)
{
size_t len = 0;
while (*string++) {
++len;
}
return len;
}
#endif

#ifndef HAVE_STRLCPY
size_t
SDL_strlcpy(char *dst, const char *src, size_t maxlen)
Expand Down
11 changes: 8 additions & 3 deletions src/video/win32/SDL_d3drender.c
Expand Up @@ -287,6 +287,7 @@ SDL_D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
pparams.Windowed = TRUE;
}
pparams.FullScreen_RefreshRateInHz = 0; /* FIXME */
pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

result = IDirect3D9_CreateDevice(videodata->d3d, D3DADAPTER_DEFAULT, /* FIXME */
D3DDEVTYPE_HAL,
Expand Down Expand Up @@ -431,16 +432,20 @@ SDL_D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 color)
{
SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
D3DRECT d3drect;
HRESULT result;

if (data->beginScene) {
IDirect3DDevice9_BeginScene(data->device);
data->beginScene = SDL_FALSE;
}

result =
IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET,
(D3DCOLOR) color, 1.0f, 0);
d3drect.x1 = rect->x;
d3drect.x2 = rect->x+rect->w;
d3drect.y1 = rect->y;
d3drect.y2 = rect->y+rect->h;

result = IDirect3DDevice9_Clear(data->device, 1, &d3drect, D3DCLEAR_TARGET, (D3DCOLOR) color, 1.0f, 0);
if (FAILED(result)) {
D3D_SetError("Clear()", result);
return -1;
Expand Down
3 changes: 1 addition & 2 deletions src/video/win32/SDL_gdirender.c
Expand Up @@ -79,7 +79,7 @@ SDL_RenderDriver SDL_GDI_RenderDriver = {
SDL_GDI_CreateRenderer,
{
"gdi",
( //SDL_Renderer_Minimal |
(SDL_Renderer_Minimal |
SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
SDL_Renderer_PresentFlip2 | SDL_Renderer_PresentFlip3 |
SDL_Renderer_PresentDiscard | SDL_Renderer_RenderTarget),
Expand Down Expand Up @@ -735,7 +735,6 @@ SDL_GDI_RenderPresent(SDL_Renderer * renderer)
{
SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
SDL_DirtyRect *dirty;
int new_hbm;

/* Send the data to the display */
if (!(renderer->info.flags & SDL_Renderer_SingleBuffer)) {
Expand Down
8 changes: 5 additions & 3 deletions src/video/win32/SDL_win32video.h
Expand Up @@ -32,7 +32,9 @@
#include <windows.h>

#if SDL_VIDEO_RENDER_D3D
#include <d3d9.h>
//#include <d3d9.h>
#define D3D_DEBUG_INFO
#include "d3d9.h"
#endif

#include "SDL_win32events.h"
Expand All @@ -43,10 +45,10 @@
#include "SDL_win32window.h"

#ifdef UNICODE
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (wcslen(S)+1)*sizeof(WCHAR))
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR))
#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1)
#else
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (strlen(S)+1))
#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1))
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
#endif

Expand Down

0 comments on commit dee4124

Please sign in to comment.