MCPcopy Create free account
hub / github.com/demoth/jake2 / GL_DrawParticles

Method GL_DrawParticles

client/src/main/java/jake2/client/render/fast/Main.java:470–524  ·  view source on GitHub ↗

GL_DrawParticles

(int num_particles)

Source from the content-addressed store, hash-verified

468 * GL_DrawParticles
469 */
470 void GL_DrawParticles(int num_particles) {
471 float origin_x, origin_y, origin_z;
472
473 Math3D.VectorScale(vup, 1.5f, up);
474 Math3D.VectorScale(vright, 1.5f, right);
475
476 GL_Bind(r_particletexture.texnum);
477 gl.glDepthMask(false); // no z buffering
478 gl.glEnable(GL_BLEND);
479 GL_TexEnv(GL_MODULATE);
480
481 gl.glBegin(GL_TRIANGLES);
482
483 FloatBuffer sourceVertices = particle_t.vertexArray;
484 IntBuffer sourceColors = particle_t.colorArray;
485 float scale;
486 int color;
487 for (int j = 0, i = 0; i < num_particles; i++) {
488 origin_x = sourceVertices.get(j++);
489 origin_y = sourceVertices.get(j++);
490 origin_z = sourceVertices.get(j++);
491
492 // hack a scale up to keep particles from disapearing
493 scale =
494 (origin_x - r_origin[0]) * vpn[0]
495 + (origin_y - r_origin[1]) * vpn[1]
496 + (origin_z - r_origin[2]) * vpn[2];
497
498 scale = (scale < 20) ? 1 : 1 + scale * 0.004f;
499
500 color = sourceColors.get(i);
501
502 gl.glColor4ub(
503 (byte)((color) & 0xFF),
504 (byte)((color >> 8) & 0xFF),
505 (byte)((color >> 16) & 0xFF),
506 (byte)((color >>> 24))
507 );
508 // first vertex
509 gl.glTexCoord2f(0.0625f, 0.0625f);
510 gl.glVertex3f(origin_x, origin_y, origin_z);
511 // second vertex
512 gl.glTexCoord2f(1.0625f, 0.0625f);
513 gl.glVertex3f(origin_x + up[0] * scale, origin_y + up[1] * scale, origin_z + up[2] * scale);
514 // third vertex
515 gl.glTexCoord2f(0.0625f, 1.0625f);
516 gl.glVertex3f(origin_x + right[0] * scale, origin_y + right[1] * scale, origin_z + right[2] * scale);
517 }
518 gl.glEnd();
519
520 gl.glDisable(GL_BLEND);
521 gl.glColor4f(1, 1, 1, 1);
522 gl.glDepthMask(true); // back to normal Z buffering
523 GL_TexEnv(GL_REPLACE);
524 }
525
526 /**
527 * R_DrawParticles

Callers 1

R_DrawParticlesMethod · 0.95

Calls 13

VectorScaleMethod · 0.95
GL_BindMethod · 0.95
GL_TexEnvMethod · 0.95
glDepthMaskMethod · 0.65
glEnableMethod · 0.65
glBeginMethod · 0.65
glColor4ubMethod · 0.65
glTexCoord2fMethod · 0.65
glVertex3fMethod · 0.65
glEndMethod · 0.65
glDisableMethod · 0.65
glColor4fMethod · 0.65

Tested by

no test coverage detected