mirror of
https://github.com/w23/xash3d-fwgs
synced 2025-01-18 23:00:01 +01:00
vk: set beam/triapi texture and render mode explicitly
This commit is contained in:
parent
cf5d3d9d47
commit
2daa130453
@ -1106,26 +1106,27 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
|
||||
// TODO gl renderer has per-vertex color that is updated using brightness and whatever
|
||||
VK_RenderDebugLabelBegin( "beam" );
|
||||
|
||||
TriSetTexture( texturenum );
|
||||
TriRenderMode( render_mode );
|
||||
TriColor4f( color[0], color[1], color[2], color[3] );
|
||||
|
||||
switch( pbeam->type )
|
||||
{
|
||||
case TE_BEAMTORUS:
|
||||
// FIXME VK GL_Cull( GL_NONE );
|
||||
TriBegin( TRI_TRIANGLE_STRIP );
|
||||
TriColor4f( color[0], color[1], color[2], color[3] );
|
||||
R_DrawTorus( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
||||
TriEnd();
|
||||
break;
|
||||
case TE_BEAMDISK:
|
||||
// FIXME VK GL_Cull( GL_NONE );
|
||||
TriBegin( TRI_TRIANGLE_STRIP );
|
||||
TriColor4f( color[0], color[1], color[2], color[3] );
|
||||
R_DrawDisk( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
||||
TriEnd();
|
||||
break;
|
||||
case TE_BEAMCYLINDER:
|
||||
// FIXME VK GL_Cull( GL_NONE );
|
||||
TriBegin( TRI_TRIANGLE_STRIP );
|
||||
TriColor4f( color[0], color[1], color[2], color[3] );
|
||||
R_DrawCylinder( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
||||
TriEnd();
|
||||
break;
|
||||
@ -1142,7 +1143,6 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
|
||||
case TE_BEAMRING:
|
||||
// FIXME VK GL_Cull( GL_NONE );
|
||||
TriBegin( TRI_TRIANGLE_STRIP );
|
||||
TriColor4f( color[0], color[1], color[2], color[3] );
|
||||
R_DrawRing( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
|
||||
TriEnd();
|
||||
break;
|
||||
|
@ -14,26 +14,53 @@ static struct {
|
||||
uint16_t indices[MAX_TRIAPI_INDICES];
|
||||
|
||||
int num_vertices;
|
||||
int mode;
|
||||
int primitive_mode;
|
||||
int texture_index;
|
||||
|
||||
vk_render_type_e render_type;
|
||||
|
||||
qboolean initialized;
|
||||
} g_triapi = {0};
|
||||
|
||||
void TriBegin( int mode ) {
|
||||
ASSERT(!g_triapi.mode);
|
||||
void TriSetTexture( int texture_index ) {
|
||||
g_triapi.texture_index = texture_index;
|
||||
}
|
||||
|
||||
switch(mode) {
|
||||
void TriRenderMode( int render_mode ) {
|
||||
switch( render_mode )
|
||||
{
|
||||
case kRenderTransAlpha: g_triapi.render_type = kVkRenderType_A_1mA_R; break;
|
||||
case kRenderTransColor:
|
||||
case kRenderTransTexture: g_triapi.render_type = kVkRenderType_A_1mA_RW; break;
|
||||
case kRenderGlow:
|
||||
case kRenderTransAdd: g_triapi.render_type = kVkRenderType_A_1_R; break;
|
||||
case kRenderNormal:
|
||||
default: g_triapi.render_type = kVkRenderTypeSolid; break;
|
||||
}
|
||||
}
|
||||
|
||||
void TriBegin( int primitive_mode ) {
|
||||
ASSERT(!g_triapi.primitive_mode);
|
||||
|
||||
switch(primitive_mode) {
|
||||
case TRI_TRIANGLES: break;
|
||||
case TRI_TRIANGLE_STRIP: break;
|
||||
default:
|
||||
gEngine.Con_Printf(S_ERROR "TriBegin: unsupported mode %d\n", mode);
|
||||
gEngine.Con_Printf(S_ERROR "TriBegin: unsupported primitive_mode %d\n", primitive_mode);
|
||||
return;
|
||||
}
|
||||
|
||||
g_triapi.mode = mode + 1;
|
||||
g_triapi.num_vertices = 0;
|
||||
|
||||
vk_vertex_t *const ve = g_triapi.vertices + 0;
|
||||
memset(ve, 0, sizeof *ve);
|
||||
Vector4Set(ve->color, 255, 255, 255, 255);
|
||||
if (g_triapi.num_vertices > 1)
|
||||
*ve = g_triapi.vertices[g_triapi.num_vertices-1];
|
||||
|
||||
if (!g_triapi.initialized) {
|
||||
Vector4Set(ve->color, 255, 255, 255, 255);
|
||||
g_triapi.initialized = true;
|
||||
}
|
||||
|
||||
g_triapi.primitive_mode = primitive_mode + 1;
|
||||
g_triapi.num_vertices = 0;
|
||||
}
|
||||
|
||||
/* static int genTrianglesIndices(void) { */
|
||||
@ -84,13 +111,11 @@ static void emitDynamicGeometry(int num_indices) {
|
||||
|
||||
{
|
||||
// FIXME pass these properly
|
||||
const int texture = tglob.whiteTexture;
|
||||
const vec4_t color = {1, 1, 1, 1};
|
||||
const vk_render_type_e render_type = kVkRenderType_A_1_R;
|
||||
const char* name = "FIXME triapi";
|
||||
|
||||
const vk_render_geometry_t geometry = {
|
||||
.texture = texture,
|
||||
.texture = g_triapi.texture_index,
|
||||
.material = kXVkMaterialEmissive,
|
||||
|
||||
.max_vertex = g_triapi.num_vertices,
|
||||
@ -102,21 +127,21 @@ static void emitDynamicGeometry(int num_indices) {
|
||||
.emissive = { color[0], color[1], color[2] },
|
||||
};
|
||||
|
||||
VK_RenderModelDynamicBegin( render_type, color, name );
|
||||
VK_RenderModelDynamicBegin( g_triapi.render_type, color, name );
|
||||
VK_RenderModelDynamicAddGeometry( &geometry );
|
||||
VK_RenderModelDynamicCommit();
|
||||
}
|
||||
}
|
||||
|
||||
void TriEnd( void ) {
|
||||
if (!g_triapi.mode)
|
||||
if (!g_triapi.primitive_mode)
|
||||
return;
|
||||
|
||||
if (!g_triapi.num_vertices)
|
||||
return;
|
||||
|
||||
int num_indices = 0;
|
||||
switch(g_triapi.mode - 1) {
|
||||
switch(g_triapi.primitive_mode - 1) {
|
||||
/* case TRI_TRIANGLES: */
|
||||
/* num_indices = genTrianglesIndices(); */
|
||||
/* break; */
|
||||
@ -124,14 +149,14 @@ void TriEnd( void ) {
|
||||
num_indices = genTriangleStripIndices();
|
||||
break;
|
||||
default:
|
||||
gEngine.Con_Printf(S_ERROR "TriEnd: unsupported mode %d\n", g_triapi.mode - 1);
|
||||
gEngine.Con_Printf(S_ERROR "TriEnd: unsupported primitive_mode %d\n", g_triapi.primitive_mode - 1);
|
||||
break;
|
||||
}
|
||||
|
||||
emitDynamicGeometry(num_indices);
|
||||
|
||||
g_triapi.num_vertices = 0;
|
||||
g_triapi.mode = 0;
|
||||
g_triapi.primitive_mode = 0;
|
||||
}
|
||||
|
||||
void TriTexCoord2f( float u, float v ) {
|
||||
|
@ -2,11 +2,13 @@
|
||||
|
||||
#include "xash3d_types.h"
|
||||
|
||||
void TriRenderMode( int mode );
|
||||
void TriSetTexture( int texture_index );
|
||||
|
||||
void TriBegin( int mode );
|
||||
|
||||
void TriTexCoord2f( float u, float v );
|
||||
void TriColor4f( float r, float g, float b, float a );
|
||||
//void TriColor4ub( byte r, byte g, byte b, byte a );
|
||||
|
||||
// Emits next vertex
|
||||
void TriVertex3fv( const float *v );
|
||||
|
Loading…
x
Reference in New Issue
Block a user