Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
03611a36
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,发现更多精彩内容 >>
提交
03611a36
编写于
3月 03, 2017
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'working'
上级
fab4c61d
e895f6d3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
6 deletion
+18
-6
stb_rect_pack.h
stb_rect_pack.h
+18
-6
未找到文件。
stb_rect_pack.h
浏览文件 @
03611a36
// stb_rect_pack.h - v0.1
0
- public domain - rectangle packing
// stb_rect_pack.h - v0.1
1
- public domain - rectangle packing
// Sean Barrett 2014
//
// Useful for e.g. packing rectangular textures into an atlas.
...
...
@@ -27,11 +27,14 @@
// Sean Barrett
// Minor features
// Martins Mozeiko
// github:IntellectualKitty
//
// Bugfixes / warning fixes
// Jeremy Jaussaud
//
// Version history:
//
// 0.11 (2017-03-03) return packing success/fail result
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
// 0.09 (2016-08-27) fix compiler warnings
// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
...
...
@@ -75,7 +78,7 @@ typedef int stbrp_coord;
typedef
unsigned
short
stbrp_coord
;
#endif
STBRP_DEF
void
stbrp_pack_rects
(
stbrp_context
*
context
,
stbrp_rect
*
rects
,
int
num_rects
);
STBRP_DEF
int
stbrp_pack_rects
(
stbrp_context
*
context
,
stbrp_rect
*
rects
,
int
num_rects
);
// Assign packed locations to rectangles. The rectangles are of type
// 'stbrp_rect' defined below, stored in the array 'rects', and there
// are 'num_rects' many of them.
...
...
@@ -96,6 +99,9 @@ STBRP_DEF void stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int
// arrays will probably produce worse packing results than calling it
// a single time with the full rectangle array, but the option is
// available.
//
// The function returns 1 if all of the rectangles were successfully
// packed and 0 otherwise.
struct
stbrp_rect
{
...
...
@@ -542,9 +548,9 @@ static int rect_original_order(const void *a, const void *b)
#define STBRP__MAXVAL 0xffff
#endif
STBRP_DEF
void
stbrp_pack_rects
(
stbrp_context
*
context
,
stbrp_rect
*
rects
,
int
num_rects
)
STBRP_DEF
int
stbrp_pack_rects
(
stbrp_context
*
context
,
stbrp_rect
*
rects
,
int
num_rects
)
{
int
i
;
int
i
,
all_rects_packed
=
1
;
// we use the 'was_packed' field internally to allow sorting/unsorting
for
(
i
=
0
;
i
<
num_rects
;
++
i
)
{
...
...
@@ -574,9 +580,15 @@ STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int n
// unsort
STBRP_SORT
(
rects
,
num_rects
,
sizeof
(
rects
[
0
]),
rect_original_order
);
// set was_packed flags
for
(
i
=
0
;
i
<
num_rects
;
++
i
)
// set was_packed flags
and all_rects_packed status
for
(
i
=
0
;
i
<
num_rects
;
++
i
)
{
rects
[
i
].
was_packed
=
!
(
rects
[
i
].
x
==
STBRP__MAXVAL
&&
rects
[
i
].
y
==
STBRP__MAXVAL
);
if
(
!
rects
[
i
].
was_packed
)
all_rects_packed
=
0
;
}
// return the all_rects_packed status
return
all_rects_packed
;
}
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录