Add gl_drawline to util.c
This commit is contained in:
parent
9ec237509d
commit
5aa85bc274
|
@ -1,12 +1,18 @@
|
||||||
#ifndef UTIL_H_
|
#ifndef UTIL_H_
|
||||||
#define UTIL_H_
|
#define UTIL_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include "sdk.h"
|
#include "sdk.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
/* Vector 2 for 2d points */
|
/* Vector 2 for 2d points */
|
||||||
typedef float vec2_t[2];
|
typedef float vec2_t[2];
|
||||||
|
|
||||||
|
/* RGB color */
|
||||||
|
typedef struct {
|
||||||
|
uint8_t r, g, b;
|
||||||
|
} rgb_t;
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
bool is_alive(cl_entity_t* ent);
|
bool is_alive(cl_entity_t* ent);
|
||||||
|
@ -15,5 +21,6 @@ char* get_name(int ent_idx);
|
||||||
vec3_t vec3(float x, float y, float z);
|
vec3_t vec3(float x, float y, float z);
|
||||||
bool vec_is_zero(vec3_t v);
|
bool vec_is_zero(vec3_t v);
|
||||||
bool world_to_screen(vec3_t vec, vec2_t screen);
|
bool world_to_screen(vec3_t vec, vec2_t screen);
|
||||||
|
void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col);
|
||||||
|
|
||||||
#endif /* UTIL_H_ */
|
#endif /* UTIL_H_ */
|
||||||
|
|
18
src/util.c
18
src/util.c
|
@ -3,6 +3,8 @@
|
||||||
#include "include/sdk.h"
|
#include "include/sdk.h"
|
||||||
#include "include/globals.h"
|
#include "include/globals.h"
|
||||||
|
|
||||||
|
#include <GL/gl.h>
|
||||||
|
|
||||||
bool is_alive(cl_entity_t* ent) {
|
bool is_alive(cl_entity_t* ent) {
|
||||||
return ent && ent->curstate.movetype != 6 && ent->curstate.movetype != 0;
|
return ent && ent->curstate.movetype != 6 && ent->curstate.movetype != 0;
|
||||||
}
|
}
|
||||||
|
@ -54,3 +56,19 @@ bool world_to_screen(vec3_t vec, vec2_t screen) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col) {
|
||||||
|
const int alpha = 255;
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glColor4ub(col.r, col.g, col.b, alpha); /* Set colors + alpha */
|
||||||
|
glLineWidth(w); /* Set line width */
|
||||||
|
glBegin(GL_LINES); /* Interpret vertices as lines */
|
||||||
|
glVertex2i(x0, y0); /* Start */
|
||||||
|
glVertex2i(x1, y1); /* End */
|
||||||
|
glEnd(); /* Stop glBegin, end line mode */
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue