Make things C89 friendly

This commit is contained in:
Luke Benstead 2018-05-14 17:10:53 +01:00
parent de1fb05ac1
commit 4218111ab8
6 changed files with 23 additions and 12 deletions

View File

@ -90,23 +90,25 @@ static void _parseColour(uint32* out, const GLubyte* in, GLint size, GLenum type
}
static void _parseFloats(GLfloat* out, const GLubyte* in, GLint size, GLenum type) {
GLubyte i = 0;
switch(type) {
case GL_SHORT: {
GLshort* inp = (GLshort*) in;
for(GLubyte i = 0; i < size; ++i) {
for(i = 0; i < size; ++i) {
out[i] = (GLfloat) inp[i];
}
} break;
case GL_INT: {
GLint* inp = (GLint*) in;
for(GLubyte i = 0; i < size; ++i) {
for(i = 0; i < size; ++i) {
out[i] = (GLfloat) inp[i];
}
} break;
case GL_FLOAT:
case GL_DOUBLE: /* Double == Float */
default:
for(GLubyte i = 0; i < size; ++i) out[i] = ((GLfloat*) in)[i];
for(i = 0; i < size; ++i) out[i] = ((GLfloat*) in)[i];
}
}
@ -165,7 +167,8 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
GLboolean lighting_enabled = isLightingEnabled();
for(GLuint i = first; i < count; ++i) {
GLushort i;
for(i = first; i < count; ++i) {
pvr_vertex_t* vertex = (pvr_vertex_t*) dst;
vertex->u = vertex->v = 0.0f;
vertex->argb = 0;
@ -202,9 +205,12 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ
GLfloat contribution [] = {0.0f, 0.0f, 0.0f, 0.0f};
GLfloat to_add [] = {0.0f, 0.0f, 0.0f, 0.0f};
for(GLubyte i = 0; i < MAX_LIGHTS; ++i) {
/* FIXME!!! Transform the position to eye space */
GLubyte j;
for(j = 0; j < MAX_LIGHTS; ++j) {
if(isLightEnabled(i)) {
calculateLightingContribution(i, &vertex->x, normal, to_add);
calculateLightingContribution(j, &vertex->x, normal, to_add);
contribution[0] += to_add[0];
contribution[1] += to_add[1];

View File

@ -23,7 +23,8 @@ void initLights() {
MATERIAL.diffuse_color_index = 1.0f;
MATERIAL.specular_color_index = 1.0f;
for(GLubyte i = 0; i < MAX_LIGHTS; ++i) {
GLubyte i;
for(i = 0; i < MAX_LIGHTS; ++i) {
memcpy(LIGHTS[i].ambient, ZERO, sizeof(GLfloat) * 4);
memcpy(LIGHTS[i].diffuse, ONE, sizeof(GLfloat) * 4);
memcpy(LIGHTS[i].specular, ONE, sizeof(GLfloat) * 4);

View File

@ -189,7 +189,8 @@ void initContext() {
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
for(GLubyte i = 0; i < MAX_LIGHTS; ++i) {
GLubyte i;
for(i = 0; i < MAX_LIGHTS; ++i) {
glDisable(GL_LIGHT0 + i);
}
}

View File

@ -549,7 +549,8 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
}
/* Perform the conversion */
for(GLuint i = 0; i < bytes; i += 2) {
GLuint i;
for(i = 0; i < bytes; i += 2) {
convert(source, dest);
dest++;

View File

@ -3,6 +3,7 @@
# kos-ports/libgl Makefile
# Copyright (C) 2013, 2014 Josh Pearson
# Copyright (C) 2014 Lawrence Sebald
# Copyright (C) 2018 Luke Benstead
TARGET = libGL.a
OBJS = gl-rgb.o gl-fog.o gl-sh4-light.o gl-light.o gl-clip.o gl-clip-arrays.o

View File

@ -43,8 +43,9 @@ inline char named_array_used(NamedArray* array, unsigned int id) {
}
inline void* named_array_alloc(NamedArray* array, unsigned int* new_id) {
for(unsigned int i = 0; i < array->marker_count; ++i) {
for(unsigned int j = 0; j < 8; ++j) {
unsigned int i = 0, j = 0;
for(i = 0; i < array->marker_count; ++i) {
for(j = 0; j < 8; ++j) {
unsigned int id = (i * 8) + j + 1;
if(!named_array_used(array, id)) {
array->used_markers[i] |= (unsigned char) 1 << j;