added changes for proper c++ compile

This commit is contained in:
Pawel Kolodziejski 2005-01-12 15:26:45 +00:00
parent 23cb09f88d
commit 08d587724a
26 changed files with 77 additions and 84 deletions

View file

@ -3,3 +3,6 @@ The changes made from the original version of TinyGL 0.4 are:
* Changed files extensions from *.c to *.cpp to compile as C++.
* Included only files needed by Residual.
* Changed includes paths in source files.
* Added needed type cast after malloc funcs and one fix for proper
compile.

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
#include <stdio.h>
/* glVertex */

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
#include <assert.h>
#include <stdio.h>
@ -130,7 +130,7 @@ glopVertexPointer(GLContext *c, GLParam *p)
{
c->vertex_array_size = p[1].i;
c->vertex_array_stride = p[2].i;
c->vertex_array = p[3].p;
c->vertex_array = (float *)p[3].p;
}
void
@ -151,7 +151,7 @@ glopColorPointer(GLContext *c, GLParam *p)
{
c->color_array_size = p[1].i;
c->color_array_stride = p[2].i;
c->color_array = p[3].p;
c->color_array = (float *)p[3].p;
}
void
@ -171,7 +171,7 @@ void
glopNormalPointer(GLContext *c, GLParam *p)
{
c->normal_array_stride = p[1].i;
c->normal_array = p[2].p;
c->normal_array = (float *)p[2].p;
}
void
@ -190,7 +190,7 @@ glopTexCoordPointer(GLContext *c, GLParam *p)
{
c->texcoord_array_size = p[1].i;
c->texcoord_array_stride = p[2].i;
c->texcoord_array = p[3].p;
c->texcoord_array = (float *)p[3].p;
}
void

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
void glopClearColor(GLContext *c,GLParam *p)

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
/* fill triangle profile */
/* #define PROFILE */
@ -404,7 +404,7 @@ void gl_draw_triangle_fill(GLContext *c,
#ifdef PROFILE
count_triangles_textured++;
#endif
ZB_setTexture(c->zb,c->current_texture->images[0].pixmap);
ZB_setTexture(c->zb,(PIXEL *)c->current_texture->images[0].pixmap);
ZB_fillTriangleMappingPerspective(c->zb,&p0->zp,&p1->zp,&p2->zp);
} else if (c->current_shade_model == GL_SMOOTH) {
ZB_fillTriangleSmooth(c->zb,&p0->zp,&p1->zp,&p2->zp);

View file

@ -1,5 +1,5 @@
#include <stdarg.h>
#include "zgl.h"
#include "tinygl/zgl.h"
void gl_fatal_error(char *format, ...)
{

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
void glGetIntegerv(int pname,int *params)
{

View file

@ -6,10 +6,6 @@
#define GL_VERSION_1_1 1
#ifdef __cplusplus
extern "C" {
#endif
enum {
/* Boolean values */
GL_FALSE = 0,
@ -831,8 +827,4 @@ void glDebug(int mode);
void glInit(void *zbuffer);
void glClose(void);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
/*
* image conversion

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
GLContext *gl_ctx;
@ -6,8 +6,8 @@ GLContext *gl_ctx;
void initSharedState(GLContext *c)
{
GLSharedState *s=&c->shared_state;
s->lists=gl_zalloc(sizeof(GLList *) * MAX_DISPLAY_LISTS);
s->texture_hash_table=
s->lists=(GLList **)gl_zalloc(sizeof(GLList *) * MAX_DISPLAY_LISTS);
s->texture_hash_table=(GLTexture **)
gl_zalloc(sizeof(GLTexture *) * TEXTURE_HASH_TABLE_SIZE);
alloc_texture(c,0);
@ -34,14 +34,14 @@ void glInit(void *zbuffer1)
GLViewport *v;
int i;
c=gl_zalloc(sizeof(GLContext));
c=(GLContext *)gl_zalloc(sizeof(GLContext));
gl_ctx=c;
c->zb=zbuffer;
/* allocate GLVertex array */
c->vertex_max = POLYGON_MAX_VERTEX;
c->vertex = gl_malloc(POLYGON_MAX_VERTEX*sizeof(GLVertex));
c->vertex = (GLVertex *)gl_malloc(POLYGON_MAX_VERTEX*sizeof(GLVertex));
/* viewport */
v=&c->viewport;
@ -150,7 +150,7 @@ void glInit(void *zbuffer1)
c->matrix_stack_depth_max[2]=MAX_TEXTURE_STACK_DEPTH;
for(i=0;i<3;i++) {
c->matrix_stack[i]=gl_zalloc(c->matrix_stack_depth_max[i] * sizeof(M4));
c->matrix_stack[i]=(M4*)gl_zalloc(c->matrix_stack_depth_max[i] * sizeof(M4));
c->matrix_stack_ptr[i]=c->matrix_stack[i];
}

View file

@ -1,5 +1,5 @@
#include "zgl.h"
#include "msghandling.h"
#include "tinygl/zgl.h"
#include "tinygl/msghandling.h"
void glopMaterial(GLContext *c,GLParam *p)
{
@ -113,7 +113,7 @@ void glopLight(GLContext *c,GLParam *p)
float a=v.v[0];
assert(a == 180 || (a>=0 && a<=90));
l->spot_cutoff=a;
if (a != 180) l->cos_spot_cutoff=cos(a * M_PI / 180.0);
if (a != 180) l->cos_spot_cutoff=cos(a * PI / 180.0);
}
break;
case GL_CONSTANT_ATTENUATION:

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
static char *op_table_str[]=
{
@ -57,8 +57,8 @@ static GLList *alloc_list(GLContext *c,int list)
GLList *l;
GLParamBuffer *ob;
l=gl_zalloc(sizeof(GLList));
ob=gl_zalloc(sizeof(GLParamBuffer));
l=(GLList *)gl_zalloc(sizeof(GLList));
ob=(GLParamBuffer *)gl_zalloc(sizeof(GLParamBuffer));
ob->next=NULL;
l->first_op_buffer=ob;
@ -113,7 +113,7 @@ void gl_compile_op(GLContext *c,GLParam *p)
/* we should be able to add a NextBuffer opcode */
if ((index + op_size) > (OP_BUFFER_MAX_SIZE-2)) {
ob1=gl_zalloc(sizeof(GLParamBuffer));
ob1=(GLParamBuffer *)gl_zalloc(sizeof(GLParamBuffer));
ob1->next=NULL;
ob->next=ob1;

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
void gl_print_matrix( const float *m)
{
@ -116,7 +116,7 @@ void glopRotate(GLContext *c,GLParam *p)
float angle;
int dir_code;
angle = p[1].f * M_PI / 180.0;
angle = p[1].f * PI / 180.0;
u[0]=p[2].f;
u[1]=p[3].f;
u[2]=p[4].f;

View file

@ -1,7 +1,7 @@
/*
* Memory allocator for TinyGL
*/
#include "zgl.h"
#include "tinygl/zgl.h"
/* modify these functions so that they suit your needs */

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
#include "msghandling.h"
void glopViewport(GLContext *c,GLParam *p)

View file

@ -1,4 +1,4 @@
#include "zgl.h"
#include "tinygl/zgl.h"
int glRenderMode(int mode)
{

View file

@ -1,5 +1,5 @@
#include "zgl.h"
#include "msghandling.h"
#include "tinygl/zgl.h"
#include "tinygl/msghandling.h"
#include <math.h>
#include <stdlib.h>
@ -33,7 +33,7 @@ specbuf_get_buffer(GLContext *c, const int shininess_i,
}
if (oldest == NULL || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) {
/* create new buffer */
GLSpecBuf *buf = gl_malloc(sizeof(GLSpecBuf));
GLSpecBuf *buf = (GLSpecBuf *)gl_malloc(sizeof(GLSpecBuf));
if (!buf) gl_fatal_error("could not allocate specular buffer");
c->specbuf_num_buffers++;
buf->next = c->specbuf_first;

View file

@ -2,7 +2,7 @@
* Texture Manager
*/
#include "zgl.h"
#include "tinygl/zgl.h"
static GLTexture *find_texture(GLContext *c,int h)
{
@ -44,7 +44,7 @@ GLTexture *alloc_texture(GLContext *c,int h)
{
GLTexture *t,**ht;
t=gl_zalloc(sizeof(GLTexture));
t=(GLTexture *)gl_zalloc(sizeof(GLTexture));
ht=&c->shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE];
@ -144,14 +144,14 @@ void glopTexImage2D(GLContext *c,GLParam *p)
do_free=0;
if (width != 256 || height != 256) {
pixels1 = gl_malloc(256 * 256 * 3);
pixels1 = (unsigned char *)gl_malloc(256 * 256 * 3);
/* no interpolation is done here to respect the original image aliasing ! */
gl_resizeImageNoInterpolate(pixels1,256,256,pixels,width,height);
gl_resizeImageNoInterpolate(pixels1,256,256,(unsigned char *)pixels,width,height);
do_free=1;
width=256;
height=256;
} else {
pixels1=pixels;
pixels1=(unsigned char *)pixels;
}
im=&c->current_texture->images[level];
@ -171,7 +171,7 @@ void glopTexImage2D(GLContext *c,GLParam *p)
#elif TGL_FEATURE_RENDER_BITS == 16
im->pixmap=gl_malloc(width*height*2);
if(im->pixmap) {
gl_convertRGB_to_5R6G5B(im->pixmap,pixels1,width,height);
gl_convertRGB_to_5R6G5B((unsigned short *)im->pixmap,pixels1,width,height);
}
#else
#error TODO

View file

@ -1,4 +1,5 @@
#include "zgl.h"
#include "tinygl/zgl.h"
#include <string.h>
void glopNormal(GLContext * c, GLParam * p)
{
@ -219,7 +220,7 @@ void glopVertex(GLContext * c, GLParam * p)
if (n >= c->vertex_max) {
GLVertex *newarray;
c->vertex_max <<= 1; /* just double size */
newarray = gl_malloc(sizeof(GLVertex) * c->vertex_max);
newarray = (GLVertex *)gl_malloc(sizeof(GLVertex) * c->vertex_max);
if (!newarray) {
gl_fatal_error("unable to allocate GLVertex array.\n");
}

View file

@ -7,7 +7,7 @@
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "zbuffer.h"
#include "tinygl/zbuffer.h"
ZBuffer *ZB_open(int xsize, int ysize, int mode,
int nb_colors,
@ -18,7 +18,7 @@ ZBuffer *ZB_open(int xsize, int ysize, int mode,
ZBuffer *zb;
int size;
zb = gl_malloc(sizeof(ZBuffer));
zb = (ZBuffer *)gl_malloc(sizeof(ZBuffer));
if (zb == NULL)
return NULL;
@ -48,12 +48,12 @@ ZBuffer *ZB_open(int xsize, int ysize, int mode,
size = zb->xsize * zb->ysize * sizeof(unsigned short);
zb->zbuf = gl_malloc(size);
zb->zbuf = (unsigned short *)gl_malloc(size);
if (zb->zbuf == NULL)
goto error;
if (frame_buffer == NULL) {
zb->pbuf = gl_malloc(zb->ysize * zb->linesize);
zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize);
if (zb->pbuf == NULL) {
gl_free(zb->zbuf);
goto error;
@ -61,7 +61,7 @@ ZBuffer *ZB_open(int xsize, int ysize, int mode,
zb->frame_buffer_allocated = 1;
} else {
zb->frame_buffer_allocated = 0;
zb->pbuf = frame_buffer;
zb->pbuf = (PIXEL *)frame_buffer;
}
zb->current_texture = NULL;
@ -100,16 +100,16 @@ void ZB_resize(ZBuffer * zb, void *frame_buffer, int xsize, int ysize)
size = zb->xsize * zb->ysize * sizeof(unsigned short);
gl_free(zb->zbuf);
zb->zbuf = gl_malloc(size);
zb->zbuf = (unsigned short *)gl_malloc(size);
if (zb->frame_buffer_allocated)
gl_free(zb->pbuf);
if (frame_buffer == NULL) {
zb->pbuf = gl_malloc(zb->ysize * zb->linesize);
zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize);
zb->frame_buffer_allocated = 1;
} else {
zb->pbuf = frame_buffer;
zb->pbuf = (PIXEL *)frame_buffer;
zb->frame_buffer_allocated = 0;
}
}
@ -123,7 +123,7 @@ static void ZB_copyBuffer(ZBuffer * zb,
int y, n;
q = zb->pbuf;
p1 = buf;
p1 =(unsigned char *) buf;
n = zb->xsize * PSZB;
for (y = 0; y < zb->ysize; y++) {
memcpy(p1, q, n);
@ -247,7 +247,7 @@ static void ZB_copyFrameBufferRGB24(ZBuffer * zb,
int y, n;
q = zb->pbuf;
p1 = (unsigned int *) buf;
p1 = (unsigned int *)buf;
linesize = linesize * 3;
for (y = 0; y < zb->ysize; y++) {
@ -264,8 +264,9 @@ static void ZB_copyFrameBufferRGB24(ZBuffer * zb,
q += 4;
p += 3;
} while (--n > 0);
(char *) p1 += linesize;
char *t = (char *)p1;
t += linesize;
p1 = (unsigned int *)t;
}
}
@ -277,7 +278,7 @@ void ZB_copyFrameBuffer(ZBuffer * zb, void *buf,
switch (zb->mode) {
#ifdef TGL_FEATURE_8_BITS
case ZB_MODE_INDEX:
ZB_ditherFrameBuffer(zb, buf, linesize >> 1);
ZB_ditherFrameBuffer(zb, (unsigned char *)buf, linesize >> 1);
break;
#endif
#ifdef TGL_FEATURE_16_BITS
@ -416,7 +417,7 @@ void memset_s(void *adr, int val, int count)
unsigned int *p;
unsigned short *q;
p = adr;
p = (unsigned int *)adr;
v = val | (val << 16);
n = count >> 3;
@ -439,7 +440,7 @@ void memset_l(void *adr, int val, int count)
int i, n, v;
unsigned int *p;
p = adr;
p = (unsigned int *)adr;
v = val;
n = count >> 2;
for (i = 0; i < n; i++) {

View file

@ -5,7 +5,7 @@
* Z buffer
*/
#include "zfeatures.h"
#include "tinygl/zfeatures.h"
#define ZB_Z_BITS 16

View file

@ -5,7 +5,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "zbuffer.h"
#include "tinygl/zbuffer.h"
#include <assert.h>
#if defined(TGL_FEATURE_8_BITS)
@ -45,7 +45,7 @@ void ZB_initDither(ZBuffer *zb,int nb_colors,
for(i=0;i<nb_colors;i++) color_table[i]=0;
zb->nb_colors=nb_colors;
zb->ctable=gl_malloc(nb_colors * sizeof(int));
zb->ctable=(int *)gl_malloc(nb_colors * sizeof(int));
for (r = 0; r < _R; r++) {
for (g = 0; g < _G; g++) {
@ -61,7 +61,7 @@ void ZB_initDither(ZBuffer *zb,int nb_colors,
}
}
zb->dctable=gl_malloc( DITHER_TABLE_SIZE );
zb->dctable=(unsigned char *)gl_malloc( DITHER_TABLE_SIZE );
for(i=0;i<DITHER_TABLE_SIZE;i++) {
r=(i >> 12) & 0x7;

View file

@ -5,10 +5,10 @@
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <GL/gl.h>
#include "zbuffer.h"
#include "zmath.h"
#include "zfeatures.h"
#include "tinygl/gl.h"
#include "tinygl/zbuffer.h"
#include "tinygl/zmath.h"
#include "tinygl/zfeatures.h"
#define DEBUG
/* #define NDEBUG */
@ -324,27 +324,23 @@ GLContext *gl_get_context(void);
void gl_fatal_error(char *format, ...);
#ifndef PI
#define PI 3.14159265358979323846
#endif
/* specular buffer "api" */
GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i,
const float shininess);
#ifdef __BEOS__
void dprintf(const char *, ...);
#else /* !BEOS */
#ifdef DEBUG
#define dprintf(format, args...) \
fprintf(stderr,"In '%s': " format "\n",__FUNCTION__, ##args);
#define dprintf fprintf
#else
#define dprintf(format, args...)
#define dprintf
#endif
#endif /* !BEOS */
/* glopXXX functions */

View file

@ -1,5 +1,5 @@
#include <stdlib.h>
#include "zbuffer.h"
#include "tinygl/zbuffer.h"
#define ZCMP(z,zpix) ((z) >= (zpix))

View file

@ -4,7 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "zmath.h"
#include "tinygl/zmath.h"
/* ******* Gestion des matrices 4x4 ****** */

View file

@ -1,5 +1,5 @@
#include <stdlib.h>
#include "zbuffer.h"
#include "tinygl/zbuffer.h"
#define ZCMP(z,zpix) ((z) >= (zpix))