UFO: Alien Invasion
Loading...
Searching...
No Matches
r_thread.cpp
Go to the documentation of this file.
1
4
5/*
6Copyright(c) 1997-2001 Id Software, Inc.
7Copyright(c) 2006 Quake2World.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or(at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26#include "r_local.h"
27#include "../../ports/system.h"
28#include "../../shared/thread.h"
29
30#ifndef _MSC_VER
31#include <unistd.h>
32#endif
33
35
36#define THREAD_SLEEP_INTERVAL 5
37
38int R_RunThread (void* p)
39{
40 while (r_threads->integer) {
41 if (!refdef.ready) {
43 continue;
44 }
45
46 /* the renderer is up, so busy-wait for it */
47 while (r_threadstate.state != THREAD_BSP)
48 Sys_Sleep(0);
49
50 if (!r_threads->integer)
51 break;
52
54
55 /* draw brushes on current worldlevel */
57
59
61 }
62
63 return 0;
64}
65
70{
71 if (r_threadstate.thread) {
72 const int old = r_threads->integer;
73 r_threads->integer = 0;
75 SDL_WaitThread(r_threadstate.thread, nullptr);
76 r_threads->integer = old;
77 }
78
79 r_threadstate.thread = nullptr;
80}
81
85void R_InitThreads (void)
86{
87 r_threadstate.thread = Com_CreateThread(R_RunThread, "RendererThread");
88}
@ THREAD_RENDERER
@ THREAD_BSP
renderer_threadstate_t r_threadstate
Definition r_thread.cpp:34
rendererData_t refdef
Definition r_main.cpp:45
void R_GetLevelSurfaceLists(void)
Fills the surface chains for the current worldlevel and hide other levels.
Definition r_bsp.cpp:281
local graphics definitions
void R_SetupFrustum(void)
Definition r_main.cpp:137
cvar_t * r_threads
Definition r_main.cpp:93
#define THREAD_SLEEP_INTERVAL
Definition r_thread.cpp:36
int R_RunThread(void *p)
Definition r_thread.cpp:38
void R_ShutdownThreads(void)
Definition r_thread.cpp:69
void R_InitThreads(void)
Definition r_thread.cpp:85
System specific stuff.
void Sys_Sleep(int milliseconds)
Calls the win32 sleep function.
SDL_Thread * Com_CreateThread(int(*fn)(void *), const char *name, void *data=nullptr)
Definition thread.h:5