Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
07bf163c
Commit
07bf163c
authored
25 years ago
by
Marcus Comstedt
Browse files
Options
Downloads
Patches
Plain Diff
Fixed basic mipmap support (only decodes fullsize texture for now).
Rev: src/modules/Image/encodings/pvr.c:1.4
parent
902a5594
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/Image/encodings/pvr.c
+21
-11
21 additions, 11 deletions
src/modules/Image/encodings/pvr.c
with
21 additions
and
11 deletions
src/modules/Image/encodings/pvr.c
+
21
−
11
View file @
07bf163c
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#include
<ctype.h>
#include
<ctype.h>
#include
"stralloc.h"
#include
"stralloc.h"
RCSID
(
"$Id: pvr.c,v 1.
3
2000/02/27 1
3
:0
6:45
marcus Exp $"
);
RCSID
(
"$Id: pvr.c,v 1.
4
2000/02/27 1
4
:0
1:31
marcus Exp $"
);
#include
"pike_macros.h"
#include
"pike_macros.h"
#include
"object.h"
#include
"object.h"
#include
"constants.h"
#include
"constants.h"
...
@@ -268,13 +268,15 @@ void img_pvr_decode(INT32 args,int header_only)
...
@@ -268,13 +268,15 @@ void img_pvr_decode(INT32 args,int header_only)
len
=
str
->
len
;
len
=
str
->
len
;
pop_n_elems
(
args
-
1
);
pop_n_elems
(
args
-
1
);
if
(
len
>=
12
&&
!
strncmp
(
s
,
"GBIX"
,
4
)
&&
if
(
len
>=
12
&&
!
strncmp
(
s
,
"GBIX"
,
4
))
{
s
[
4
]
==
4
&&
s
[
5
]
==
0
&&
s
[
6
]
==
0
&&
s
[
7
]
==
0
)
{
INT32
l
=
s
[
4
]
|
(
s
[
5
]
<<
8
)
|
(
s
[
6
]
<<
16
)
|
(
s
[
7
]
<<
24
);
push_text
(
"global_index"
);
if
(
l
>=
4
&&
l
<=
len
-
8
)
{
push_int
(
s
[
8
]
|
(
s
[
9
]
<<
8
)
|
(
s
[
10
]
<<
16
)
|
(
s
[
11
]
<<
24
));
push_text
(
"global_index"
);
n
++
;
push_int
(
s
[
8
]
|
(
s
[
9
]
<<
8
)
|
(
s
[
10
]
<<
16
)
|
(
s
[
11
]
<<
24
));
len
-=
12
;
n
++
;
s
+=
12
;
len
-=
l
+
8
;
s
+=
l
+
8
;
}
}
}
if
(
len
<
16
||
strncmp
(
s
,
"PVRT"
,
4
))
if
(
len
<
16
||
strncmp
(
s
,
"PVRT"
,
4
))
...
@@ -313,10 +315,12 @@ void img_pvr_decode(INT32 args,int header_only)
...
@@ -313,10 +315,12 @@ void img_pvr_decode(INT32 args,int header_only)
int
twiddle
=
0
,
hasalpha
=
0
,
bpp
=
0
;
int
twiddle
=
0
,
hasalpha
=
0
,
bpp
=
0
;
struct
object
*
o
;
struct
object
*
o
;
struct
image
*
img
;
struct
image
*
img
;
INT32
mipmap
=
0
;
switch
(
attr
&
0xff00
)
{
switch
(
attr
&
0xff00
)
{
case
MODE_TWIDDLE
:
case
MODE_TWIDDLE_MIPMAP
:
case
MODE_TWIDDLE_MIPMAP
:
mipmap
=
1
;
case
MODE_TWIDDLE
:
twiddle
=
1
;
twiddle
=
1
;
if
(
w
!=
h
||
w
<
8
||
w
>
1024
||
(
w
&
(
w
-
1
)))
if
(
w
!=
h
||
w
<
8
||
w
>
1024
||
(
w
&
(
w
-
1
)))
error
(
"invalid size for twiddle texture
\n
"
);
error
(
"invalid size for twiddle texture
\n
"
);
...
@@ -336,7 +340,7 @@ void img_pvr_decode(INT32 args,int header_only)
...
@@ -336,7 +340,7 @@ void img_pvr_decode(INT32 args,int header_only)
case
MODE_CLUT4_MIPMAP
:
case
MODE_CLUT4_MIPMAP
:
case
MODE_CLUT8
:
case
MODE_CLUT8
:
case
MODE_CLUT8_MIPMAP
:
case
MODE_CLUT8_MIPMAP
:
error
(
"palette PVRs not supported
\n
"
);
error
(
"palette PVRs not supported
\n
"
);
default:
default:
error
(
"unknown PVR format
\n
"
);
error
(
"unknown PVR format
\n
"
);
}
}
...
@@ -358,9 +362,15 @@ void img_pvr_decode(INT32 args,int header_only)
...
@@ -358,9 +362,15 @@ void img_pvr_decode(INT32 args,int header_only)
error
(
"unknown PVR color mode
\n
"
);
error
(
"unknown PVR color mode
\n
"
);
}
}
if
(
len
<
(
INT32
)
bpp
*
h
*
w
)
if
(
mipmap
)
for
(
x
=
w
;
x
>>=
1
;)
mipmap
+=
x
*
x
;
if
(
len
<
(
INT32
)(
bpp
*
(
h
*
w
+
mipmap
)))
error
(
"short PVRT chunk
\n
"
);
error
(
"short PVRT chunk
\n
"
);
s
+=
bpp
*
mipmap
;
push_text
(
"image"
);
push_text
(
"image"
);
push_int
(
w
);
push_int
(
w
);
push_int
(
h
);
push_int
(
h
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment