Help on port of Fade2BlackGL


Farox

Certified Guru
Joined
Jan 8, 2009
Messages
2,420
Age
56
Location
Italy
Website
rbnet.it
I have a problem to understand how to correctly convert this little chunk of code of the Fade2Black engine rewrite by Gregory Montoir.


This is the code :



Code:
#ifdef PANDORA

// to do

#else

glBegin(GL_POLYGON);

  while (verticesCount--) {

   glVertex3f(vertices->x, vertices->y, vertices->z);

   if (_normals) {

	Vertex4f n;

	n.x = vertices->nx;

	n.y = vertices->ny;

	n.z = vertices->nz;

	n.normalize();

	glNormal3f(n.x, n.y, n.z);

   }

   ++vertices;

  }

glEnd();

#endif

This is the only portion of code unconverted and running the game seems to work.


It run, setup the gles and suddenly exit complaining that didn't find a file ....maybe a little help is needed here also


but the rest is ok i think.


Thanks
 
If it runs but complain about file I dont know what that could be, but glBegin isnt supposed to be in GLES, heres a code that should hopefully work to replace it with. If you dont have #include "math.h" then add that also.


GLfloat nortemp[9],vertemp[9]; float ntemp;


glEnableClientState(GL_VERTEX_ARRAY);


glEnableClientState(GL_NORMAL_ARRAY);


while(verticesCount--){


vertemp[0]=vertices->x;vertemp[1]=vertices->y;vertemp[2]=vertices->z;


nortemp[0]=vertices->nx;nortemp[1]=vertices->ny;nortemp[2]=vertices->nz;vertices+=1;


vertemp[3]=vertices->x;vertemp[4]=vertices->y;vertemp[5]=vertices->z;


nortemp[3]=vertices->nx;nortemp[4]=vertices->ny;nortemp[5]=vertices->nz;vertices+=1;


vertemp[6]=vertices->x;vertemp[7]=vertices->y;vertemp[8]=vertices->z;


nortemp[6]=vertices->nx;nortemp[7]=vertices->ny;nortemp[8]=vertices->nz;vertices+=1;


ntemp=sqrt((nortemp[0]*nortemp[0])+(nortemp[1]*nortemp[1]+(nortemp[2]*nortemp[2]);


nortemp[0]/=ntemp;nortemp[1]/=ntemp;nortemp[2]/=ntemp;


ntemp=sqrt((nortemp[3]*nortemp[3])+(nortemp[4]*nortemp[4]+(nortemp[5]*nortemp[5]);


nortemp[3]/=ntemp;nortemp[4]/=ntemp;nortemp[5]/=ntemp;


ntemp=sqrt((nortemp[6]*nortemp[6])+(nortemp[7]*nortemp[7]+(nortemp[8]*nortemp[8]);


nortemp[6]/=ntemp;nortemp[7]/=ntemp;nortemp[8]/=ntemp;


glNormalPointer(GL_FLOAT, 0, nortemp);


glVertexPointer(3,GL_FLOAT,0,vertemp);


glDrawArrays(GL_TRIANGLES,0,3);


}


glDisableClientState(GL_VERTEX_ARRAY);


glDisableClientState(GL_NORMAL_ARRAY);
 
Last edited by a moderator:
Thank a lot ...just try to recompile...


I have only added a couple of ) to your code in order to compile...



Code:
ntemp=sqrt((nortemp[0]*nortemp[0])+(nortemp[1]*nortemp[1]+(nortemp[2]*nortemp[2])));

nortemp[0]/=ntemp;nortemp[1]/=ntemp;nortemp[2]/=ntemp;

ntemp=sqrt((nortemp[3]*nortemp[3])+(nortemp[4]*nortemp[4]+(nortemp[5]*nortemp[5])));

nortemp[3]/=ntemp;nortemp[4]/=ntemp;nortemp[5]/=ntemp;

ntemp=sqrt((nortemp[6]*nortemp[6])+(nortemp[7]*nortemp[7]+(nortemp[8]*nortemp[8])));

nortemp[6]/=ntemp;nortemp[7]/=ntemp;nortemp[8]/=ntemp;


it's right ?
 
oh, I forgot a ) at end of second multiplication, the () shouldnt be needed at all actually, its just my bad habit of not being confident enough to leave them out, either remove them all like sqrt(x*x+y*y+z*z) or have them like this sqrt((x*x)+(y*y)+(z*z)).
 
Ok compile fine...now remain only the error of file not found...but this need to be more investigated in loading routines


I optated for the second scheme sqrt((x*x)+(y*y)+(z*z)).



Code:
ntemp=sqrt((nortemp[0]*nortemp[0])+(nortemp[1]*nortemp[1])+(nortemp[2]*nortemp[2]));

nortemp[0]/=ntemp;nortemp[1]/=ntemp;nortemp[2]/=ntemp;

ntemp=sqrt((nortemp[3]*nortemp[3])+(nortemp[4]*nortemp[4])+(nortemp[5]*nortemp[5]));

nortemp[3]/=ntemp;nortemp[4]/=ntemp;nortemp[5]/=ntemp;

ntemp=sqrt((nortemp[6]*nortemp[6])+(nortemp[7]*nortemp[7])+(nortemp[8]*nortemp[8]));

nortemp[6]/=ntemp;nortemp[7]/=ntemp;nortemp[8]/=ntemp;

Thanks a lot for the help.
 
Last edited by a moderator:
Uhmm the problem seems hard to master...maybe out of my skills...plus i have downloaded the win version by Gregory Montoir and i have the same error

game.initLevelData 0
ERROR: Unable to open 'level1.snt'!
...maybe is a problem with my DATA ?


Of course level1.snt is present ....i have all the files under /DATA/ ......where they are searched by default according to sources (you can change the dir using --datapath=)


Some of the files are loaded/checked as if i remove the dir DATA the program return:

WARNING: Unable to find datafiles in '.'!
and the same with the win version.


If someone have the game and want to try i will give the exe.
 
Yes and the result is

WARNING: Unable to find datafiles in '.'!

More i have used a debug option (present in sources) for test the resources (with all the files in /DATA ) and here the result:

EGL Open display


EGL Get display


EGL Init


Found 2 available configs


Config 0


EGL Bind


EGL Create Context


EGL Create window surface


EGL Make Current


EGL Done


game.initLevelData 0


Resource::loadLevelData() file 'level1.spr' type 0 count 2704


Resource::loadLevelData() file 'level1.pal' type 1 count 11


Resource::loadLevelData() file 'level1.map' type 2 count 5


Resource::loadLevelData() file 'level1.ani' type 3 count 10039


Resource::loadLevelData() file 'level1.stm' type 4 count 3346


Resource::loadLevelData() file 'level1.obj' type 5 count 836


Resource::loadLevelData() file 'level1.snd' type 6 count 285


Resource::loadLevelData() file 'level1.f3d' type 7 count 1651


Resource::loadLevelData() file 'level1.p3d' type 8 count 397


Resource::loadCMD(83960) count = 976


Resource::loadMSG(124) count = 22


Resource::loadENV(3766) count = 99


_keyPathsTableCount 304


ERROR: Unable to open 'level1.snt'!
:mellow:
 
Have you checked the casing on the filenames (in Linux level1.snt != Level1.SNT)
 
Have you checked the casing on the filenames (in Linux level1.snt != Level1.SNT)

Yes i have tested with all the files lowercase and all the files uppercase...the result is allways

game.initLevelData 0
ERROR: Unable to open 'level1.snt'!
this is the function for file open



Code:
FILE *fileOpen(const char *fileName, int *fileSize, int fileType, bool errorIfNotFound) {

if (g_isDemo) {

  if (fileType == kFileType_VOICE) {

   return 0;

  } else if (fileType == kFileType_TEXT) {

   fileType = kFileType_DATA;

  }

}

FILE *fp = fileOpenIntern(fileName, fileType);

if (!fp) {

  if (errorIfNotFound) {

   error("Unable to open '%s'", fileName);

  } else {

   warning("Unable to open '%s'", fileName);

  }

  return 0;

}

fseek(fp, 0, SEEK_END);

if (fileSize) {

  *fileSize = ftell(fp);

}

fseek(fp, 0, SEEK_SET);

return fp;

}

///////////////////////////////////////////////////

static FILE *fileOpenIntern(const char *fileName, int fileType) {

char filePath[512];

fileMakeFilePath(fileName, fileType, _fileLanguage, filePath);

char *p = strrchr(filePath, '/');

if (p) {

  ++p;

} else {

  p = filePath;

}

stringToUpperCase(p);

FILE *fp = fopen(filePath, "rb");

if (!fp) {

  stringToLowerCase(p);

  fp = fopen(filePath, "rb");

}

return fp;

}
 
A good and a bad news ..


The good one is that i have found a new set of Data files ( a demo version) that work good with this reimplementation, tested also on Win version.


The bad is that my GLES changes are not properly right...so the game start but visualize all garbage and tend to crash.


My intention is to present here my changes in the hope someone with more knowledge will shed some light on it and point me in the right direction.
 
OK this is the first part of code on file render.cpp :

void Render::drawPolygonTexture(const Vertex *vertices, int verticesCount, int primitive, const uint8_t *texData, int texW, int texH, int16_t texKey) {


assert(texData && texW > 0 && texH > 0);


assert(vertices && verticesCount >= 4);


glEnable(GL_TEXTURE_2D);


Texture *t = _textureCache.getCachedTexture(texData, texW, texH, texKey);


const GLfloat tx = t->u;


const GLfloat ty = t->v;


switch (primitive) {


case 0:


case 2:


{


//


// 1:::2


// : :


// 4:::3


//


glBindTexture(GL_TEXTURE_2D, t->id);


#ifdef PANDORA


GLfloat vtx1[] = {


vertices[0].x, vertices[0].y, vertices[0].z,


vertices[1].x, vertices[1].y, vertices[1].z,


vertices[2].x, vertices[2].y, vertices[2].z,


vertices[3].x, vertices[3].y, vertices[3].z


};


GLfloat tex1[] = {


0., 0.,


tx, 0.,


tx, ty,


0., ty


};


glEnableClientState(GL_VERTEX_ARRAY);


glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glVertexPointer(3, GL_FLOAT, 0, vtx1);


glTexCoordPointer(2, GL_FLOAT, 0, tex1);


glDrawArrays(GL_TRIANGLE_FAN,0,4);


glDisableClientState(GL_VERTEX_ARRAY);


glDisableClientState(GL_TEXTURE_COORD_ARRAY);


#else


glBegin(GL_QUADS);


glTexCoord2f(0., 0.);


glVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);


glTexCoord2f(tx, 0.);


glVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);


glTexCoord2f(tx, ty);


glVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);


glTexCoord2f(0., ty);


glVertex3f(vertices[3].x, vertices[3].y, vertices[3].z);


glEnd();


#endif


break;


}


case 1:


{


//


// 1


// : :


// 3:::2


//


glBindTexture(GL_TEXTURE_2D, t->id);


#ifdef PANDORA


GLfloat vtx2[] = {


vertices[0].x, vertices[0].y, vertices[0].z,


vertices[1].x, vertices[1].y, vertices[1].z,


vertices[2].x, vertices[2].y, vertices[2].z


};


GLfloat tex2[] = {


tx / 2, 0.,


tx, ty,


0., ty


};


glEnableClientState(GL_VERTEX_ARRAY);


glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glVertexPointer(3, GL_FLOAT, 0, vtx2);


glTexCoordPointer(2, GL_FLOAT, 0, tex2);


glDrawArrays(GL_TRIANGLES,0,3);


glDisableClientState(GL_VERTEX_ARRAY);


glDisableClientState(GL_TEXTURE_COORD_ARRAY);


#else


glBegin(GL_TRIANGLES);


glTexCoord2f(tx / 2, 0.);


glVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);


glTexCoord2f(tx, ty);


glVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);


glTexCoord2f(0., ty);


glVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);


glEnd();


#endif


break;


}


