mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 09:53:30 +08:00
fix sdl_fb.c to support gcc under linux
This commit is contained in:
parent
236099e3ec
commit
7c3f2fd6c7
@ -1,6 +1,10 @@
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <sdl.h>
|
||||
#else
|
||||
#include <SDL/SDL.h>
|
||||
#endif
|
||||
#include <rtdevice.h>
|
||||
#include <rtgui/driver.h>
|
||||
|
||||
@ -104,7 +108,7 @@ static void sdlfb_hw_init(void)
|
||||
//_putenv("SDL_VIDEODRIVER=windib");
|
||||
|
||||
//if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO) < 0)
|
||||
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
@ -132,16 +136,24 @@ static void sdlfb_hw_init(void)
|
||||
sdllock = rt_mutex_create("fb", RT_IPC_FLAG_FIFO);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sdl.h>
|
||||
#include <rtgui/event.h>
|
||||
#include <rtgui/kbddef.h>
|
||||
#include <rtgui/rtgui_server.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
static DWORD WINAPI sdl_loop(LPVOID lpParam)
|
||||
#else
|
||||
static void *sdl_loop(void *lpParam)
|
||||
#endif
|
||||
{
|
||||
int quit = 0;
|
||||
SDL_Event event;
|
||||
@ -284,6 +296,7 @@ static DWORD WINAPI sdl_loop(LPVOID lpParam)
|
||||
/* start sdl thread */
|
||||
void rt_hw_sdl_start(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HANDLE thread;
|
||||
DWORD thread_id;
|
||||
|
||||
@ -301,4 +314,15 @@ void rt_hw_sdl_start(void)
|
||||
return;
|
||||
}
|
||||
ResumeThread(thread);
|
||||
#else
|
||||
/* Linux */
|
||||
pthread_t pid;
|
||||
int res;
|
||||
res = pthread_create(&pid, NULL, &sdl_loop, NULL);
|
||||
if (res)
|
||||
{
|
||||
printf("pthread create sdl thread faild, <%d>\n", res);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user