Skip to content

Commit

Permalink
Merge branch 'master' into sdl2
Browse files Browse the repository at this point in the history
  • Loading branch information
zturtleman committed Nov 26, 2013
2 parents 3736968 + 2044bcb commit ad514c9
Show file tree
Hide file tree
Showing 20 changed files with 539 additions and 463 deletions.
665 changes: 354 additions & 311 deletions README → README.md

Large diffs are not rendered by default.

49 changes: 28 additions & 21 deletions code/client/snd_dma.c
Expand Up @@ -1371,6 +1371,32 @@ void S_Base_StopBackgroundTrack( void ) {
s_rawend[0] = 0;
}

/*
======================
S_OpenBackgroundStream
======================
*/
static void S_OpenBackgroundStream( const char *filename ) {
// close the background track, but DON'T reset s_rawend
// if restarting the same back ground track
if(s_backgroundStream)
{
S_CodecCloseStream(s_backgroundStream);
s_backgroundStream = NULL;
}

// Open stream
s_backgroundStream = S_CodecOpenStream(filename);
if(!s_backgroundStream) {
Com_Printf( S_COLOR_YELLOW "WARNING: couldn't open music file %s\n", filename );
return;
}

if(s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050) {
Com_Printf(S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo\n", filename );
}
}

/*
======================
S_StartBackgroundTrack
Expand All @@ -1397,24 +1423,7 @@ void S_Base_StartBackgroundTrack( const char *intro, const char *loop ){
Q_strncpyz( s_backgroundLoop, loop, sizeof( s_backgroundLoop ) );
}

// close the background track, but DON'T reset s_rawend
// if restarting the same back ground track
if(s_backgroundStream)
{
S_CodecCloseStream(s_backgroundStream);
s_backgroundStream = NULL;
}

// Open stream
s_backgroundStream = S_CodecOpenStream(intro);
if(!s_backgroundStream) {
Com_Printf( S_COLOR_YELLOW "WARNING: couldn't open music file %s\n", intro );
return;
}

if(s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050) {
Com_Printf(S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo\n", intro );
}
S_OpenBackgroundStream( intro );
}

/*
Expand Down Expand Up @@ -1477,9 +1486,7 @@ void S_UpdateBackgroundTrack( void ) {
// loop
if(s_backgroundLoop[0])
{
S_CodecCloseStream(s_backgroundStream);
s_backgroundStream = NULL;
S_Base_StartBackgroundTrack( s_backgroundLoop, s_backgroundLoop );
S_OpenBackgroundStream( s_backgroundLoop );
if(!s_backgroundStream)
return;
}
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_client.c
Expand Up @@ -426,7 +426,7 @@ void CopyToBodyQue( gentity_t *ent ) {
body->s.eFlags |= EF_KAMIKAZE;

// check if there is a kamikaze timer around for this owner
for (i = 0; i < MAX_GENTITIES; i++) {
for (i = 0; i < level.num_entities; i++) {
e = &g_entities[i];
if (!e->inuse)
continue;
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_combat.c
Expand Up @@ -241,7 +241,7 @@ void GibEntity( gentity_t *self, int killer ) {
//if this entity still has kamikaze
if (self->s.eFlags & EF_KAMIKAZE) {
// check if there is a kamikaze timer around for this owner
for (i = 0; i < MAX_GENTITIES; i++) {
for (i = 0; i < level.num_entities; i++) {
ent = &g_entities[i];
if (!ent->inuse)
continue;
Expand Down
4 changes: 4 additions & 0 deletions code/renderergl1/tr_backend.c
Expand Up @@ -737,6 +737,10 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
}
R_IssuePendingRenderCommands();

if ( tess.numIndexes ) {
RB_EndSurface();
}

// we definately want to sync every frame for the cinematics
qglFinish();

Expand Down
40 changes: 22 additions & 18 deletions code/renderergl2/tr_backend.c
Expand Up @@ -371,17 +371,17 @@ void GL_State( unsigned long stateBits )
}


void GL_SetProjectionMatrix(matrix_t matrix)
void GL_SetProjectionMatrix(mat4_t matrix)
{
Matrix16Copy(matrix, glState.projection);
Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection);
Mat4Copy(matrix, glState.projection);
Mat4Multiply(glState.projection, glState.modelview, glState.modelviewProjection);
}


void GL_SetModelviewMatrix(matrix_t matrix)
void GL_SetModelviewMatrix(mat4_t matrix)
{
Matrix16Copy(matrix, glState.modelview);
Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection);
Mat4Copy(matrix, glState.modelview);
Mat4Multiply(glState.projection, glState.modelview, glState.modelviewProjection);
}


Expand Down Expand Up @@ -765,7 +765,7 @@ RB_SetGL2D
================
*/
void RB_SetGL2D (void) {
matrix_t matrix;
mat4_t matrix;
int width, height;

if (backEnd.projection2D && backEnd.last2DFBO == glState.currentFBO)
Expand All @@ -789,9 +789,9 @@ void RB_SetGL2D (void) {
qglViewport( 0, 0, width, height );
qglScissor( 0, 0, width, height );

Matrix16Ortho(0, width, height, 0, 0, 1, matrix);
Mat4Ortho(0, width, height, 0, 0, 1, matrix);
GL_SetProjectionMatrix(matrix);
Matrix16Identity(matrix);
Mat4Identity(matrix);
GL_SetModelviewMatrix(matrix);

GL_State( GLS_DEPTHTEST_DISABLE |
Expand Down Expand Up @@ -830,6 +830,10 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
}
R_IssuePendingRenderCommands();

if ( tess.numIndexes ) {
RB_EndSurface();
}

// we definately want to sync every frame for the cinematics
qglFinish();

Expand Down Expand Up @@ -881,7 +885,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *

GLSL_BindProgram(&tr.textureColorShader);

GLSL_SetUniformMatrix16(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite);

RB_InstantQuad2(quadVerts, texCoords);
Expand Down Expand Up @@ -1122,9 +1126,9 @@ const void *RB_DrawSurfs( const void *data ) {
GL_BindToTMU(tr.sunShadowDepthImage[1], TB_SHADOWMAP2);
GL_BindToTMU(tr.sunShadowDepthImage[2], TB_SHADOWMAP3);

GLSL_SetUniformMatrix16(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[0]);
GLSL_SetUniformMatrix16(&tr.shadowmaskShader, UNIFORM_SHADOWMVP2, backEnd.refdef.sunShadowMvp[1]);
GLSL_SetUniformMatrix16(&tr.shadowmaskShader, UNIFORM_SHADOWMVP3, backEnd.refdef.sunShadowMvp[2]);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[0]);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP2, backEnd.refdef.sunShadowMvp[1]);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP3, backEnd.refdef.sunShadowMvp[2]);

GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg);
{
Expand Down Expand Up @@ -1578,7 +1582,7 @@ const void *RB_PostProcess(const void *data)
{
const postProcessCommand_t *cmd = data;
FBO_t *srcFbo;
vec4i_t srcBox, dstBox;
ivec4_t srcBox, dstBox;
qboolean autoExposure;

// finish any 2D drawing if needed
Expand Down Expand Up @@ -1664,7 +1668,7 @@ const void *RB_PostProcess(const void *data)

if (0)
{
vec4i_t dstBox;
ivec4_t dstBox;
VectorSet4(dstBox, 0, 0, 128, 128);
FBO_BlitFromTexture(tr.sunShadowDepthImage[0], NULL, NULL, NULL, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 128, 0, 128, 128);
Expand All @@ -1675,7 +1679,7 @@ const void *RB_PostProcess(const void *data)

if (0)
{
vec4i_t dstBox;
ivec4_t dstBox;
VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256);
FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 512, glConfig.vidHeight - 256, 256, 256);
Expand All @@ -1684,15 +1688,15 @@ const void *RB_PostProcess(const void *data)

if (0)
{
vec4i_t dstBox;
ivec4_t dstBox;
VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256);
FBO_BlitFromTexture(tr.sunRaysImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0);
}

#if 0
if (r_cubeMapping->integer && tr.numCubemaps)
{
vec4i_t dstBox;
ivec4_t dstBox;
int cubemapIndex = R_CubemapForPoint( backEnd.viewParms.or.origin );

if (cubemapIndex)
Expand Down
22 changes: 11 additions & 11 deletions code/renderergl2/tr_extramath.c
Expand Up @@ -26,31 +26,31 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// Some matrix helper functions
// FIXME: do these already exist in ioq3 and I don't know about them?

void Matrix16Zero( matrix_t out )
void Mat4Zero( mat4_t out )
{
out[ 0] = 0.0f; out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = 0.0f;
out[ 1] = 0.0f; out[ 5] = 0.0f; out[ 9] = 0.0f; out[13] = 0.0f;
out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 0.0f; out[14] = 0.0f;
out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 0.0f;
}

void Matrix16Identity( matrix_t out )
void Mat4Identity( mat4_t out )
{
out[ 0] = 1.0f; out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = 0.0f;
out[ 1] = 0.0f; out[ 5] = 1.0f; out[ 9] = 0.0f; out[13] = 0.0f;
out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 1.0f; out[14] = 0.0f;
out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f;
}

void Matrix16Copy( const matrix_t in, matrix_t out )
void Mat4Copy( const mat4_t in, mat4_t out )
{
out[ 0] = in[ 0]; out[ 4] = in[ 4]; out[ 8] = in[ 8]; out[12] = in[12];
out[ 1] = in[ 1]; out[ 5] = in[ 5]; out[ 9] = in[ 9]; out[13] = in[13];
out[ 2] = in[ 2]; out[ 6] = in[ 6]; out[10] = in[10]; out[14] = in[14];
out[ 3] = in[ 3]; out[ 7] = in[ 7]; out[11] = in[11]; out[15] = in[15];
}

void Matrix16Multiply( const matrix_t in1, const matrix_t in2, matrix_t out )
void Mat4Multiply( const mat4_t in1, const mat4_t in2, mat4_t out )
{
out[ 0] = in1[ 0] * in2[ 0] + in1[ 4] * in2[ 1] + in1[ 8] * in2[ 2] + in1[12] * in2[ 3];
out[ 1] = in1[ 1] * in2[ 0] + in1[ 5] * in2[ 1] + in1[ 9] * in2[ 2] + in1[13] * in2[ 3];
Expand All @@ -73,47 +73,47 @@ void Matrix16Multiply( const matrix_t in1, const matrix_t in2, matrix_t out )
out[15] = in1[ 3] * in2[12] + in1[ 7] * in2[13] + in1[11] * in2[14] + in1[15] * in2[15];
}

void Matrix16Transform( const matrix_t in1, const vec4_t in2, vec4_t out )
void Mat4Transform( const mat4_t in1, const vec4_t in2, vec4_t out )
{
out[ 0] = in1[ 0] * in2[ 0] + in1[ 4] * in2[ 1] + in1[ 8] * in2[ 2] + in1[12] * in2[ 3];
out[ 1] = in1[ 1] * in2[ 0] + in1[ 5] * in2[ 1] + in1[ 9] * in2[ 2] + in1[13] * in2[ 3];
out[ 2] = in1[ 2] * in2[ 0] + in1[ 6] * in2[ 1] + in1[10] * in2[ 2] + in1[14] * in2[ 3];
out[ 3] = in1[ 3] * in2[ 0] + in1[ 7] * in2[ 1] + in1[11] * in2[ 2] + in1[15] * in2[ 3];
}

qboolean Matrix16Compare( const matrix_t a, const matrix_t b )
qboolean Mat4Compare( const mat4_t a, const mat4_t b )
{
return !(a[ 0] != b[ 0] || a[ 4] != b[ 4] || a[ 8] != b[ 8] || a[12] != b[12] ||
a[ 1] != b[ 1] || a[ 5] != b[ 5] || a[ 9] != b[ 9] || a[13] != b[13] ||
a[ 2] != b[ 2] || a[ 6] != b[ 6] || a[10] != b[10] || a[14] != b[14] ||
a[ 3] != b[ 3] || a[ 7] != b[ 7] || a[11] != b[11] || a[15] != b[15]);
}

void Matrix16Dump( const matrix_t in )
void Mat4Dump( const mat4_t in )
{
ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 0], in[ 4], in[ 8], in[12]);
ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 1], in[ 5], in[ 9], in[13]);
ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 2], in[ 6], in[10], in[14]);
ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 3], in[ 7], in[11], in[15]);
}

void Matrix16Translation( vec3_t vec, matrix_t out )
void Mat4Translation( vec3_t vec, mat4_t out )
{
out[ 0] = 1.0f; out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = vec[0];
out[ 1] = 0.0f; out[ 5] = 1.0f; out[ 9] = 0.0f; out[13] = vec[1];
out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 1.0f; out[14] = vec[2];
out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f;
}

void Matrix16Ortho( float left, float right, float bottom, float top, float znear, float zfar, matrix_t out )
void Mat4Ortho( float left, float right, float bottom, float top, float znear, float zfar, mat4_t out )
{
out[ 0] = 2.0f / (right - left); out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = -(right + left) / (right - left);
out[ 1] = 0.0f; out[ 5] = 2.0f / (top - bottom); out[ 9] = 0.0f; out[13] = -(top + bottom) / (top - bottom);
out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 2.0f / (zfar - znear); out[14] = -(zfar + znear) / (zfar - znear);
out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f;
}

void Matrix16View(vec3_t axes[3], vec3_t origin, matrix_t out)
void Mat4View(vec3_t axes[3], vec3_t origin, mat4_t out)
{
out[0] = axes[0][0];
out[1] = axes[1][0];
Expand All @@ -136,7 +136,7 @@ void Matrix16View(vec3_t axes[3], vec3_t origin, matrix_t out)
out[15] = 1;
}

