Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
5a0dcc90
S
stb
项目概览
itdan3344
/
stb
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5a0dcc90
编写于
2月 22, 2015
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
initialize cache mutexes in right file
上级
cd17050c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
7 deletion
+13
-7
tests/caveview/cave_mesher.c
tests/caveview/cave_mesher.c
+6
-0
tests/caveview/cave_render.c
tests/caveview/cave_render.c
+7
-7
未找到文件。
tests/caveview/cave_mesher.c
浏览文件 @
5a0dcc90
// This file takes minecraft chunks (decoded by cave_parse) and
// uses stb_voxel_render to turn them into vertex buffers.
#define STB_GLEXT_DECLARE "glext_list.h"
#include "stb_gl.h"
...
...
@@ -452,6 +454,7 @@ void reset_cache_size(int size)
cache_size
=
size
;
}
// this must be called inside mutex
void
deref_fastchunk
(
fast_chunk
*
fc
)
{
if
(
fc
)
{
...
...
@@ -672,6 +675,9 @@ void mesh_init(void)
{
int
i
;
chunk_cache_mutex
=
SDL_CreateMutex
();
chunk_get_mutex
=
SDL_CreateMutex
();
for
(
i
=
0
;
i
<
256
;
++
i
)
{
memcpy
(
minecraft_tex1_for_blocktype
[
i
],
minecraft_info
[
i
]
+
1
,
6
);
minecraft_trans_for_blocktype
[
i
]
=
(
minecraft_info
[
i
][
0
]
!=
C_solid
&&
minecraft_info
[
i
][
0
]
!=
C_water
);
...
...
tests/caveview/cave_render.c
浏览文件 @
5a0dcc90
// This file takes renders vertex buffers and manages
// threads that invoke mesh building (found in cave_mesher.c)
#include "stb_voxel_render.h"
#define STB_GLEXT_DECLARE "glext_list.h"
...
...
@@ -57,10 +60,6 @@ typedef struct
}
chunk_mesh
;
extern
SDL_mutex
*
chunk_cache_mutex
;
extern
SDL_mutex
*
chunk_get_mutex
;
void
scale_texture
(
unsigned
char
*
src
,
int
x
,
int
y
,
int
w
,
int
h
)
{
int
i
,
j
,
k
;
...
...
@@ -511,6 +510,8 @@ void world_init(void)
reset_cache_size
(
32
);
}
extern
SDL_mutex
*
chunk_cache_mutex
;
int
mesh_worker_handler
(
void
*
data
)
{
mesh_worker
*
mw
=
data
;
...
...
@@ -549,6 +550,8 @@ int mesh_worker_handler(void *data)
// when done, free the chunks
// for efficiency we just take the mutex once around the whole thing,
// though this spreads the mutex logic over two files
SDL_LockMutex
(
chunk_cache_mutex
);
for
(
j
=
0
;
j
<
4
;
++
j
)
for
(
i
=
0
;
i
<
4
;
++
i
)
{
...
...
@@ -594,9 +597,6 @@ void prepare_threads(void)
if
(
num_mesh_workers
>
MAX_MESH_WORKERS
)
num_mesh_workers
=
MAX_MESH_WORKERS
;
chunk_cache_mutex
=
SDL_CreateMutex
();
chunk_get_mutex
=
SDL_CreateMutex
();
for
(
i
=
0
;
i
<
num_mesh_workers
;
++
i
)
{
mesh_worker
*
data
=
&
mesh_data
[
i
];
data
->
request_received
=
SDL_CreateSemaphore
(
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录