case 3:


case 5:


{


//


// 4:::1


// : :


// 3:::2


//


glBindTexture(GL_TEXTURE_2D, t->id);


#ifdef PANDORA


GLfloat vtx3[] = {


vertices[0].x, vertices[0].y, vertices[0].z,


vertices[1].x, vertices[1].y, vertices[1].z,


vertices[2].x, vertices[2].y, vertices[2].z,


vertices[3].x, vertices[3].y, vertices[3].z


};


GLfloat tex3[] = {


tx, 0.,


tx, ty,


0., ty,


0., 0.


};


glEnableClientState(GL_VERTEX_ARRAY);


glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glVertexPointer(3, GL_FLOAT, 0, vtx3);


glTexCoordPointer(2, GL_FLOAT, 0, tex3);


glDrawArrays(GL_TRIANGLE_FAN,0,4);


glDisableClientState(GL_VERTEX_ARRAY);


glDisableClientState(GL_TEXTURE_COORD_ARRAY);


#else


glBegin(GL_QUADS);


glTexCoord2f(tx, 0.);


glVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);


glTexCoord2f(tx, ty);


glVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);


glTexCoord2f(0., ty);


glVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);


glTexCoord2f(0., 0.);


glVertex3f(vertices[3].x, vertices[3].y, vertices[3].z);


