143 for (
i=0 ;
i<4 ;
i++)
208 float quadVerts[] = { spriteQuad[0][0], spriteQuad[0][1], spriteQuad[0][2], 0.f, 1.f,
209 spriteQuad[1][0], spriteQuad[1][1], spriteQuad[1][2], 0.f, 0.f,
210 spriteQuad[2][0], spriteQuad[2][1], spriteQuad[2][2], 1.f, 0.f,
211 spriteQuad[0][0], spriteQuad[0][1], spriteQuad[0][2], 0.f, 1.f,
212 spriteQuad[2][0], spriteQuad[2][1], spriteQuad[2][2], 1.f, 0.f,
213 spriteQuad[3][0], spriteQuad[3][1], spriteQuad[3][2], 1.f, 1.f };
219 VkDeviceSize vboOffset;
221 memcpy(vertData, quadVerts,
sizeof(quadVerts));
257 for (
i = 2,
j = 0;
i < 12;
i+=2,
j++)
259 verts[
i][0] = 16 * cos(
j*
M_PI / 2);
260 verts[
i][1] = 16 * sin(
j*
M_PI / 2);
274 for (
i = 23,
j = 4;
i > 13;
i-=2,
j--)
276 verts[
i-1][0] = 16 * cos(
j*
M_PI / 2);
277 verts[
i-1][1] = 16 * sin(
j*
M_PI / 2);
285 VkDeviceSize vboOffset;
287 VkDescriptorSet uboDescriptorSet;
290 memcpy(vertData, verts,
sizeof(verts));
291 memcpy(uboData, model,
sizeof(model));
424 scale = 1 + scale * 0.004;
426 *(
int *)color = colortable[p->
color];
429 float r = color[0] / 255.f;
430 float g = color[1] / 255.f;
431 float b = color[2] / 255.f;
433 visibleParticles[idx].x = p->
origin[0];
434 visibleParticles[idx].y = p->
origin[1];
435 visibleParticles[idx].z = p->
origin[2];
436 visibleParticles[idx].r =
r;
437 visibleParticles[idx].g = g;
438 visibleParticles[idx].b = b;
439 visibleParticles[idx].a = p->
alpha;
440 visibleParticles[idx].u = 0.0625;
441 visibleParticles[idx].v = 0.0625;
443 visibleParticles[idx + 1].x = p->
origin[0] +
up[0] * scale;
444 visibleParticles[idx + 1].y = p->
origin[1] +
up[1] * scale;
445 visibleParticles[idx + 1].z = p->
origin[2] +
up[2] * scale;
446 visibleParticles[idx + 1].r =
r;
447 visibleParticles[idx + 1].g = g;
448 visibleParticles[idx + 1].b = b;
449 visibleParticles[idx + 1].a = p->
alpha;
450 visibleParticles[idx + 1].u = 1.0625;
451 visibleParticles[idx + 1].v = 0.0625;
453 visibleParticles[idx + 2].x = p->
origin[0] +
right[0] * scale;
454 visibleParticles[idx + 2].y = p->
origin[1] +
right[1] * scale;
455 visibleParticles[idx + 2].z = p->
origin[2] +
right[2] * scale;
456 visibleParticles[idx + 2].r =
r;
457 visibleParticles[idx + 2].g = g;
458 visibleParticles[idx + 2].b = b;
459 visibleParticles[idx + 2].a = p->
alpha;
460 visibleParticles[idx + 2].u = 0.0625;
461 visibleParticles[idx + 2].v = 1.0625;
467 VkDeviceSize vboOffset;
468 uint8_t *vertData =
QVk_GetVertexBuffer(3 *
sizeof(pvertex) * num_particles, &vbo, &vboOffset);
469 memcpy(vertData, &visibleParticles, 3 *
sizeof(pvertex) * num_particles);
486 unsigned char color[4];
493 float x,
y,
z,
r, g, b, a;
520 float r = color[0] / 255.f;
521 float g = color[1] / 255.f;
522 float b = color[2] / 255.f;
524 visibleParticles[
i].x = p->
origin[0];
525 visibleParticles[
i].y = p->
origin[1];
526 visibleParticles[
i].z = p->
origin[2];
527 visibleParticles[
i].r =
r;
528 visibleParticles[
i].g = g;
529 visibleParticles[
i].b = b;
530 visibleParticles[
i].a = p->
alpha;
536 VkDeviceSize vboOffset;
538 VkDescriptorSet uboDescriptorSet;
542 memcpy(uboData, &particleUbo,
sizeof(particleUbo));
578 for (
j = 0;
j<3;
j++)
598 for (
int i = 0;
i < 4;
i++)
658 for (
i = 0;
i < 4;
i++)
670 .3f, .3f, .3f, 1.f };
695 void Mat_Mul(
float *m1,
float *m2,
float *res)
697 float mul[16] = { m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12],
698 m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13],
699 m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14],
700 m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15],
701 m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12],
702 m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13],
703 m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14],
704 m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15],
705 m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12],
706 m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13],
707 m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14],
708 m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15],
709 m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12],
710 m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13],
711 m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14],
712 m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]
715 memcpy(res, mul,
sizeof(
float) * 16);
720 float t[16] = { 1.f, 0.f, 0.f, 0.f,
730 double c = cos(deg *
M_PI / 180.0);
731 double s = sin(deg *
M_PI / 180.0);
736 float rot[16] = {
r[0]*
r[0]*cd + c,
r[1]*
r[0]*cd +
r[2]*
s,
r[0]*
r[2]*cd -
r[1]*
s, 0.f,
737 r[0]*
r[1]*cd -
r[2]*
s,
r[1]*
r[1]*cd + c,
r[1]*
r[2]*cd +
r[0]*
s, 0.f,
738 r[0]*
r[2]*cd +
r[1]*
s,
r[1]*
r[2]*cd -
r[0]*
s,
r[2]*
r[2]*cd + c, 0.f,
747 float s[16] = {
x, 0.f, 0.f, 0.f,
756 void Mat_Perspective(
float *matrix,
float *correction_matrix,
float fovy,
float aspect,
759 float xmin, xmax, ymin, ymax;
764 xmin = ymin * aspect;
765 xmax = ymax * aspect;
771 memset(proj, 0,
sizeof(
float) * 16);
772 proj[0] = 2.f *
zNear / (xmax - xmin);
773 proj[2] = (xmax + xmin) / (xmax - xmin);
774 proj[5] = 2.f *
zNear / (ymax - ymin);
775 proj[6] = (ymax + ymin) / (ymax - ymin);
781 Mat_Mul(proj, correction_matrix, matrix);
788 memset(proj, 0,
sizeof(
float) * 16);
789 proj[0] = 2.f / (
right - left);
822 VkViewport viewport = {
1249 ref->modified =
true;
1268 if (swapChainValid != VK_SUCCESS)
1305 for (
i = 0;
i < 256;
i++)
1307 rp[
i * 4 + 0] = palette[
i * 3 + 0];
1308 rp[
i * 4 + 1] = palette[
i * 3 + 1];
1309 rp[
i * 4 + 2] = palette[
i * 3 + 2];
1310 rp[
i * 4 + 3] = 0xff;
1315 for (
i = 0;
i < 256;
i++)
1320 rp[
i * 4 + 3] = 0xff;
1330 #define NUM_BEAM_SEGS 6
1336 vec3_t direction, normalized_direction;
1338 vec3_t oldorigin, origin;
1344 origin[0] = e->
origin[0];
1345 origin[1] = e->
origin[1];
1346 origin[2] = e->
origin[2];
1348 normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
1349 normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
1350 normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
1358 for (
i = 0;
i < 6;
i++)
1361 VectorAdd(start_points[
i], origin, start_points[
i]);
1362 VectorAdd(start_points[
i], direction, end_points[
i]);
1373 float color[4] = {
r, g, b, e->
alpha };
1382 beamvertex[idx].v[0] = start_points[
i][0];
1383 beamvertex[idx].v[1] = start_points[
i][1];
1384 beamvertex[idx].v[2] = start_points[
i][2];
1386 beamvertex[idx + 1].v[0] = end_points[
i][0];
1387 beamvertex[idx + 1].v[1] = end_points[
i][1];
1388 beamvertex[idx + 1].v[2] = end_points[
i][2];
1390 beamvertex[idx + 2].v[0] = start_points[(
i + 1) %
NUM_BEAM_SEGS][0];
1391 beamvertex[idx + 2].v[1] = start_points[(
i + 1) %
NUM_BEAM_SEGS][1];
1392 beamvertex[idx + 2].v[2] = start_points[(
i + 1) %
NUM_BEAM_SEGS][2];
1394 beamvertex[idx + 3].v[0] = end_points[(
i + 1) %
NUM_BEAM_SEGS][0];
1395 beamvertex[idx + 3].v[1] = end_points[(
i + 1) %
NUM_BEAM_SEGS][1];
1396 beamvertex[idx + 3].v[2] = end_points[(
i + 1) %
NUM_BEAM_SEGS][2];
1402 VkDeviceSize vboOffset;
1404 VkDescriptorSet uboDescriptorSet;
1407 memcpy(vertData, beamvertex,
sizeof(beamvertex));
1408 memcpy(uboData, color,
sizeof(color));
1483 #ifndef REF_HARD_LINKED
1490 va_start (argptr,
error);
1491 vsnprintf (text, 1024,
error, argptr);
1502 va_start (argptr, fmt);
1503 vsnprintf (text, 1024, fmt, argptr);