void Matrix16SimpleInverse( const matrix_t in, matrix_t out)
void Mat4SimpleInverse( const mat4_t in, mat4_t out)
{
vec3_t v;
float invSqrLen;
Expand Down
32 changes: 16 additions & 16 deletions code/renderergl2/tr_extramath.h
Expand Up @@ -24,22 +24,22 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef __TR_EXTRAMATH_H__
#define __TR_EXTRAMATH_H__

typedef vec_t matrix_t[16];
typedef int vec2i_t[2];
typedef int vec3i_t[3];
typedef int vec4i_t[4];

void Matrix16Zero( matrix_t out );
void Matrix16Identity( matrix_t out );
void Matrix16Copy( const matrix_t in, matrix_t out );
void Matrix16Multiply( const matrix_t in1, const matrix_t in2, matrix_t out );
void Matrix16Transform( const matrix_t in1, const vec4_t in2, vec4_t out );
qboolean Matrix16Compare(const matrix_t a, const matrix_t b);
void Matrix16Dump( const matrix_t in );
void Matrix16Translation( vec3_t vec, matrix_t out );
void Matrix16Ortho( float left, float right, float bottom, float top, float znear, float zfar, matrix_t out );
void Matrix16View(vec3_t axes[3], vec3_t origin, matrix_t out);
void Matrix16SimpleInverse( const matrix_t in, matrix_t out);
typedef vec_t mat4_t[16];
typedef int ivec2_t[2];
typedef int ivec3_t[3];
typedef int ivec4_t[4];

void Mat4Zero( mat4_t out );
void Mat4Identity( mat4_t out );
void Mat4Copy( const mat4_t in, mat4_t out );
void Mat4Multiply( const mat4_t in1, const mat4_t in2, mat4_t out );
void Mat4Transform( const mat4_t in1, const vec4_t in2, vec4_t out );
qboolean Mat4Compare(const mat4_t a, const mat4_t b);
void Mat4Dump( const mat4_t in );
void Mat4Translation( vec3_t vec, mat4_t out );
void Mat4Ortho( float left, float right, float bottom, float top, float znear, float zfar, mat4_t out );
void Mat4View(vec3_t axes[3], vec3_t origin, mat4_t out);
void Mat4SimpleInverse( const mat4_t in, mat4_t out);

#define VectorCopy2(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1])
#define VectorSet2(v,x,y) ((v)[0]=(x),(v)[1]=(y));
Expand Down

0 comments on commit ad514c9

Please sign in to comment.