glEnd();


#endif


break;


}


case 4:


{


//


// 3


// : :


// 2:::1


//


glBindTexture(GL_TEXTURE_2D, t->id);


#ifdef PANDORA


GLfloat vtx4[] = {


vertices[0].x, vertices[0].y, vertices[0].z,


vertices[1].x, vertices[1].y, vertices[1].z,


vertices[2].x, vertices[2].y, vertices[2].z


};


GLfloat tex4[] = {


tx, ty,


0., ty,


tx / 2, 0.


};


glEnableClientState(GL_VERTEX_ARRAY);


glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glVertexPointer(3, GL_FLOAT, 0, vtx4);


glTexCoordPointer(2, GL_FLOAT, 0, tex4);


glDrawArrays(GL_TRIANGLES,0,3);


glDisableClientState(GL_VERTEX_ARRAY);


glDisableClientState(GL_TEXTURE_COORD_ARRAY);


#else


glBegin(GL_TRIANGLES);


glTexCoord2f(tx, ty);


glVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);


glTexCoord2f(0., ty);


glVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);


glTexCoord2f(tx / 2, 0.);


glVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);


glEnd();


#endif


break;


}


case 6:


case 8:


{


//


// 3:::4


// : :


// 2:::1


//


glBindTexture(GL_TEXTURE_2D, t->id);


#ifdef PANDORA


GLfloat vtx5[] = {


vertices[0].x, vertices[0].y, vertices[0].z,


vertices[1].x, vertices[1].y, vertices[1].z,


vertices[2].x, vertices[2].y, vertices[2].z,


vertices[3].x, vertices[3].y, vertices[3].z


};


GLfloat tex5[] = {


tx, ty,


0., ty,


0., 0.,


tx, ty


};


glEnableClientState(GL_VERTEX_ARRAY);


glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glVertexPointer(3, GL_FLOAT, 0, vtx5);


glTexCoordPointer(2, GL_FLOAT, 0, tex5);


glDrawArrays(GL_TRIANGLE_FAN,0,4);


glDisableClientState(GL_VERTEX_ARRAY);


glDisableClientState(GL_TEXTURE_COORD_ARRAY);


#else


glBegin(GL_QUADS);


glTexCoord2f(tx, ty);


glVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);


glTexCoord2f(0., ty);


glVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);


glTexCoord2f(0., 0.);


glVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);


glTexCoord2f(tx, ty);


glVertex3f(vertices[3].x, vertices[3].y, vertices[3].z);


glEnd();


#endif


break;


}


case 7:


{


//


// 2


// : :


// 1:::3


//


glBindTexture(GL_TEXTURE_2D, t->id);


#ifdef PANDORA


GLfloat vtx6[] = {


vertices[0].x, vertices[0].y, vertices[0].z,


vertices[1].x, vertices[1].y, vertices[1].z,


vertices[2].x, vertices[2].y, vertices[2].z


};


GLfloat tex6[] = {


.0, ty,


tx / 2, 0.,


tx, ty


};


glEnableClientState(GL_VERTEX_ARRAY);


glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glVertexPointer(3, GL_FLOAT, 0, vtx6);


glTexCoordPointer(2, GL_FLOAT, 0, tex6);


glDrawArrays(GL_TRIANGLES,0,3);


glDisableClientState(GL_VERTEX_ARRAY);


glDisableClientState(GL_TEXTURE_COORD_ARRAY);


#else


glBegin(GL_TRIANGLES);


glTexCoord2f(.0, ty);


glVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);


glTexCoord2f(tx / 2, 0.);


glVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);


glTexCoord2f(tx, ty);


glVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);


glEnd();


#endif


break;


}


case 9:


case 10:


