UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
r_thread.cpp
Go to the documentation of this file.
1
4
5
/*
6
Copyright(c) 1997-2001 Id Software, Inc.
7
Copyright(c) 2006 Quake2World.
8
9
This program is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License
11
as published by the Free Software Foundation; either version 2
12
of the License, or(at your option) any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18
See the GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, 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
34
renderer_threadstate_t
r_threadstate
;
35
36
#define THREAD_SLEEP_INTERVAL 5
37
38
int
R_RunThread
(
void
* p)
39
{
40
while
(
r_threads
->integer) {
41
if
(!
refdef
.ready) {
42
Sys_Sleep
(
THREAD_SLEEP_INTERVAL
);
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
53
R_SetupFrustum
();
54
55
/* draw brushes on current worldlevel */
56
R_GetLevelSurfaceLists
();
57
59
60
r_threadstate
.state =
THREAD_RENDERER
;
61
}
62
63
return
0;
64
}
65
69
void
R_ShutdownThreads
(
void
)
70
{
71
if
(
r_threadstate
.thread) {
72
const
int
old =
r_threads
->integer;
73
r_threads
->integer = 0;
74
r_threadstate
.state =
THREAD_BSP
;
75
SDL_WaitThread(
r_threadstate
.thread,
nullptr
);
76
r_threads
->integer = old;
77
}
78
79
r_threadstate
.thread =
nullptr
;
80
}
81
85
void
R_InitThreads
(
void
)
86
{
87
r_threadstate
.thread =
Com_CreateThread
(
R_RunThread
,
"RendererThread"
);
88
}
THREAD_RENDERER
@ THREAD_RENDERER
Definition
cl_renderer.h:214
THREAD_BSP
@ THREAD_BSP
Definition
cl_renderer.h:213
r_threadstate
renderer_threadstate_t r_threadstate
Definition
r_thread.cpp:34
refdef
rendererData_t refdef
Definition
r_main.cpp:45
R_GetLevelSurfaceLists
void R_GetLevelSurfaceLists(void)
Fills the surface chains for the current worldlevel and hide other levels.
Definition
r_bsp.cpp:281
r_local.h
local graphics definitions
R_SetupFrustum
void R_SetupFrustum(void)
Definition
r_main.cpp:137
r_threads
cvar_t * r_threads
Definition
r_main.cpp:93
THREAD_SLEEP_INTERVAL
#define THREAD_SLEEP_INTERVAL
Definition
r_thread.cpp:36
R_RunThread
int R_RunThread(void *p)
Definition
r_thread.cpp:38
R_ShutdownThreads
void R_ShutdownThreads(void)
Definition
r_thread.cpp:69
R_InitThreads
void R_InitThreads(void)
Definition
r_thread.cpp:85
renderer_threadstate_t
Definition
cl_renderer.h:225
system.h
System specific stuff.
Sys_Sleep
void Sys_Sleep(int milliseconds)
Definition
unix_shared.cpp:68
thread.h
Com_CreateThread
SDL_Thread * Com_CreateThread(int(*fn)(void *), const char *name, void *data=nullptr)
Definition
thread.h:5
src
client
renderer
r_thread.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0