TINYGL: Use astyle to (semi-selectively) apply the code-formatting conventions to TinyGL.

This commit is contained in:
Einar Johan Trøan Sømåen 2014-02-20 18:46:49 +01:00
parent b21271bd82
commit 698ef4a37c
26 changed files with 835 additions and 838 deletions

View file

@ -27,7 +27,7 @@ void glopEdgeFlag(GLContext *c, GLParam *p) {
c->current_edge_flag = p[1].i;
}
void glopColor(GLContext *c, GLParam *p){
void glopColor(GLContext *c, GLParam *p) {
c->current_color.X = p[1].f;
c->current_color.Y = p[2].f;
c->current_color.Z = p[3].f;
@ -85,8 +85,8 @@ void glopBegin(GLContext *c, GLParam *p) {
float *m = &c->matrix_model_projection.m[0][0];
// precompute projection matrix
gl_M4_Mul(&c->matrix_model_projection,
c->matrix_stack_ptr[1],
c->matrix_stack_ptr[0]);
c->matrix_stack_ptr[1],
c->matrix_stack_ptr[0]);
// test to accelerate computation
c->matrix_model_projection_no_w_transform = 0;
if (m[12] == 0.0 && m[13] == 0.0 && m[14] == 0.0)
@ -103,7 +103,7 @@ void glopBegin(GLContext *c, GLParam *p) {
gl_eval_viewport(c);
c->viewport.updated = 0;
}
// triangle drawing functions
// triangle drawing functions
if (c->render_mode == TGL_SELECT) {
c->draw_triangle_front = gl_draw_triangle_select;
c->draw_triangle_back = gl_draw_triangle_select;
@ -141,17 +141,17 @@ static inline void gl_vertex_transform(GLContext *c, GLVertex *v) {
V4 *n;
if (c->lighting_enabled) {
// eye coordinates needed for lighting
// eye coordinates needed for lighting
m = &c->matrix_stack_ptr[0]->m[0][0];
v->ec.X = (v->coord.X * m[0] + v->coord.Y * m[1] +
v->coord.Z * m[2] + m[3]);
v->coord.Z * m[2] + m[3]);
v->ec.Y = (v->coord.X * m[4] + v->coord.Y * m[5] +
v->coord.Z * m[6] + m[7]);
v->coord.Z * m[6] + m[7]);
v->ec.Z = (v->coord.X * m[8] + v->coord.Y * m[9] +
v->coord.Z * m[10] + m[11]);
v->coord.Z * m[10] + m[11]);
v->ec.W = (v->coord.X * m[12] + v->coord.Y * m[13] +
v->coord.Z * m[14] + m[15]);
v->coord.Z * m[14] + m[15]);
// projection coordinates
m = &c->matrix_stack_ptr[1]->m[0][0];
@ -170,7 +170,7 @@ static inline void gl_vertex_transform(GLContext *c, GLVertex *v) {
if (c->normalize_enabled) {
gl_V3_Norm(&v->normal);
}
} else {
} else {
// no eye coordinates needed, no normal
// NOTE: W = 1 is assumed
m = &c->matrix_model_projection.m[0][0];
@ -202,7 +202,7 @@ void glopVertex(GLContext *c, GLParam *p) {
// quick fix to avoid crashes on large polygons
if (n >= c->vertex_max) {
GLVertex *newarray;
c->vertex_max <<= 1; // just double size
c->vertex_max <<= 1; // just double size
newarray = (GLVertex *)gl_malloc(sizeof(GLVertex) * c->vertex_max);
if (!newarray) {
error("unable to allocate GLVertex array.");
@ -239,11 +239,11 @@ void glopVertex(GLContext *c, GLParam *p) {
v->tex_coord = c->current_tex_coord;
}
}
// precompute the mapping to the viewport
// precompute the mapping to the viewport
if (v->clip_code == 0)
gl_transform_to_viewport(c, v);
// edge flag
// edge flag
v->edge_flag = c->current_edge_flag;
@ -258,8 +258,8 @@ void glopVertex(GLContext *c, GLParam *p) {
n = 0;
}
break;
case TGL_LINE_STRIP:
case TGL_LINE_LOOP:
case TGL_LINE_STRIP:
case TGL_LINE_LOOP:
if (n == 1) {
c->vertex[2] = c->vertex[0];
} else if (n == 2) {
@ -277,26 +277,26 @@ void glopVertex(GLContext *c, GLParam *p) {
case TGL_TRIANGLE_STRIP:
if (cnt >= 3) {
if (n == 3)
n = 0;
n = 0;
// needed to respect triangle orientation
switch (cnt & 1) {
case 0:
gl_draw_triangle(c, &c->vertex[2], &c->vertex[1], &c->vertex[0]);
break;
gl_draw_triangle(c, &c->vertex[2], &c->vertex[1], &c->vertex[0]);
break;
case 1:
gl_draw_triangle(c,&c->vertex[0], &c->vertex[1], &c->vertex[2]);
break;
gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]);
break;
}
}
break;
case TGL_TRIANGLE_FAN:
case TGL_TRIANGLE_FAN:
if (n == 3) {
gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]);
c->vertex[1] = c->vertex[2];
n = 2;
}
break;
case TGL_QUADS:
case TGL_QUADS:
if (n == 4) {
c->vertex[2].edge_flag = 0;
gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]);
@ -317,7 +317,7 @@ void glopVertex(GLContext *c, GLParam *p) {
break;
case TGL_POLYGON:
break;
default:
default:
error("glBegin: type %x not handled", c->begin_type);
}