{


//


// 2:::3


// : :


// 1:::4


//


glBindTexture(GL_TEXTURE_2D, t->id);


#ifdef PANDORA


GLfloat vtx7[] = {


vertices[0].x, vertices[0].y, vertices[0].z,


vertices[1].x, vertices[1].y, vertices[1].z,


vertices[2].x, vertices[2].y, vertices[2].z,


vertices[3].x, vertices[3].y, vertices[3].z


};


GLfloat tex7[] = {


0., 0.,


0., ty,


tx, ty,


tx, 0.


};


glEnableClientState(GL_VERTEX_ARRAY);


glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glVertexPointer(3, GL_FLOAT, 0, vtx7);


glTexCoordPointer(2, GL_FLOAT, 0, tex7);


glDrawArrays(GL_TRIANGLE_FAN,0,4);


glDisableClientState(GL_VERTEX_ARRAY);


glDisableClientState(GL_TEXTURE_COORD_ARRAY);


#else


glBegin(GL_QUADS);


glTexCoord2f(0., 0.);


glVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);


glTexCoord2f(0., ty);


glVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);


glTexCoord2f(tx, ty);


glVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);


glTexCoord2f(tx, 0.);


glVertex3f(vertices[3].x, vertices[3].y, vertices[3].z);


glEnd();


#endif


break;


}


default:


warning("Render::drawPolygonFlat() unhandled primitive %d", primitive);


break;


}


glDisable(GL_TEXTURE_2D);


}


and now another part

void Render::drawParticle(const Vertex *pos, int color) {


assert(color >= 0 && color < 256);


#ifdef PANDORA


GLfloat p[] {


p[0] = pos->x,


p[1] = pos->y,


p[2] = pos->z


};


glColor4f(_pixelColorMap[0], _pixelColorMap[1], _pixelColorMap[2],1.0f);


glPointSize(1.5);


glEnableClientState(GL_VERTEX_ARRAY);


glVertexPointer(3, GL_FLOAT, 0, p);


glDrawArrays(GL_POINTS,0, 2);


glDisableClientState(GL_VERTEX_ARRAY);


glPointSize(1.);


glColor4f(1., 1., 1., 1.);


#else


glColor3f(_pixelColorMap[0], _pixelColorMap[1], _pixelColorMap[2]);


glPointSize(1.5);


glBegin(GL_POINTS);


glVertex3f(pos->x, pos->y, pos->z);


glEnd();


glPointSize(1.);


glColor3f(1., 1., 1.);


#endif


}


void Render::drawSprite(int x, int y, const uint8_t *texData, int texW, int texH, int16_t texKey) {


glDisable(GL_DEPTH_TEST);


glEnable(GL_TEXTURE_2D);


Texture *t = _textureCache.getCachedTexture(texData, texW, texH, texKey);


glBindTexture(GL_TEXTURE_2D, t->id);


#ifdef PANDORA


GLfloat vtx10[] = {


x, y,


x + texW, y,


x + texW, y + texH,


x, y + texH


};


GLfloat tex10[] = {


0., 0.,


t->u, 0.,


t->u, t->v,


0., t->v


};


glEnableClientState(GL_VERTEX_ARRAY);


glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glVertexPointer(2, GL_FLOAT, 0, vtx10);


glTexCoordPointer(2, GL_FLOAT, 0, tex10);


glDrawArrays(GL_TRIANGLE_FAN,0,4);


glDisableClientState(GL_VERTEX_ARRAY);


glDisableClientState(GL_TEXTURE_COORD_ARRAY);


#else


glBegin(GL_QUADS);


glTexCoord2f(0., 0.);


glVertex2i(x, y);


glTexCoord2f(t->u, 0.);


glVertex2i(x + texW, y);


glTexCoord2f(t->u, t->v);


glVertex2i(x + texW, y + texH);


glTexCoord2f(0., t->v);


glVertex2i(x, y + texH);


glEnd();


#endif


glDisable(GL_TEXTURE_2D);


glEnable(GL_DEPTH_TEST);


}


void Render::drawRectangle(int x, int y, int w, int h, int color) {


glDisable(GL_DEPTH_TEST);


assert(color >= 0 && color < 256);


glColor4f(_pixelColorMap[0], _pixelColorMap[1], _pixelColorMap[2], _pixelColorMap[3]);


#ifdef PANDORA


GLfloat vtx11[] = {


x, y,


x + w, y,


x + w, y + h,


x, y + h


};


glEnableClientState(GL_VERTEX_ARRAY);


glVertexPointer(2, GL_FLOAT, 0, vtx11);


glDrawArrays(GL_TRIANGLE_FAN,0,4);


glDisableClientState(GL_VERTEX_ARRAY);


#else


glBegin(GL_QUADS);


glVertex2i(x, y);


glVertex2i(x + w, y);


glVertex2i(x + w, y + h);


glVertex2i(x, y + h);


glEnd();


#endif


glColor4f(1., 1., 1., 1.);


glEnable(GL_DEPTH_TEST);


}




and 3th part :







void Render::drawOverlay() {


if (!kOverlayDisabled && _overlay.tex) {


glMatrixMode(GL_PROJECTION);


glLoadIdentity();


if (_overlay.hflip) {


#ifdef PANDORA


glOrthof(0, _w, 0, _h, 0, 1);


#else


glOrtho(0, _w, 0, _h, 0, 1);


#endif


} else {


#ifdef PANDORA


glOrthof(0, _w, _h, 0, 0, 1);


#else


glOrtho(0, _w, _h, 0, 0, 1);


#endif


memset(_overlay.buf, 0, kOverlayBufSize);


}


glMatrixMode(GL_MODELVIEW);


glLoadIdentity();


glDisable(GL_DEPTH_TEST);


glEnable(GL_TEXTURE_2D);


glBindTexture(GL_TEXTURE_2D, _overlay.tex->id);


#ifdef PANDORA


const GLfloat tU = _overlay.tex->u;


const GLfloat tV = _overlay.tex->v;


assert(tU != 0. && tV != 0.);


GLfloat vtx12[] = {


0, 0,


_w, 0,


_w, _h,


0, _h


};


GLfloat tex12[] = {


0., 0.,


tU, 0.,


tU, tV,


0., tV


};


glEnableClientState(GL_VERTEX_ARRAY);


glEnableClientState(GL_TEXTURE_COORD_ARRAY);


glVertexPointer(2, GL_FLOAT, 0, vtx12);


glTexCoordPointer(2, GL_FLOAT, 0, tex12);


glDrawArrays(GL_TRIANGLE_FAN,0,4);


glDisableClientState(GL_VERTEX_ARRAY);


glDisableClientState(GL_TEXTURE_COORD_ARRAY);


#else


glBegin(GL_QUADS);


const GLfloat tU = _overlay.tex->u;


const GLfloat tV = _overlay.tex->v;


assert(tU != 0. && tV != 0.);


glTexCoord2f(0., 0.);


glVertex2i(0, 0);


glTexCoord2f(tU, 0.);


glVertex2i(_w, 0);


glTexCoord2f(tU, tV);


glVertex2i(_w, _h);


glTexCoord2f(0., tV);


glVertex2i(0, _h);


glEnd();


#endif


glEnable(GL_DEPTH_TEST);


glDisable(GL_TEXTURE_2D);


}


if (_overlay.r != 255 || _overlay.g != 255 || _overlay.b != 255) {


glColor4f(_overlay.r / 255., _overlay.g / 255., _overlay.b / 255., .8);


#ifdef PANDORA


GLfloat vtx13[] = {


0, 0,


_w, 0,


_w, _h,


0, _h


};


glEnableClientState(GL_VERTEX_ARRAY);


glVertexPointer(2, GL_FLOAT, 0, vtx13);


glDrawArrays(GL_TRIANGLE_FAN,0,4);


glDisableClientState(GL_VERTEX_ARRAY);


#else


glBegin(GL_QUADS);


glVertex2i(0, 0);


glVertex2i(_w, 0);


glVertex2i(_w, _h);


glVertex2i(0, _h);


glEnd();


#endif


glColor4f(1., 1., 1., 1.);


_overlay.r = _overlay.g = _overlay.b = 255;


}


}




i left out some minor code converted i think its ok...





Thanks a lot for your help !!
 
Sorry, just read and thought it might be a problem with a missing data file (I know nothing about GLES). Hope you get it fixed. I tried Fade to Black in the PSX emu by the way and it ran very nicely. I remember trying to set up FtB on my old DOS PC and it was a really tricky thing to get running. Again, hope you get it fixed, it's a nice game (though not as fun as flashback).
 
Don't worry :) ...hope some real programmer help me with this GLES conversion....it's my first and hope not the last. :mellow:
 
Could you post your glTexImage2D calls? If the screen is garbage, there might be something wrong with the textureformat.
 
One thing i noticed, the original vertex are integers where you treated them as float. For correctness you could switch to GL_SHORT and make the vertex array signed short or int16_t
 
here is the create_texture function


i didn't touched ...

Code:
Texture *TextureCache::createTexture(const uint8_t *data, int w, int h) {

Texture *t = new Texture;

t->bitmapW = w;

t->bitmapH = h;

t->bitmapData = (uint8_t *)malloc(w * h);

if (!t->bitmapData) {

  delete t;

  return 0;

}

memcpy(t->bitmapData, data, w * h);

w *= _scalers[_scaler].factor;

h *= _scalers[_scaler].factor;

t->texW = _npotTex ? w : roundPow2(w);

t->texH = _npotTex ? h : roundPow2(h);

t->u = w / (float)t->texW;

t->v = h / (float)t->texH;

glGenTextures(1, &t->id);

uint16_t *texData = (uint16_t *)malloc(t->texW * t->texH * sizeof(uint16_t));

if (texData) {

  convertTexture(t->bitmapData, t->bitmapW, t->bitmapH, _clut, texData, t->texW);

  glBindTexture(GL_TEXTURE_2D, t->id);

  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, kTextureMinMaxFilter);

  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, kTextureMinMaxFilter);

  if (kTextureMinMaxFilter == GL_LINEAR) {

   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

  }

  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

  glTexImage2D(GL_TEXTURE_2D, 0, _formats[_fmt].internal, t->texW, t->texH, 0, _formats[_fmt].format, _formats[_fmt].type, texData);

  free(texData);

}

if (!_texturesListHead) {

  _texturesListHead = _texturesListTail = t;

} else {

  _texturesListTail->next = t;

  _texturesListTail = t;

}

t->next = 0;

t->key = -1;

return t;

}




but i have changed this :


B) {

return ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1) | 1;

}

#ifndef PANDORA //not used on PANDORA...by farox

static uint16_t convert_BGRA_1555(int r, int g, int B) {

return 0x8000 | ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);

}

#endif

static const struct {

int internal;

int format;

int type;

uint16_t (*convertColor)(int, int, int);

} _formats[] = {

#ifndef __amigaos4__

#ifdef PANDORA

{ GL_RGB , GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, &convert_RGBA_5551 },

#else

{ GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, &convert_RGBA_5551 },

#endif

#endif

#ifndef PANDORA

{ GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, &convert_BGRA_1555 },

#endif

{ -1, -1, -1 }

};

Code:
static const int kDefaultTexBufSize = 320 * 200;

static const int kTextureMinMaxFilter = GL_LINEAR; // GL_NEAREST

static uint16_t convert_RGBA_5551(int r, int g, int




@pickle i should change where i found

for ex.



Code:
glBegin(GL_QUADS);

   const GLfloat tU = _overlay.tex->u;

   const GLfloat tV = _overlay.tex->v;

   assert(tU != 0. && tV != 0.);

   glTexCoord2f(0., 0.);

   glVertex2i(0, 0);

   glTexCoord2f(tU, 0.);

   glVertex2i(_w, 0);

   glTexCoord2f(tU, tV);

   glVertex2i(_w, _h);

   glTexCoord2f(0., tV);

   glVertex2i(0, _h);

  glEnd();



to this ?





Code:
const GLfloat tU = _overlay.tex->u;

    	const GLfloat tV = _overlay.tex->v;

    	assert(tU != 0. && tV != 0.);

    	int16_t vtx12[] = {

    	0, 0,

    	_w, 0,

    	_w, _h,

    	0, _h

    	};

    	GLfloat tex12[] = {

    	0., 0.,

    	tU, 0.,

    	tU, tV,

    	0., tV

    	};

    	glEnableClientState(GL_VERTEX_ARRAY);

    	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    	glVertexPointer(2, GL_SHORT, 0, vtx12);

    	glTexCoordPointer(2, GL_FLOAT, 0, tex12);

    	glDrawArrays(GL_TRIANGLE_FAN,0,4);

    	glDisableClientState(GL_VERTEX_ARRAY);

    	glDisableClientState(GL_TEXTURE_COORD_ARRAY);


Thanks for the help..
 
Back
Top