Finally I got time to check out the latest code and walk through them. There are a lot issues under Windows & VS, which I had commented before but seem to be ignored...
Environment: Windows, VS2010 Express, r152
1, On Windows, you must include <Windows.h> before OpenGL headers. I recommend in opengl.h :
#if defined(__APPLE__)
# ifdef GL_ES_VERSION_2_0
# include <OpenGLES/ES2/gl.h>
# else
# include <OpenGL/gl.h>
# include <Glut/glut.h>
# endif
#elif defined(_WIN32) || defined(_WIN64)
#include <Windows.h>
#include <GL/glew.h>
#include <GL/wglew.h>
#include <GLUT/glut.h> // changed according to your path of glut.h
#else
#include <GL/gl.h>
#include <GL/glut.h>
#endif
2, texture-atlas.c should removed the following code and instead include opengl.h:
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
All files that need OpenGL API should follow this rule. The same problem also occurs in shader.c.
3, texture-font.c should include platform.h, because it use function round()
4, vector.c, line 84
return self->items + index * self->item_size;
On VC, you could not add an offset to void*, instead you should:
return (char*)(self->items) + index * self->item_size;
The same problems occurred in line 210, 230, 250, 322, 344... (please search for them)
5, In vertex-buffer.c: strndup() is not available on Windows, too. Add the following code:
// strndup() was only added in OSX lion
#ifdef __APPLE__
char *
strndup( const char *s1, size_t n)
{
char *copy = calloc( n+1, sizeof(char) );
memcpy( copy, s1, n );
return copy;
};
#elif defined(_WIN32) || defined(_WIN64)
// strndup() is not available on Windows, too
char *
strndup( const char *s1, size_t n)
{
char *copy= (char*)malloc( n+1 );
memcpy( copy, s1, n );
copy[n] = 0;
return copy;
};
#endif
6, text-buffer.c, the following code is illegality in VC:
vertices[vcount+0] =
(glyph_vertex_t) { (int)x0,y0,0, s0,t0, r,g,b,a, x0-((int)x0), gamma };
instead you should:
vertices[vcount+0].x = x0;
vertices[vcount+0].y = y0;
// etc..
I recommend the use of macro:
#define SET_GLYPH_VERTEX(value,x0,y0,z0,s0,t0,r,g,b,a,sh,gm) {\
glyph_vertex_t *gv=&value;\
gv->x=x0;gv->y=y0;gv->z=z0;\
gv->u=s0;gv->v=t0;\
gv->r=r;gv->g=g;gv->b=b;gv->a=a;\
gv->shift=sh;\
gv->gamma=gm;}
SET_GLYPH_VERTEX(vertices[vcount+0], (int)x0,y0,0, s0,t0, r,g,b,a, x0-((int)x0), gamma);
7, demo-console.c, added the following:
#define wcpncpy wcsncpy
#define wcpcpy wcscpy
Because wcpncpy() and wcpcpy() is not usable in VC
8, demo-console.c, line 116, following code is not allowed in VC:
markup_t normal = {
.family = "fonts/VeraMono.ttf",
.size = 13.0,
.bold = 0,
.italic = 0,
.rise = 0.0,
.spacing = 0.0,
.gamma = 1.0,
.foreground_color = black,
.background_color = none,
.underline = 0,
.underline_color = white,
.overline = 0,
.overline_color = white,
.strikethrough = 0,
.strikethrough_color = white,
.font = 0,
};
Instead you should:
markup_t normal;
normal.family = "fonts/VeraMono.ttf",
normal.size = 13.0,
normal.bold = 0,
normal.italic = 0,
normal.rise = 0.0,
normal.spacing = 0.0,
normal.gamma = 1.0,
normal.foreground_color = black,
normal.background_color = none,
normal.underline = 0,
normal.underline_color = white,
normal.overline = 0,
normal.overline_color = white,
normal.strikethrough = 0,
normal.strikethrough_color = white,
normal.font = 0,
在 2012年5月7日星期一UTC+8下午7时12分40秒,Nicolas Rougier写道: