r_thread.c

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright(c) 1997-2001 Id Software, Inc.
00007 Copyright(c) 2006 Quake2World.
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or(at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018 See the GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 
00024 */
00025 
00026 #include "r_local.h"
00027 #include "../../ports/system.h"
00028 
00029 #include <unistd.h>
00030 #include <SDL_thread.h>
00031 
00032 renderer_threadstate_t r_threadstate;
00033 
00034 #define THREAD_SLEEP_INTERVAL 100
00035 
00036 int R_RunThread (void *p)
00037 {
00038     Com_DPrintf(DEBUG_RENDERER, "R_RunThread: %d\n", SDL_ThreadID());
00039 
00040     while (r_threads->integer) {
00041         if (!refdef.ready) {
00042             Sys_Sleep(THREAD_SLEEP_INTERVAL);
00043             continue;
00044         }
00045 
00046         /* the renderer is up, so busy-wait for it */
00047         while (r_threadstate.state != THREAD_BSP)
00048             Sys_Sleep(0);
00049 
00050         R_SetupFrustum();
00051 
00052         /* draw brushes on current worldlevel */
00053         R_GetLevelSurfaceLists();
00054 
00057         r_threadstate.state = THREAD_RENDERER;
00058     }
00059 
00060     return 0;
00061 }
00062 
00066 void R_ShutdownThreads (void)
00067 {
00068     if (r_threadstate.thread)
00069         SDL_KillThread(r_threadstate.thread);
00070 
00071     r_threadstate.thread = NULL;
00072 }
00073 
00077 void R_InitThreads (void)
00078 {
00079     r_threadstate.thread = SDL_CreateThread(R_RunThread, NULL);
00080 }

Generated by  doxygen 1.6.2