Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
vitaquake3
Commits
bb196032
Commit
bb196032
authored
Aug 12, 2019
by
Rinnegatamante
Browse files
Preventing renderer to reorder streams.
parent
53652371
Changes
14
Hide whitespace changes
Inline
Side-by-side
code/psp2/psp2_glimp.c
View file @
bb196032
...
...
@@ -76,11 +76,13 @@ This routine is responsible for initializing the OS specific portions
of OpenGL
===============
*/
uint16_t
*
indices
;
uint16_t
*
gIndexesBuffer
;
uint16_t
*
gIndexesBufferOrdered
;
float
*
gVertexBuffer
;
uint8_t
*
gColorBuffer
;
uint8_t
*
gColorBuffer255
;
float
*
gTexCoordBuffer
;
uint16_t
*
gIndexesBufferPtr
;
float
*
gVertexBufferPtr
;
uint8_t
*
gColorBufferPtr
;
float
*
gTexCoordBufferPtr
;
...
...
@@ -138,20 +140,21 @@ void GLimp_Init( qboolean coreContext)
}
vglStartRendering
();
int
i
;
indices
=
(
uint16_t
*
)
malloc
(
sizeof
(
uint16_t
*
)
*
MAX_INDICES
);
gIndexesBufferOrdered
=
(
uint16_t
*
)
malloc
(
sizeof
(
uint16_t
*
)
*
MAX_INDICES
);
for
(
i
=
0
;
i
<
MAX_INDICES
;
i
++
){
indices
[
i
]
=
i
;
gIndexesBufferOrdered
[
i
]
=
i
;
}
vglIndexPointerMapped
(
indices
);
glEnableClientState
(
GL_VERTEX_ARRAY
);
gVertexBufferPtr
=
(
float
*
)
malloc
(
0x400000
);
gColorBufferPtr
=
(
uint8_t
*
)
malloc
(
0x200000
);
gTexCoordBufferPtr
=
(
float
*
)
malloc
(
0x200000
);
gColorBuffer255
=
(
uint8_t
*
)
malloc
(
0x3000
);
gIndexesBufferPtr
=
(
uint16_t
*
)
vglAlloc
(
0x400000
,
VGL_MEM_RAM
);
gVertexBufferPtr
=
(
float
*
)
vglAlloc
(
0x400000
,
VGL_MEM_RAM
);
gColorBufferPtr
=
(
uint8_t
*
)
vglAlloc
(
0x200000
,
VGL_MEM_RAM
);
gTexCoordBufferPtr
=
(
float
*
)
vglAlloc
(
0x200000
,
VGL_MEM_RAM
);
gColorBuffer255
=
(
uint8_t
*
)
vglAlloc
(
0x3000
,
VGL_MEM_RAM
);
memset
(
gColorBuffer255
,
0xFF
,
0x3000
);
gVertexBuffer
=
gVertexBufferPtr
;
gColorBuffer
=
gColorBufferPtr
;
gTexCoordBuffer
=
gTexCoordBufferPtr
;
gIndexesBuffer
=
gIndexesBufferPtr
;
strncpy
(
glConfig
.
vendor_string
,
glGetString
(
GL_VENDOR
),
sizeof
(
glConfig
.
vendor_string
));
strncpy
(
glConfig
.
renderer_string
,
glGetString
(
GL_RENDERER
),
sizeof
(
glConfig
.
renderer_string
));
...
...
@@ -175,8 +178,8 @@ void GLimp_EndFrame( void )
{
vglStopRendering
();
vglStartRendering
();
vglIndexPointerMapped
(
indices
);
gVertexBuffer
=
gVertexBufferPtr
;
gColorBuffer
=
gColorBufferPtr
;
gTexCoordBuffer
=
gTexCoordBufferPtr
;
gIndexesBuffer
=
gIndexesBufferPtr
;
}
code/qcommon/q_shared.h
View file @
bb196032
...
...
@@ -229,7 +229,7 @@ typedef int clipHandle_t;
#define PADP(base, alignment) ((void *) PAD((intptr_t) (base), (alignment)))
#ifdef
__GNUC__
#if
def
ined(
__GNUC__
) && (!defined(__PSP2__))
#define QALIGN(x) __attribute__((aligned(x)))
#else
#define QALIGN(x)
...
...
code/renderercommon/qgl.h
View file @
bb196032
...
...
@@ -34,7 +34,8 @@ extern float *gVertexBuffer;
extern
uint8_t
*
gColorBuffer
;
extern
uint8_t
*
gColorBuffer255
;
extern
float
*
gTexCoordBuffer
;
extern
uint16_t
*
indices
;
extern
uint16_t
*
gIndexesBuffer
;
extern
uint16_t
*
gIndexesBufferOrdered
;
#include "vitaGL.h"
...
...
code/renderergl1/tr_animation.c
View file @
bb196032
...
...
@@ -412,8 +412,8 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface )
tess
.
normal
[
baseVertex
+
j
][
1
]
=
tempNormal
[
1
];
tess
.
normal
[
baseVertex
+
j
][
2
]
=
tempNormal
[
2
];
tess
.
texCoords
[
baseVertex
+
j
][
0
]
[
0
]
=
v
->
texCoords
[
0
];
tess
.
texCoords
[
baseVertex
+
j
][
0
][
1
]
=
v
->
texCoords
[
1
];
tess
.
texCoords
[
0
][
baseVertex
+
j
][
0
]
=
v
->
texCoords
[
0
];
tess
.
texCoords
[
0
][
baseVertex
+
j
][
1
]
=
v
->
texCoords
[
1
];
v
=
(
mdrVertex_t
*
)
&
v
->
weights
[
v
->
numWeights
];
}
...
...
code/renderergl1/tr_backend.c
View file @
bb196032
...
...
@@ -759,6 +759,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
vglVertexPointer
(
3
,
GL_FLOAT
,
0
,
4
,
vertices
);
vglTexCoordPointer
(
2
,
GL_FLOAT
,
0
,
4
,
texcoords
);
vglIndexPointerMapped
(
gIndexesBufferOrdered
);
vglDrawObjects
(
GL_TRIANGLE_FAN
,
4
,
GL_TRUE
);
}
...
...
@@ -853,29 +854,29 @@ const void *RB_StretchPic ( const void *data ) {
tess
.
xyz
[
numVerts
][
1
]
=
cmd
->
y
;
tess
.
xyz
[
numVerts
][
2
]
=
0
;
tess
.
texCoords
[
numVerts
][
0
]
[
0
]
=
cmd
->
s1
;
tess
.
texCoords
[
numVerts
][
0
][
1
]
=
cmd
->
t1
;
tess
.
texCoords
[
0
][
numVerts
][
0
]
=
cmd
->
s1
;
tess
.
texCoords
[
0
][
numVerts
][
1
]
=
cmd
->
t1
;
tess
.
xyz
[
numVerts
+
1
][
0
]
=
cmd
->
x
+
cmd
->
w
;
tess
.
xyz
[
numVerts
+
1
][
1
]
=
cmd
->
y
;
tess
.
xyz
[
numVerts
+
1
][
2
]
=
0
;
tess
.
texCoords
[
numVerts
+
1
][
0
]
[
0
]
=
cmd
->
s2
;
tess
.
texCoords
[
numVerts
+
1
][
0
][
1
]
=
cmd
->
t1
;
tess
.
texCoords
[
0
][
numVerts
+
1
][
0
]
=
cmd
->
s2
;
tess
.
texCoords
[
0
][
numVerts
+
1
][
1
]
=
cmd
->
t1
;
tess
.
xyz
[
numVerts
+
2
][
0
]
=
cmd
->
x
+
cmd
->
w
;
tess
.
xyz
[
numVerts
+
2
][
1
]
=
cmd
->
y
+
cmd
->
h
;
tess
.
xyz
[
numVerts
+
2
][
2
]
=
0
;
tess
.
texCoords
[
numVerts
+
2
][
0
]
[
0
]
=
cmd
->
s2
;
tess
.
texCoords
[
numVerts
+
2
][
0
][
1
]
=
cmd
->
t2
;
tess
.
texCoords
[
0
][
numVerts
+
2
][
0
]
=
cmd
->
s2
;
tess
.
texCoords
[
0
][
numVerts
+
2
][
1
]
=
cmd
->
t2
;
tess
.
xyz
[
numVerts
+
3
][
0
]
=
cmd
->
x
;
tess
.
xyz
[
numVerts
+
3
][
1
]
=
cmd
->
y
+
cmd
->
h
;
tess
.
xyz
[
numVerts
+
3
][
2
]
=
0
;
tess
.
texCoords
[
numVerts
+
3
][
0
]
[
0
]
=
cmd
->
s1
;
tess
.
texCoords
[
numVerts
+
3
][
0
][
1
]
=
cmd
->
t2
;
tess
.
texCoords
[
0
][
numVerts
+
3
][
0
]
=
cmd
->
s1
;
tess
.
texCoords
[
0
][
numVerts
+
3
][
1
]
=
cmd
->
t2
;
return
(
const
void
*
)(
cmd
+
1
);
}
...
...
@@ -984,6 +985,7 @@ void RB_ShowImages( void ) {
vglVertexPointer
(
3
,
GL_FLOAT
,
0
,
4
,
vertex
);
vglTexCoordPointer
(
2
,
GL_FLOAT
,
0
,
4
,
texcoord
);
vglIndexPointerMapped
(
gIndexesBufferOrdered
);
vglDrawObjects
(
GL_TRIANGLE_FAN
,
4
,
GL_TRUE
);
}
...
...
code/renderergl1/tr_flares.c
View file @
bb196032
...
...
@@ -392,8 +392,8 @@ void RB_RenderFlare( flare_t *f ) {
// FIXME: use quadstamp?
tess
.
xyz
[
tess
.
numVertexes
][
0
]
=
f
->
windowX
-
size
;
tess
.
xyz
[
tess
.
numVertexes
][
1
]
=
f
->
windowY
-
size
;
tess
.
texCoords
[
tess
.
numVertexes
][
0
]
[
0
]
=
0
;
tess
.
texCoords
[
tess
.
numVertexes
][
0
][
1
]
=
0
;
tess
.
texCoords
[
0
][
tess
.
numVertexes
][
0
]
=
0
;
tess
.
texCoords
[
0
][
tess
.
numVertexes
][
1
]
=
0
;
tess
.
vertexColors
[
tess
.
numVertexes
][
0
]
=
iColor
[
0
];
tess
.
vertexColors
[
tess
.
numVertexes
][
1
]
=
iColor
[
1
];
tess
.
vertexColors
[
tess
.
numVertexes
][
2
]
=
iColor
[
2
];
...
...
@@ -402,8 +402,8 @@ void RB_RenderFlare( flare_t *f ) {
tess
.
xyz
[
tess
.
numVertexes
][
0
]
=
f
->
windowX
-
size
;
tess
.
xyz
[
tess
.
numVertexes
][
1
]
=
f
->
windowY
+
size
;
tess
.
texCoords
[
tess
.
numVertexes
][
0
]
[
0
]
=
0
;
tess
.
texCoords
[
tess
.
numVertexes
][
0
][
1
]
=
1
;
tess
.
texCoords
[
0
][
tess
.
numVertexes
][
0
]
=
0
;
tess
.
texCoords
[
0
][
tess
.
numVertexes
][
1
]
=
1
;
tess
.
vertexColors
[
tess
.
numVertexes
][
0
]
=
iColor
[
0
];
tess
.
vertexColors
[
tess
.
numVertexes
][
1
]
=
iColor
[
1
];
tess
.
vertexColors
[
tess
.
numVertexes
][
2
]
=
iColor
[
2
];
...
...
@@ -412,8 +412,8 @@ void RB_RenderFlare( flare_t *f ) {
tess
.
xyz
[
tess
.
numVertexes
][
0
]
=
f
->
windowX
+
size
;
tess
.
xyz
[
tess
.
numVertexes
][
1
]
=
f
->
windowY
+
size
;
tess
.
texCoords
[
tess
.
numVertexes
][
0
]
[
0
]
=
1
;
tess
.
texCoords
[
tess
.
numVertexes
][
0
][
1
]
=
1
;
tess
.
texCoords
[
0
][
tess
.
numVertexes
][
0
]
=
1
;
tess
.
texCoords
[
0
][
tess
.
numVertexes
][
1
]
=
1
;
tess
.
vertexColors
[
tess
.
numVertexes
][
0
]
=
iColor
[
0
];
tess
.
vertexColors
[
tess
.
numVertexes
][
1
]
=
iColor
[
1
];
tess
.
vertexColors
[
tess
.
numVertexes
][
2
]
=
iColor
[
2
];
...
...
@@ -422,8 +422,8 @@ void RB_RenderFlare( flare_t *f ) {
tess
.
xyz
[
tess
.
numVertexes
][
0
]
=
f
->
windowX
+
size
;
tess
.
xyz
[
tess
.
numVertexes
][
1
]
=
f
->
windowY
-
size
;
tess
.
texCoords
[
tess
.
numVertexes
][
0
]
[
0
]
=
1
;
tess
.
texCoords
[
tess
.
numVertexes
][
0
][
1
]
=
0
;
tess
.
texCoords
[
0
][
tess
.
numVertexes
][
0
]
=
1
;
tess
.
texCoords
[
0
][
tess
.
numVertexes
][
1
]
=
0
;
tess
.
vertexColors
[
tess
.
numVertexes
][
0
]
=
iColor
[
0
];
tess
.
vertexColors
[
tess
.
numVertexes
][
1
]
=
iColor
[
1
];
tess
.
vertexColors
[
tess
.
numVertexes
][
2
]
=
iColor
[
2
];
...
...
code/renderergl1/tr_local.h
View file @
bb196032
...
...
@@ -32,8 +32,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../renderercommon/iqm.h"
#include "../renderercommon/qgl.h"
#define GL_INDEX_TYPE GL_UNSIGNED_
IN
T
typedef
u
nsigned
in
t
glIndex_t
;
#define GL_INDEX_TYPE GL_UNSIGNED_
SHOR
T
typedef
u
int16_
t
glIndex_t
;
// 14 bits
// can't be increased without changing bit packing for drawsurfs
...
...
@@ -1212,9 +1212,9 @@ typedef struct stageVars
typedef
struct
shaderCommands_s
{
glIndex_t
indexes
[
SHADER_MAX_INDEXES
]
QALIGN
(
16
);
vec
4
_t
xyz
[
SHADER_MAX_VERTEXES
]
QALIGN
(
16
);
vec
3
_t
xyz
[
SHADER_MAX_VERTEXES
]
QALIGN
(
16
);
vec4_t
normal
[
SHADER_MAX_VERTEXES
]
QALIGN
(
16
);
vec2_t
texCoords
[
SHADER_MAX_VERTEXES
]
[
2
]
QALIGN
(
16
);
vec2_t
texCoords
[
2
][
SHADER_MAX_VERTEXES
]
QALIGN
(
16
);
color4ub_t
vertexColors
[
SHADER_MAX_VERTEXES
]
QALIGN
(
16
);
int
vertexDlightBits
[
SHADER_MAX_VERTEXES
]
QALIGN
(
16
);
...
...
code/renderergl1/tr_main.c
View file @
bb196032
...
...
@@ -1307,6 +1307,7 @@ void R_DebugPolygon( int color, int numPoints, float *points ) {
qglColor3f
(
color
&
1
,
(
color
>>
1
)
&
1
,
(
color
>>
2
)
&
1
);
vglVertexPointer
(
3
,
GL_FLOAT
,
0
,
numPoints
,
points
);
vglIndexPointerMapped
(
gIndexesBufferOrdered
);
vglDrawObjects
(
GL_TRIANGLE_FAN
,
4
,
GL_TRUE
);
// draw wireframe outline
...
...
code/renderergl1/tr_model_iqm.c
View file @
bb196032
...
...
@@ -1205,9 +1205,9 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
float
*
normal
;
float
*
texCoords
;
byte
*
color
;
vec
4
_t
*
outXYZ
;
vec
3
_t
*
outXYZ
;
vec4_t
*
outNormal
;
vec2_t
(
*
outTexCoord
)[
2
]
;
vec2_t
*
outTexCoord
;
color4ub_t
*
outColor
;
int
frame
=
data
->
num_frames
?
backEnd
.
currentEntity
->
e
.
frame
%
data
->
num_frames
:
0
;
...
...
@@ -1232,7 +1232,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
outXYZ
=
&
tess
.
xyz
[
tess
.
numVertexes
];
outNormal
=
&
tess
.
normal
[
tess
.
numVertexes
];
outTexCoord
=
&
tess
.
texCoords
[
tess
.
numVertexes
];
outTexCoord
=
&
tess
.
texCoords
[
0
][
tess
.
numVertexes
];
outColor
=
&
tess
.
vertexColors
[
tess
.
numVertexes
];
if
(
data
->
num_poses
>
0
)
{
...
...
@@ -1325,8 +1325,8 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
float
*
vtxMat
=
&
influenceVtxMat
[
12
*
influence
];
float
*
nrmMat
=
&
influenceNrmMat
[
9
*
influence
];
(
*
outTexCoord
)[
0
]
[
0
]
=
texCoords
[
0
];
(
*
outTexCoord
)[
0
][
1
]
=
texCoords
[
1
];
(
*
outTexCoord
)[
0
]
=
texCoords
[
0
];
(
*
outTexCoord
)[
1
]
=
texCoords
[
1
];
(
*
outXYZ
)[
0
]
=
vtxMat
[
0
]
*
xyz
[
0
]
+
...
...
@@ -1362,8 +1362,8 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
for
(
i
=
0
;
i
<
surf
->
num_vertexes
;
i
++
,
xyz
+=
3
,
normal
+=
3
,
texCoords
+=
2
,
outXYZ
++
,
outNormal
++
,
outTexCoord
++
)
{
(
*
outTexCoord
)[
0
]
[
0
]
=
texCoords
[
0
];
(
*
outTexCoord
)[
0
][
1
]
=
texCoords
[
1
];
(
*
outTexCoord
)[
0
]
=
texCoords
[
0
];
(
*
outTexCoord
)[
1
]
=
texCoords
[
1
];
(
*
outXYZ
)[
0
]
=
xyz
[
0
];
(
*
outXYZ
)[
1
]
=
xyz
[
1
];
...
...
code/renderergl1/tr_shade.c
View file @
bb196032
...
...
@@ -40,6 +40,10 @@ without compiled vertex arrays.
==================
*/
static
void
R_DrawElements
(
int
numIndexes
,
const
glIndex_t
*
indexes
)
{
uint16_t
*
indexes_buf
=
gIndexesBuffer
;
memcpy
(
gIndexesBuffer
,
indexes
,
numIndexes
*
sizeof
(
glIndex_t
));
gIndexesBuffer
+=
numIndexes
;
vglIndexPointerMapped
(
indexes_buf
);
vglDrawObjects
(
GL_TRIANGLES
,
numIndexes
,
GL_TRUE
);
}
...
...
@@ -109,11 +113,8 @@ static void DrawTris (shaderCommands_t *input) {
qglDisableClientState
(
GL_TEXTURE_COORD_ARRAY
);
float
*
vertices
=
gVertexBuffer
;
int
i
;
for
(
i
=
0
;
i
<
input
->
numIndexes
;
i
++
){
memcpy
(
gVertexBuffer
,
input
->
xyz
[
input
->
indexes
[
i
]],
sizeof
(
vec3_t
));
gVertexBuffer
+=
3
;
}
memcpy
(
gVertexBuffer
,
input
->
xyz
[
0
],
input
->
numVertexes
*
sizeof
(
vec3_t
));
gVertexBuffer
+=
input
->
numVertexes
*
3
;
vglVertexPointerMapped
(
vertices
);
//->if (qglLockArraysEXT) {
...
...
@@ -156,6 +157,7 @@ static void DrawNormals (shaderCommands_t *input) {
gVertexBuffer
+=
3
;
}
vglVertexPointerMapped
(
vertices
);
vglIndexPointerMapped
(
gIndexesBufferOrdered
);
vglDrawObjects
(
GL_LINES
,
input
->
numVertexes
*
2
,
GL_TRUE
);
qglDepthRange
(
0
,
1
);
...
...
@@ -219,11 +221,8 @@ static void DrawMultitextured( shaderCommands_t *input, int stage ) {
//
GL_SelectTexture
(
0
);
float
*
texcoord
=
gTexCoordBuffer
;
int
i
;
for
(
i
=
0
;
i
<
input
->
numIndexes
;
i
++
)
{
memcpy
(
gTexCoordBuffer
,
input
->
svars
.
texcoords
[
0
][
input
->
indexes
[
i
]],
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
2
;
}
memcpy
(
gTexCoordBuffer
,
input
->
svars
.
texcoords
[
0
][
0
],
input
->
numVertexes
*
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
2
*
input
->
numVertexes
;
vglTexCoordPointerMapped
(
texcoord
);
R_BindAnimatedImage
(
&
pStage
->
bundle
[
0
]
);
...
...
@@ -243,10 +242,8 @@ static void DrawMultitextured( shaderCommands_t *input, int stage ) {
//->}
texcoord
=
gTexCoordBuffer
;
for
(
i
=
0
;
i
<
input
->
numIndexes
;
i
++
)
{
memcpy
(
gTexCoordBuffer
,
input
->
svars
.
texcoords
[
1
][
input
->
indexes
[
i
]],
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
2
;
}
memcpy
(
gTexCoordBuffer
,
input
->
svars
.
texcoords
[
1
][
0
],
input
->
numVertexes
*
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
input
->
numVertexes
*
2
;
vglTexCoordPointerMapped
(
texcoord
);
R_BindAnimatedImage
(
&
pStage
->
bundle
[
1
]
);
R_DrawElements
(
input
->
numIndexes
,
input
->
indexes
);
...
...
@@ -353,8 +350,6 @@ static void ProjectDlightTexture_scalar( void ) {
}
else
if
(
texCoords
[
1
]
>
1
.
0
f
)
{
clip
|=
8
;
}
texCoords
[
0
]
=
texCoords
[
0
];
texCoords
[
1
]
=
texCoords
[
1
];
// modulate the strength based on the height and color
if
(
dist
[
2
]
>
radius
)
{
...
...
@@ -405,12 +400,10 @@ static void ProjectDlightTexture_scalar( void ) {
float
*
texcoord
=
gTexCoordBuffer
;
uint8_t
*
colorbuf
=
gColorBuffer
;
for
(
i
=
0
;
i
<
numIndexes
;
i
++
)
{
memcpy
(
gTexCoordBuffer
,
texCoordsArray
[
hitIndexes
[
i
]],
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
2
;
memcpy
(
gColorBuffer
,
colorArray
[
hitIndexes
[
i
]],
sizeof
(
uint32_t
));
gColorBuffer
+=
4
;
}
memcpy
(
gTexCoordBuffer
,
texCoords
,
tess
.
numVertexes
*
sizeof
(
vec2_t
));
memcpy
(
gColorBuffer
,
colorArray
[
0
],
tess
.
numVertexes
*
sizeof
(
uint32_t
));
gTexCoordBuffer
+=
tess
.
numVertexes
*
2
;
gColorBuffer
+=
tess
.
numVertexes
*
4
;
vglColorPointerMapped
(
GL_UNSIGNED_BYTE
,
colorbuf
);
vglTexCoordPointerMapped
(
texcoord
);
...
...
@@ -465,12 +458,10 @@ static void RB_FogPass( void ) {
float
*
texcoord
=
gTexCoordBuffer
;
uint8_t
*
colorbuf
=
gColorBuffer
;
for
(
i
=
0
;
i
<
tess
.
numIndexes
;
i
++
)
{
memcpy
(
gColorBuffer
,
tess
.
svars
.
colors
[
tess
.
indexes
[
i
]],
sizeof
(
uint32_t
));
memcpy
(
gTexCoordBuffer
,
tess
.
svars
.
texcoords
[
0
][
tess
.
indexes
[
i
]],
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
2
;
gColorBuffer
+=
4
;
}
memcpy
(
gColorBuffer
,
tess
.
svars
.
colors
[
0
],
tess
.
numVertexes
*
sizeof
(
uint32_t
));
memcpy
(
gTexCoordBuffer
,
tess
.
svars
.
texcoords
[
0
][
0
],
tess
.
numVertexes
*
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
tess
.
numVertexes
*
2
;
gColorBuffer
+=
tess
.
numVertexes
*
4
;
vglColorPointerMapped
(
GL_UNSIGNED_BYTE
,
colorbuf
);
vglTexCoordPointerMapped
(
texcoord
);
...
...
@@ -702,7 +693,6 @@ ComputeTexCoords
static
void
ComputeTexCoords
(
shaderStage_t
*
pStage
)
{
int
i
;
int
b
;
for
(
b
=
0
;
b
<
NUM_TEXTURE_BUNDLES
;
b
++
)
{
int
tm
;
...
...
@@ -716,14 +706,14 @@ static void ComputeTexCoords( shaderStage_t *pStage ) {
break
;
case
TCGEN_TEXTURE
:
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
)
{
tess
.
svars
.
texcoords
[
b
][
i
][
0
]
=
tess
.
texCoords
[
i
][
0
][
0
];
tess
.
svars
.
texcoords
[
b
][
i
][
1
]
=
tess
.
texCoords
[
i
][
0
][
1
];
tess
.
svars
.
texcoords
[
b
][
i
][
0
]
=
tess
.
texCoords
[
0
][
i
][
0
];
tess
.
svars
.
texcoords
[
b
][
i
][
1
]
=
tess
.
texCoords
[
0
][
i
][
1
];
}
break
;
case
TCGEN_LIGHTMAP
:
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
)
{
tess
.
svars
.
texcoords
[
b
][
i
][
0
]
=
tess
.
texCoords
[
i
][
1
][
0
];
tess
.
svars
.
texcoords
[
b
][
i
][
1
]
=
tess
.
texCoords
[
i
][
1
][
1
];
tess
.
svars
.
texcoords
[
b
][
i
][
0
]
=
tess
.
texCoords
[
1
][
i
][
0
];
tess
.
svars
.
texcoords
[
b
][
i
][
1
]
=
tess
.
texCoords
[
1
][
i
][
1
];
}
break
;
case
TCGEN_VECTOR
:
...
...
@@ -818,11 +808,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
//{
qglEnableClientState
(
GL_COLOR_ARRAY
);
uint8_t
*
colorbuf
=
gColorBuffer
;
int
i
;
for
(
i
=
0
;
i
<
input
->
numIndexes
;
i
++
)
{
memcpy
(
gColorBuffer
,
input
->
svars
.
colors
[
input
->
indexes
[
i
]],
sizeof
(
uint32_t
));
gColorBuffer
+=
4
;
}
memcpy
(
gColorBuffer
,
input
->
svars
.
colors
[
0
],
input
->
numVertexes
*
sizeof
(
uint32_t
));
gColorBuffer
+=
input
->
numVertexes
*
4
;
vglColorPointerMapped
(
GL_UNSIGNED_BYTE
,
colorbuf
);
//}
...
...
@@ -838,11 +825,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
//if ( !setArraysOnce )
//{
float
*
texcoord
=
gTexCoordBuffer
;
int
i
;
for
(
i
=
0
;
i
<
input
->
numIndexes
;
i
++
)
{
memcpy
(
gTexCoordBuffer
,
input
->
svars
.
texcoords
[
0
][
input
->
indexes
[
i
]],
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
2
;
}
memcpy
(
gTexCoordBuffer
,
input
->
svars
.
texcoords
[
0
][
0
],
input
->
numVertexes
*
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
input
->
numVertexes
*
2
;
vglTexCoordPointerMapped
(
texcoord
);
//}
...
...
@@ -904,11 +888,8 @@ void RB_StageIteratorGeneric( void )
// lock XYZ
//
float
*
vertices
=
gVertexBuffer
;
int
i
;
for
(
i
=
0
;
i
<
input
->
numIndexes
;
i
++
){
memcpy
(
gVertexBuffer
,
input
->
xyz
[
input
->
indexes
[
i
]],
sizeof
(
vec3_t
));
gVertexBuffer
+=
3
;
}
memcpy
(
gVertexBuffer
,
input
->
xyz
[
0
],
input
->
numVertexes
*
sizeof
(
vec3_t
));
gVertexBuffer
+=
input
->
numVertexes
*
3
;
vglVertexPointerMapped
(
vertices
);
//->if (qglLockArraysEXT)
...
...
@@ -996,15 +977,12 @@ void RB_StageIteratorVertexLitTexture( void )
uint8_t
*
colorbuf
=
gColorBuffer
;
float
*
texcoord
=
gTexCoordBuffer
;
float
*
vertices
=
gVertexBuffer
;
int
i
;
for
(
i
=
0
;
i
<
tess
.
numIndexes
;
i
++
)
{
memcpy
(
gColorBuffer
,
tess
.
svars
.
colors
[
tess
.
indexes
[
i
]],
sizeof
(
uint32_t
));
gColorBuffer
+=
4
;
memcpy
(
gTexCoordBuffer
,
tess
.
texCoords
[
tess
.
indexes
[
i
]][
0
],
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
2
;
memcpy
(
gVertexBuffer
,
input
->
xyz
[
input
->
indexes
[
i
]],
sizeof
(
vec3_t
));
gVertexBuffer
+=
3
;
}
memcpy
(
gColorBuffer
,
tess
.
svars
.
colors
[
0
],
tess
.
numVertexes
*
sizeof
(
uint32_t
));
gColorBuffer
+=
tess
.
numVertexes
*
4
;
memcpy
(
gTexCoordBuffer
,
tess
.
texCoords
[
0
][
0
],
tess
.
numVertexes
*
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
tess
.
numVertexes
*
2
;
memcpy
(
gVertexBuffer
,
input
->
xyz
[
0
],
tess
.
numVertexes
*
sizeof
(
vec3_t
));
gVertexBuffer
+=
tess
.
numVertexes
*
3
;
vglColorPointerMapped
(
GL_UNSIGNED_BYTE
,
colorbuf
);
vglTexCoordPointerMapped
(
texcoord
);
vglVertexPointerMapped
(
vertices
);
...
...
@@ -1074,12 +1052,9 @@ void RB_StageIteratorLightmappedMultitexture( void ) {
//
GL_State
(
GLS_DEFAULT
);
qglEnableClientState
(
GL_COLOR_ARRAY
);
int
i
;
float
*
vertices
=
gVertexBuffer
;
for
(
i
=
0
;
i
<
input
->
numIndexes
;
i
++
)
{
memcpy
(
gVertexBuffer
,
input
->
xyz
[
input
->
indexes
[
i
]],
sizeof
(
vec3_t
));
gVertexBuffer
+=
3
;
}
memcpy
(
gVertexBuffer
,
input
->
xyz
[
0
],
input
->
numVertexes
*
sizeof
(
vec3_t
));
gVertexBuffer
+=
input
->
numVertexes
*
3
;
vglVertexPointerMapped
(
vertices
);
vglColorPointerMapped
(
GL_UNSIGNED_BYTE
,
gColorBuffer255
);
...
...
@@ -1092,10 +1067,8 @@ void RB_StageIteratorLightmappedMultitexture( void ) {
R_BindAnimatedImage
(
&
tess
.
xstages
[
0
]
->
bundle
[
0
]
);
float
*
texcoord
=
gTexCoordBuffer
;
for
(
i
=
0
;
i
<
tess
.
numIndexes
;
i
++
)
{
memcpy
(
gTexCoordBuffer
,
tess
.
texCoords
[
tess
.
indexes
[
i
]][
0
],
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
2
;
}
memcpy
(
gTexCoordBuffer
,
tess
.
texCoords
[
0
][
0
],
tess
.
numVertexes
*
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
tess
.
numVertexes
*
2
;
vglTexCoordPointerMapped
(
texcoord
);
R_DrawElements
(
input
->
numIndexes
,
input
->
indexes
);
...
...
@@ -1111,10 +1084,8 @@ void RB_StageIteratorLightmappedMultitexture( void ) {
//->}
R_BindAnimatedImage
(
&
tess
.
xstages
[
0
]
->
bundle
[
1
]
);
texcoord
=
gTexCoordBuffer
;
for
(
i
=
0
;
i
<
tess
.
numIndexes
;
i
++
)
{
memcpy
(
gTexCoordBuffer
,
tess
.
texCoords
[
tess
.
indexes
[
i
]][
1
],
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
2
;
}
memcpy
(
gTexCoordBuffer
,
tess
.
texCoords
[
1
][
0
],
tess
.
numVertexes
*
sizeof
(
vec2_t
));
gTexCoordBuffer
+=
tess
.
numVertexes
*
2
;
vglTexCoordPointerMapped
(
texcoord
);
//
...
...
code/renderergl1/tr_shade_calc.c
View file @
bb196032
...
...
@@ -127,7 +127,7 @@ void RB_CalcDeformVertexes( deformStage_t *ds )
{
scale
=
EvalWaveForm
(
&
ds
->
deformationWave
);
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
xyz
+=
4
,
normal
+=
4
)
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
xyz
+=
3
,
normal
+=
4
)
{
VectorScale
(
normal
,
scale
,
offset
);
...
...
@@ -140,7 +140,7 @@ void RB_CalcDeformVertexes( deformStage_t *ds )
{
table
=
TableForFunc
(
ds
->
deformationWave
.
func
);
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
xyz
+=
4
,
normal
+=
4
)
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
xyz
+=
3
,
normal
+=
4
)
{
float
off
=
(
xyz
[
0
]
+
xyz
[
1
]
+
xyz
[
2
]
)
*
ds
->
deformationSpread
;
...
...
@@ -171,7 +171,7 @@ void RB_CalcDeformNormals( deformStage_t *ds ) {
float
*
xyz
=
(
float
*
)
tess
.
xyz
;
float
*
normal
=
(
float
*
)
tess
.
normal
;
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
xyz
+=
4
,
normal
+=
4
)
{
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
xyz
+=
3
,
normal
+=
4
)
{
scale
=
0
.
98
f
;
scale
=
R_NoiseGet4f
(
xyz
[
0
]
*
scale
,
xyz
[
1
]
*
scale
,
xyz
[
2
]
*
scale
,
tess
.
shaderTime
*
ds
->
deformationWave
.
frequency
);
...
...
@@ -206,7 +206,7 @@ void RB_CalcBulgeVertexes( deformStage_t *ds ) {
now
=
backEnd
.
refdef
.
time
*
0
.
001
*
ds
->
bulgeSpeed
;
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
xyz
+=
4
,
st
+=
4
,
normal
+=
4
)
{
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
xyz
+=
3
,
st
+=
2
,
normal
+=
4
)
{
int64_t
off
;
float
scale
;
...
...
@@ -245,7 +245,7 @@ void RB_CalcMoveVertexes( deformStage_t *ds ) {
VectorScale
(
ds
->
moveVector
,
scale
,
offset
);
xyz
=
(
float
*
)
tess
.
xyz
;
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
xyz
+=
4
)
{
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
xyz
+=
3
)
{
VectorAdd
(
xyz
,
offset
,
xyz
);
}
}
...
...
@@ -465,8 +465,8 @@ static void Autosprite2Deform( void ) {
float
l
;
vec3_t
temp
;
v1
=
xyz
+
4
*
edgeVerts
[
j
][
0
];
v2
=
xyz
+
4
*
edgeVerts
[
j
][
1
];
v1
=
xyz
+
3
*
edgeVerts
[
j
][
0
];
v2
=
xyz
+
3
*
edgeVerts
[
j
][
1
];
VectorSubtract
(
v1
,
v2
,
temp
);
...
...
@@ -483,8 +483,8 @@ static void Autosprite2Deform( void ) {
}
for
(
j
=
0
;
j
<
2
;
j
++
)
{
v1
=
xyz
+
4
*
edgeVerts
[
nums
[
j
]][
0
];
v2
=
xyz
+
4
*
edgeVerts
[
nums
[
j
]][
1
];
v1
=
xyz
+
3
*
edgeVerts
[
nums
[
j
]][
0
];
v2
=
xyz
+
3
*
edgeVerts
[
nums
[
j
]][
1
];
mid
[
j
][
0
]
=
0
.
5
f
*
(
v1
[
0
]
+
v2
[
0
]);
mid
[
j
][
1
]
=
0
.
5
f
*
(
v1
[
1
]
+
v2
[
1
]);
...
...
@@ -502,8 +502,8 @@ static void Autosprite2Deform( void ) {
for
(
j
=
0
;
j
<
2
;
j
++
)
{
float
l
;
v1
=
xyz
+
4
*
edgeVerts
[
nums
[
j
]][
0
];
v2
=
xyz
+
4
*
edgeVerts
[
nums
[
j
]][
1
];
v1
=
xyz
+
3
*
edgeVerts
[
nums
[
j
]][
0
];
v2
=
xyz
+
3
*
edgeVerts
[
nums
[
j
]][
1
];
l
=
0
.
5
*
sqrt
(
lengths
[
j
]
);
...
...
@@ -853,7 +853,7 @@ void RB_CalcFogTexCoords( float *st ) {
fogDistanceVector
[
3
]
+=
1
.
0
/
512
;
// calculate density for each point
for
(
i
=
0
,
v
=
tess
.
xyz
[
0
]
;
i
<
tess
.
numVertexes
;
i
++
,
v
+=
4
)
{
for
(
i
=
0
,
v
=
tess
.
xyz
[
0
]
;
i
<
tess
.
numVertexes
;
i
++
,
v
+=
3
)
{
// calculate the length in fog
s
=
DotProduct
(
v
,
fogDistanceVector
)
+
fogDistanceVector
[
3
];
t
=
DotProduct
(
v
,
fogDepthVector
)
+
fogDepthVector
[
3
];
...
...
@@ -894,7 +894,7 @@ void RB_CalcEnvironmentTexCoords( float *st )
v
=
tess
.
xyz
[
0
];
normal
=
tess
.
normal
[
0
];
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
v
+=
4
,
normal
+=
4
,
st
+=
2
)
for
(
i
=
0
;
i
<
tess
.
numVertexes
;
i
++
,
v
+=
3
,
normal
+=
4
,
st
+=
2
)
{
VectorSubtract
(
backEnd
.
or
.
viewOrigin
,
v
,
viewer
);
VectorNormalizeFast
(
viewer
);
...
...
@@ -1036,7 +1036,7 @@ void RB_CalcSpecularAlpha( unsigned char *alphas ) {
alphas
+=
3
;
numVertexes
=
tess
.
numVertexes
;
for
(
i
=
0
;
i
<
numVertexes
;
i
++
,
v
+=
4
,
normal
+=
4
,
alphas
+=
4
)
{
for
(
i
=
0
;
i
<
numVertexes
;
i
++
,
v
+=
3
,
normal
+=
4
,
alphas
+=
4
)
{
float
ilength
;
VectorSubtract
(
lightOrigin
,
v
,
lightDir
);
...
...
@@ -1127,7 +1127,7 @@ static void RB_CalcDiffuseColor_altivec( unsigned char *colors )
normalPerm
=
vec_lvsl
(
0
,
normal
);