vk: draw the rest of the beams
This commit is contained in:
parent
2daa130453
commit
30334db159
|
@ -152,11 +152,16 @@ static float clampf(float v, float min, float max) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME unclear how to organize this
|
||||||
static void applyBrightness( float brightness, rgba_t out ) {
|
static void applyBrightness( float brightness, rgba_t out ) {
|
||||||
out[0] = out[1] = out[2] = clampf(brightness, 0, 1) * 255.f;
|
out[0] = out[1] = out[2] = clampf(brightness, 0, 1) * 255.f;
|
||||||
out[3] = 255;
|
out[3] = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void TriBrightness( float brightness ) {
|
||||||
|
TriColor4f( brightness, brightness, brightness, 1.f );
|
||||||
|
}
|
||||||
|
|
||||||
static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments, int flags, const vec4_t color, int texture, int render_mode )
|
static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments, int flags, const vec4_t color, int texture, int render_mode )
|
||||||
{
|
{
|
||||||
int noiseIndex, noiseStep;
|
int noiseIndex, noiseStep;
|
||||||
|
@ -399,7 +404,7 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments )
|
static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments, const vec4_t color )
|
||||||
{
|
{
|
||||||
int i, noiseIndex, noiseStep;
|
int i, noiseIndex, noiseStep;
|
||||||
float div, length, fraction, factor, vLast, vStep;
|
float div, length, fraction, factor, vLast, vStep;
|
||||||
|
@ -426,6 +431,8 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
|
||||||
noiseStep = (int)((float)( NOISE_DIVISIONS - 1 ) * div * 65536.0f );
|
noiseStep = (int)((float)( NOISE_DIVISIONS - 1 ) * div * 65536.0f );
|
||||||
noiseIndex = 0;
|
noiseIndex = 0;
|
||||||
|
|
||||||
|
TriBegin( TRI_TRIANGLE_STRIP );
|
||||||
|
|
||||||
for( i = 0; i < segments; i++ )
|
for( i = 0; i < segments; i++ )
|
||||||
{
|
{
|
||||||
float s, c;
|
float s, c;
|
||||||
|
@ -479,13 +486,12 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
|
||||||
VectorCopy( screen, screenLast );
|
VectorCopy( screen, screenLast );
|
||||||
noiseIndex += noiseStep;
|
noiseIndex += noiseStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TriEndEx(color, "beam torus");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments )
|
static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments, const vec4_t color )
|
||||||
{
|
{
|
||||||
PRINT_NOT_IMPLEMENTED();
|
|
||||||
|
|
||||||
/* FIXME VK
|
|
||||||
float div, length, fraction;
|
float div, length, fraction;
|
||||||
float w, vLast, vStep;
|
float w, vLast, vStep;
|
||||||
vec3_t point;
|
vec3_t point;
|
||||||
|
@ -509,6 +515,8 @@ static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, f
|
||||||
// clamp the beam width
|
// clamp the beam width
|
||||||
w = fmod( freq, width * 0.1f ) * delta[2];
|
w = fmod( freq, width * 0.1f ) * delta[2];
|
||||||
|
|
||||||
|
TriBegin( TRI_TRIANGLE_STRIP );
|
||||||
|
|
||||||
// NOTE: we must force the degenerate triangles to be on the edge
|
// NOTE: we must force the degenerate triangles to be on the edge
|
||||||
for( i = 0; i < segments; i++ )
|
for( i = 0; i < segments; i++ )
|
||||||
{
|
{
|
||||||
|
@ -532,14 +540,12 @@ static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, f
|
||||||
|
|
||||||
vLast += vStep; // advance texture scroll (v axis only)
|
vLast += vStep; // advance texture scroll (v axis only)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
TriEndEx(color, "beam disk");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments )
|
static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments, const vec4_t color )
|
||||||
{
|
{
|
||||||
PRINT_NOT_IMPLEMENTED();
|
|
||||||
|
|
||||||
/* FIXME VK
|
|
||||||
float div, length, fraction;
|
float div, length, fraction;
|
||||||
float vLast, vStep;
|
float vLast, vStep;
|
||||||
vec3_t point;
|
vec3_t point;
|
||||||
|
@ -561,6 +567,7 @@ static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scal
|
||||||
vLast = fmod( freq * speed, 1 );
|
vLast = fmod( freq * speed, 1 );
|
||||||
scale = scale * length;
|
scale = scale * length;
|
||||||
|
|
||||||
|
TriBegin( TRI_TRIANGLE_STRIP );
|
||||||
for ( i = 0; i < segments; i++ )
|
for ( i = 0; i < segments; i++ )
|
||||||
{
|
{
|
||||||
float s, c;
|
float s, c;
|
||||||
|
@ -586,14 +593,11 @@ static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scal
|
||||||
|
|
||||||
vLast += vStep; // Advance texture scroll (v axis only)
|
vLast += vStep; // Advance texture scroll (v axis only)
|
||||||
}
|
}
|
||||||
*/
|
TriEndEx(color, "beam cylinder");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
|
static void R_DrawBeamFollow( BEAM *pbeam, float frametime, const vec4_t color )
|
||||||
{
|
{
|
||||||
PRINT_NOT_IMPLEMENTED();
|
|
||||||
|
|
||||||
/* FIXME VK
|
|
||||||
particle_t *pnew, *particles;
|
particle_t *pnew, *particles;
|
||||||
float fraction, div, vLast, vStep;
|
float fraction, div, vLast, vStep;
|
||||||
vec3_t last1, last2, tmp, screen;
|
vec3_t last1, last2, tmp, screen;
|
||||||
|
@ -678,6 +682,7 @@ static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
|
||||||
vLast = 0.0f;
|
vLast = 0.0f;
|
||||||
vStep = 1.0f;
|
vStep = 1.0f;
|
||||||
|
|
||||||
|
TriBegin( TRI_QUADS );
|
||||||
while( particles )
|
while( particles )
|
||||||
{
|
{
|
||||||
TriBrightness( fraction );
|
TriBrightness( fraction );
|
||||||
|
@ -733,10 +738,11 @@ static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
|
||||||
VectorMA( particles->org, frametime, particles->vel, particles->org );
|
VectorMA( particles->org, frametime, particles->vel, particles->org );
|
||||||
particles = particles->next;
|
particles = particles->next;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
TriEndEx(color, "beam follow");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, float freq, float speed, int segments )
|
static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, float freq, float speed, int segments, const vec4_t color )
|
||||||
{
|
{
|
||||||
int i, j, noiseIndex, noiseStep;
|
int i, j, noiseIndex, noiseStep;
|
||||||
float div, length, fraction, factor, vLast, vStep;
|
float div, length, fraction, factor, vLast, vStep;
|
||||||
|
@ -798,6 +804,7 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
|
||||||
|
|
||||||
j = segments / 8;
|
j = segments / 8;
|
||||||
|
|
||||||
|
TriBegin( TRI_TRIANGLE_STRIP );
|
||||||
for( i = 0; i < segments + 1; i++ )
|
for( i = 0; i < segments + 1; i++ )
|
||||||
{
|
{
|
||||||
fraction = i * div;
|
fraction = i * div;
|
||||||
|
@ -851,6 +858,7 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
|
||||||
FracNoise( rgNoise, NOISE_DIVISIONS );
|
FracNoise( rgNoise, NOISE_DIVISIONS );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TriEndEx( color, "beam ring" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1114,37 +1122,26 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
|
||||||
{
|
{
|
||||||
case TE_BEAMTORUS:
|
case TE_BEAMTORUS:
|
||||||
// FIXME VK GL_Cull( GL_NONE );
|
// FIXME VK GL_Cull( GL_NONE );
|
||||||
TriBegin( TRI_TRIANGLE_STRIP );
|
R_DrawTorus( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments, color );
|
||||||
R_DrawTorus( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
|
||||||
TriEnd();
|
|
||||||
break;
|
break;
|
||||||
case TE_BEAMDISK:
|
case TE_BEAMDISK:
|
||||||
// FIXME VK GL_Cull( GL_NONE );
|
// FIXME VK GL_Cull( GL_NONE );
|
||||||
TriBegin( TRI_TRIANGLE_STRIP );
|
R_DrawDisk( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments, color );
|
||||||
R_DrawDisk( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
|
||||||
TriEnd();
|
|
||||||
break;
|
break;
|
||||||
case TE_BEAMCYLINDER:
|
case TE_BEAMCYLINDER:
|
||||||
// FIXME VK GL_Cull( GL_NONE );
|
// FIXME VK GL_Cull( GL_NONE );
|
||||||
TriBegin( TRI_TRIANGLE_STRIP );
|
R_DrawCylinder( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments, color );
|
||||||
R_DrawCylinder( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
|
||||||
TriEnd();
|
|
||||||
break;
|
break;
|
||||||
case TE_BEAMPOINTS:
|
case TE_BEAMPOINTS:
|
||||||
case TE_BEAMHOSE:
|
case TE_BEAMHOSE:
|
||||||
R_DrawSegs( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments, pbeam->flags, color, texturenum, render_mode );
|
R_DrawSegs( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments, pbeam->flags, color, texturenum, render_mode );
|
||||||
break;
|
break;
|
||||||
case TE_BEAMFOLLOW:
|
case TE_BEAMFOLLOW:
|
||||||
// FIXME VK TriBegin( TRI_QUADS );
|
R_DrawBeamFollow( pbeam, frametime, color );
|
||||||
//TriColor4f( color[0], color[1], color[2], color[3] );
|
|
||||||
//R_DrawBeamFollow( pbeam, frametime );
|
|
||||||
//TriEnd();
|
|
||||||
break;
|
break;
|
||||||
case TE_BEAMRING:
|
case TE_BEAMRING:
|
||||||
// FIXME VK GL_Cull( GL_NONE );
|
// FIXME VK GL_Cull( GL_NONE );
|
||||||
TriBegin( TRI_TRIANGLE_STRIP );
|
R_DrawRing( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments, color );
|
||||||
R_DrawRing( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
|
||||||
TriEnd();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ static int genTriangleStripIndices(void) {
|
||||||
return num_indices;
|
return num_indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emitDynamicGeometry(int num_indices) {
|
static void emitDynamicGeometry(int num_indices, const vec4_t color, const char* name ) {
|
||||||
if (!num_indices)
|
if (!num_indices)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -110,13 +110,9 @@ static void emitDynamicGeometry(int num_indices) {
|
||||||
R_GeometryBufferUnlock( &buffer );
|
R_GeometryBufferUnlock( &buffer );
|
||||||
|
|
||||||
{
|
{
|
||||||
// FIXME pass these properly
|
|
||||||
const vec4_t color = {1, 1, 1, 1};
|
|
||||||
const char* name = "FIXME triapi";
|
|
||||||
|
|
||||||
const vk_render_geometry_t geometry = {
|
const vk_render_geometry_t geometry = {
|
||||||
.texture = g_triapi.texture_index,
|
.texture = g_triapi.texture_index,
|
||||||
.material = kXVkMaterialEmissive,
|
.material = (g_triapi.render_type == kVkRenderTypeSolid) ? kXVkMaterialRegular : kXVkMaterialEmissive,
|
||||||
|
|
||||||
.max_vertex = g_triapi.num_vertices,
|
.max_vertex = g_triapi.num_vertices,
|
||||||
.vertex_offset = buffer.vertices.unit_offset,
|
.vertex_offset = buffer.vertices.unit_offset,
|
||||||
|
@ -140,6 +136,18 @@ void TriEnd( void ) {
|
||||||
if (!g_triapi.num_vertices)
|
if (!g_triapi.num_vertices)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const vk_vertex_t *const v = g_triapi.vertices + g_triapi.num_vertices - 1;
|
||||||
|
const vec4_t color = {v->color[0] / 255.f, v->color[1] / 255.f, v->color[2] / 255.f, 1.f};
|
||||||
|
TriEndEx( color, "unnamed triapi" );
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriEndEx( const vec4_t color, const char* name ) {
|
||||||
|
if (!g_triapi.primitive_mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!g_triapi.num_vertices)
|
||||||
|
return;
|
||||||
|
|
||||||
int num_indices = 0;
|
int num_indices = 0;
|
||||||
switch(g_triapi.primitive_mode - 1) {
|
switch(g_triapi.primitive_mode - 1) {
|
||||||
/* case TRI_TRIANGLES: */
|
/* case TRI_TRIANGLES: */
|
||||||
|
@ -153,7 +161,7 @@ void TriEnd( void ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
emitDynamicGeometry(num_indices);
|
emitDynamicGeometry(num_indices, color, name);
|
||||||
|
|
||||||
g_triapi.num_vertices = 0;
|
g_triapi.num_vertices = 0;
|
||||||
g_triapi.primitive_mode = 0;
|
g_triapi.primitive_mode = 0;
|
||||||
|
|
|
@ -15,3 +15,4 @@ void TriVertex3fv( const float *v );
|
||||||
void TriVertex3f( float x, float y, float z );
|
void TriVertex3f( float x, float y, float z );
|
||||||
|
|
||||||
void TriEnd( void );
|
void TriEnd( void );
|
||||||
|
void TriEndEx( const vec4_t color, const char* name );
|
||||||
|
|
Loading…
Reference in New Issue