TINYGL: Janitorial
This commit is contained in:
parent
0d6a09c597
commit
25c4e89b7a
8 changed files with 30 additions and 27 deletions
|
@ -121,10 +121,10 @@ void GLContext::init(int screenW, int screenH, Graphics::PixelFormat pixelFormat
|
|||
l->norm_spot_direction = Vector3(0, 0, -1);
|
||||
l->norm_position = Vector3(0, 0, 1);
|
||||
l->enabled = 0;
|
||||
l->next = NULL;
|
||||
l->prev = NULL;
|
||||
l->next = nullptr;
|
||||
l->prev = nullptr;
|
||||
}
|
||||
first_light = NULL;
|
||||
first_light = nullptr;
|
||||
ambient_light_model = Vector4(0.2f, 0.2f, 0.2f, 1);
|
||||
local_light_model = 0;
|
||||
lighting_enabled = 0;
|
||||
|
|
|
@ -184,7 +184,7 @@ void GLContext::gl_enable_disable_light(int light, int v) {
|
|||
if (first_light)
|
||||
first_light->prev = l;
|
||||
first_light = l;
|
||||
l->prev = NULL;
|
||||
l->prev = nullptr;
|
||||
}
|
||||
} else if (!v && l->enabled) {
|
||||
l->enabled = 0;
|
||||
|
@ -215,7 +215,7 @@ void GLContext::gl_shade_vertex(GLVertex *v) {
|
|||
B = m->emission.Z + m->ambient.Z * ambient_light_model.Z;
|
||||
A = clampf(m->diffuse.W, 0, 1);
|
||||
|
||||
for (l = first_light; l != NULL; l = l->next) {
|
||||
for (l = first_light; l != nullptr; l = l->next) {
|
||||
float lR, lB, lG;
|
||||
|
||||
// ambient
|
||||
|
@ -236,7 +236,8 @@ void GLContext::gl_shade_vertex(GLVertex *v) {
|
|||
d.Y = l->position.Y - v->ec.Y;
|
||||
d.Z = l->position.Z - v->ec.Z;
|
||||
dist = sqrt(d.X * d.X + d.Y * d.Y + d.Z * d.Z);
|
||||
att = 1.0f / (l->attenuation[0] + dist * (l->attenuation[1] +
|
||||
att = 1.0f / (l->attenuation[0] +
|
||||
dist * (l->attenuation[1] +
|
||||
dist * l->attenuation[2]));
|
||||
}
|
||||
dot = d.X * n.X + d.Y * n.Y + d.Z * n.Z;
|
||||
|
@ -256,8 +257,8 @@ void GLContext::gl_shade_vertex(GLVertex *v) {
|
|||
if (is_spotlight || has_specular) {
|
||||
if (is_spotlight) {
|
||||
dot_spot = -(d.X * l->norm_spot_direction.X +
|
||||
d.Y * l->norm_spot_direction.Y +
|
||||
d.Z * l->norm_spot_direction.Z);
|
||||
d.Y * l->norm_spot_direction.Y +
|
||||
d.Z * l->norm_spot_direction.Z);
|
||||
if (twoside && dot_spot < 0)
|
||||
dot_spot = -dot_spot;
|
||||
if (dot_spot < l->cos_spot_cutoff) {
|
||||
|
|
|
@ -32,9 +32,8 @@
|
|||
namespace TinyGL {
|
||||
|
||||
#define ADD_OP(aa, bb, ff) \
|
||||
static void glop ## aa (GLContext *c, GLParam *p) \
|
||||
{ \
|
||||
c->glop ## aa (p); \
|
||||
static void glop ## aa (GLContext *c, GLParam *p) { \
|
||||
c->glop ## aa (p); \
|
||||
}
|
||||
#include "graphics/tinygl/opinfo.h"
|
||||
|
||||
|
@ -87,7 +86,7 @@ static GLList *alloc_list(GLContext *c, int list) {
|
|||
l = (GLList *)gl_zalloc(sizeof(GLList));
|
||||
ob = (GLParamBuffer *)gl_zalloc(sizeof(GLParamBuffer));
|
||||
|
||||
ob->next = NULL;
|
||||
ob->next = nullptr;
|
||||
l->first_op_buffer = ob;
|
||||
|
||||
ob->ops[0].op = OP_EndList;
|
||||
|
@ -138,7 +137,7 @@ void GLContext::gl_compile_op(GLParam *p) {
|
|||
if ((index + op_size) > (OP_BUFFER_MAX_SIZE - 2)) {
|
||||
|
||||
ob1 = (GLParamBuffer *)gl_zalloc(sizeof(GLParamBuffer));
|
||||
ob1->next = NULL;
|
||||
ob1->next = nullptr;
|
||||
|
||||
ob->next = ob1;
|
||||
ob->ops[index].op = OP_NextBuffer;
|
||||
|
|
|
@ -141,15 +141,18 @@ void GLContext::glopRotate(GLParam *p) {
|
|||
m.identity();
|
||||
break;
|
||||
case 4:
|
||||
if (u[0] < 0) angle = -angle;
|
||||
if (u[0] < 0)
|
||||
angle = -angle;
|
||||
m.rotation(angle, 0);
|
||||
break;
|
||||
case 2:
|
||||
if (u[1] < 0) angle = -angle;
|
||||
if (u[1] < 0)
|
||||
angle = -angle;
|
||||
m.rotation(angle, 1);
|
||||
break;
|
||||
case 1:
|
||||
if (u[2] < 0) angle = -angle;
|
||||
if (u[2] < 0)
|
||||
angle = -angle;
|
||||
m.rotation(angle, 2);
|
||||
break;
|
||||
default: {
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
namespace Graphics {
|
||||
|
||||
PixelBuffer::PixelBuffer()
|
||||
: _buffer(NULL),
|
||||
: _buffer(nullptr),
|
||||
_dispose(DisposeAfterUse::NO) {
|
||||
|
||||
}
|
||||
|
||||
PixelBuffer::PixelBuffer(const PixelFormat &format, int buffersize, DisposeAfterUse::Flag dispose)
|
||||
: _buffer(NULL),
|
||||
: _buffer(nullptr),
|
||||
_dispose(DisposeAfterUse::NO) {
|
||||
create(format, buffersize, dispose);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ void PixelBuffer::set(const Graphics::PixelFormat &format, byte *buffer) {
|
|||
|
||||
void PixelBuffer::free() {
|
||||
delete[] _buffer;
|
||||
_buffer = NULL;
|
||||
_buffer = nullptr;
|
||||
}
|
||||
|
||||
void PixelBuffer::clear(uint length) {
|
||||
|
|
|
@ -55,11 +55,11 @@ TGLint tglRenderMode(TGLenum mode) {
|
|||
break;
|
||||
case TGL_SELECT:
|
||||
c->render_mode = TGL_SELECT;
|
||||
assert(c->select_buffer != NULL);
|
||||
assert(c->select_buffer != nullptr);
|
||||
c->select_ptr = c->select_buffer;
|
||||
c->select_hits = 0;
|
||||
c->select_overflow = 0;
|
||||
c->select_hit = NULL;
|
||||
c->select_hit = nullptr;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
|
@ -79,7 +79,7 @@ void tglSelectBuffer(TGLsizei size, TGLuint *buffer) {
|
|||
void GLContext::glopInitNames(GLParam *) {
|
||||
if (render_mode == TGL_SELECT) {
|
||||
name_stack_size = 0;
|
||||
select_hit = NULL;
|
||||
select_hit = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ void GLContext::glopPushName(GLParam *p) {
|
|||
if (render_mode == TGL_SELECT) {
|
||||
assert(name_stack_size < MAX_NAME_STACK_DEPTH);
|
||||
name_stack[name_stack_size++] = p[1].i;
|
||||
select_hit = NULL;
|
||||
select_hit = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ void GLContext::glopPopName(GLParam *) {
|
|||
if (render_mode == TGL_SELECT) {
|
||||
assert(name_stack_size > 0);
|
||||
name_stack_size--;
|
||||
select_hit = NULL;
|
||||
select_hit = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ void GLContext::glopLoadName(GLParam *p) {
|
|||
if (render_mode == TGL_SELECT) {
|
||||
assert(name_stack_size > 0);
|
||||
name_stack[name_stack_size - 1] = p[1].i;
|
||||
select_hit = NULL;
|
||||
select_hit = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ void GLContext::glopTexImage2D(GLParam *p) {
|
|||
delete im->pixmap;
|
||||
im->pixmap = nullptr;
|
||||
}
|
||||
if (pixels != NULL) {
|
||||
if (pixels) {
|
||||
uint filter;
|
||||
Graphics::PixelFormat pf;
|
||||
bool found = false;
|
||||
|
|
|
@ -161,7 +161,7 @@ static inline void gl_vertex_transform(GLContext *c, GLVertex *v) {
|
|||
// eye coordinates needed for lighting
|
||||
|
||||
m = c->matrix_stack_ptr[0];
|
||||
m->transform3x4(v->coord,v->ec);
|
||||
m->transform3x4(v->coord, v->ec);
|
||||
|
||||
// projection coordinates
|
||||
m = c->matrix_stack_ptr[1];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue