Help on port of Fade2BlackGL


Hmm... Could be a reason, as gles just accepts GL_RGB or GL_RGBA.


May be pickle can help here, as I can't see the problem right now...


And GlPixelStorei... I knew I had a problem with this sometime ago, but also pickle was able to help me.
 
it can be


GL_ALPHA,


GL_RGB,


GL_RGBA,


GL_LUMINANCE


GL_LUMINANCE_ALPHA.


Format and internal format though have to be the same so try:


{ GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, &convert_RGBA_5551 },


And just try without the GlPixelStorei
 
Its progressing. now the game look better...


kDYd2.png



382hu.png



the initial slide screen look ok..and also the rendering of overlays (where i change floats into int16_t ).


Also i have commented out glPixelStorei(GL_UNPACK_ALIGNMENT, 1); as with it the prog crash after the initial slide screens .


Now i think we need to look at how the polygon are formed...
 
Last edited by a moderator:
Ahhh now the game render ok :) ...but tend to crash... :wacko:


I try to look better at the code that i posted on the first message : ( i escluded the one that mjohansson give me because it crash the game after the slide screens)



Code:
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();



Now i realised that Vertex4f n; and glNormal3f(n.x, n.y, n.z); are functions implemented in the code.

So i implemented this function like this :





Code:
GLfloat vtx0[] = {

    	vertices->x, vertices->y, vertices->z

	};

	glEnableClientState(GL_VERTEX_ARRAY);

	while (verticesCount--) {

   glVertexPointer(3, GL_FLOAT, 0, vtx0);

   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);

   }

   glDrawArrays(GL_TRIANGLE_FAN,0,3);

   ++vertices;

  }

	glDisableClientState(GL_VERTEX_ARRAY);







here is the code of the functions:







Now the game look and work ok (and a little slow ) ....but tend to crash ( i need to reset the Pandora )..

Code:
struct Vertex3f {

GLfloat x, y, z;

};

struct Vertex4f {

GLfloat x, y, z, w;

void normalize() {

  const GLfloat len = sqrt(x * x + y * y + z * z);

  x /= len;

  y /= len;

  z /= len;

  w /= len;

}

};

struct Matrix4f {

GLfloat t[16];

void identity() {

  memset(t, 0, sizeof(t));

  for (int i = 0; i < 3; ++i) {

   t[i * 4 + i] = 1.;

  }

}

static void mul(const Matrix4f& a, const Matrix4f& b, Matrix4f &res) {

  for (int i = 0; i < 16; ++i) {

   const GLfloat *va = &a.t[i & 12];

   const GLfloat *vb = &b.t[i &  3];

   res.t[i] = va[0] * vb[0] + va[1] * vb[4] + va[2] * vb[8] + va[3] * vb[12];

  }

}

};
 
Do you use pickels newest eglport? This has some debugfeatures.
 
Do you use pickels newest eglport? This has some debugfeatures.
at moment no is the old one...


i made some changes and now have this on screen..


LM3Ga.png



but the sprites are no more visible...and the prog now segfault...after some movements...anyway better than before.


i have changed this:



Code:
GLfloat vtx0[] = {

    	vertices->x, vertices->y, vertices->z

	};

	glEnableClientState(GL_VERTEX_ARRAY);

	while (verticesCount--) {

	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;

  }

	glVertexPointer(3, GL_FLOAT, 0, vtx0);

	glDrawArrays(GL_TRIANGLE_FAN,0,3);

	glDisableClientState(GL_VERTEX_ARRAY);
 
Last edited by a moderator:
you cant use glNormal3f like that in GLES, if the normal change per vertex then you need to make an array to store each normal and then pass it to glNormalPointer like you would vertices/tex coords. Make sense?



Code:
int v,n;

vtx[verticesCount*3];

nrm[verticesCount*3];


glEnableClientState(GL_VERTEX_ARRAY);

if (_normals) {

glEnableClientState(GL_NORMAL_ARRAY);

}


v = 0;

n = 0;


while (verticesCount--)

{

   vtx[v++] = vertices->x; vtx[v++] = vertices->y; vtx[v++] = vertices->z;

   if (_normals) {

        Vertex4f n;

        n.x = vertices->nx;        n.y = vertices->ny;        n.z = vertices->nz;

        n.normalize();

        nrm[n++] = n.x nrm[n++] = n.y nrm[n++] = n.z;

   }

   ++vertices;

  }


  glVertexPointer(3, GL_FLOAT, 0, vtx);

   if (_normals) {

   		glNormalPointer(GL_FLOAT,0,nrm);

   }

}        

glDrawArrays(GL_TRIANGLE_FAN,0,verticesCount);        

glDisableClientState(GL_VERTEX_ARRAY);

glDisableClientState(GL_NORMAL_ARRAY);
 
Last edited by a moderator:
trying to compile but receive an error


i have adjusted to compile as is:



Code:
int v,n;

	GLfloat vtx[verticesCount*3];

	GLfloat nrm[verticesCount*3];

	glEnableClientState(GL_VERTEX_ARRAY);

	if (_normals) {

	glEnableClientState(GL_NORMAL_ARRAY);

	}

	v = 0;

	n = 0;

	while (verticesCount--)

        	{

        	vtx[v++] = vertices->x; vtx[v++] = vertices->y; vtx[v++] = vertices->z;

        	if (_normals) {

        	Vertex4f n;

        	n.x = vertices->nx;    	n.y = vertices->ny;    	n.z = vertices->nz;

        	n.normalize();

        	nrm[n++] = n.x nrm[n++] = n.y nrm[n++] = n.z;   //<<-----this is the line who give error

                	}

        	++vertices;

        	}

	glVertexPointer(3, GL_FLOAT, 0, vtx);

        	if (_normals) {

            	glNormalPointer(GL_FLOAT,0,nrm);

            	}

    	//} // commented ...

	glDrawArrays(GL_TRIANGLE_FAN,0,verticesCount);

	glDisableClientState(GL_VERTEX_ARRAY);

	glDisableClientState(GL_NORMAL_ARRAY);


but receive this...

Fadetoblack_pandora\render.cpp:207: error: no 'operator++(int)' declared for postfix '++', trying prefix operator instead


Fadetoblack_pandora\render.cpp:207: error: no match for 'operator++' in '++n'


Fadetoblack_pandora\render.cpp:207: error: expected ';' before 'nrm'
 
Last edited by a moderator:
Sorry but after adding semicolons the error remain:

Fadetoblack_pandora\render.cpp:207: error: no 'operator++(int)' declared for postfix '++', trying prefix operator instead


Fadetoblack_pandora\render.cpp:207: error: no match for 'operator++' in '++n'


Fadetoblack_pandora\render.cpp:207: error: no 'operator++(int)' declared for postfix '++', trying prefix operator instead


Fadetoblack_pandora\render.cpp:207: error: no match for 'operator++' in '++n'


Fadetoblack_pandora\render.cpp:207: error: no 'operator++(int)' declared for postfix '++', trying prefix operator instead


Fadetoblack_pandora\render.cpp:207: error: no match for 'operator++' in '++n'

the line is the same as before:

nrm[n++] = n.x; nrm[n++] = n.y; nrm[n++] = n.z;

Thanks for all the help..
 
ok Thanks now compile fine.


Just tested the polygons render ok but no sprites...and also crash after some movement.
 
Last edited by a moderator:
try running it in gdb to find the problem? Sprites would be a simple quad. All i can suggest is going over the gles code to make sure there no typos or mistakes
 
Farox i would also suggest running it on the PC, i find the debugging with gdb is more reliable as the PC kernel/PC driver do not crash, where the pandora SGX driver can lock the entire system up.


You can do this by using the normal SDL opengl window code and switching a couple of GL calls to the right names i.e glOrthof to glOrtho
 
Thanks for the advices..i never used gdb but i could try...


If i understand correctly i must change only the glOrthof functions and mantain the rest of GLES code included the EGL (init ,swapbuffer, etc) ones ?


What is puzzling me is that the sprite are somewhat visible before ( look at the message 23 at the second picture..ok it look wrong but is partially visible).
 
Last edited by a moderator:
If i understand correctly i must change only the glOrthof functions and mantain the rest of GLES code included the EGL (init ,swapbuffer, etc) ones ?
well, #define out the EGL code (and use the SDL swap function) and there is a few functions like glOrthof that don have the same name in GL and GLES. switch the GL name back and you're good to go
 
gdb is pretty simple even by command line. Build your binary with symbols and do gdb fade2black. Then in the gdb console type run, the game should run and then gdb should print some info if a error occurs. Type backtrace to determine the call list from where the app hit the error.


Running desktop GL there are couple incompatibties like glOrtho. glClearDepth glClearDepthf is another example. You will see them when you try to compile, if you havnt switched them yet.


Its easier to use the normal SDL calls for the window, in other words use SDL like the app did normally without calling any of the eglport calls.


Easiest way to debug sprite rendering is look at the code that handles it, maybe theres a typo.
 
I found the function that don't work properly.


is the DrawPolygonFlat .....

Code:
void Render::drawPolygonFlat(const Vertex *vertices, int verticesCount, int color) {

switch (color) {

case kFlatColorRed:

  glColor4f(1., 0., 0., .5);

  break;

case kFlatColorGreen:

  glColor4f(0., 1., 0., .5);

  break;

case kFlatColorYellow:

  glColor4f(1., 1., 0., .5);

  break;

case kFlatColorBlue:

  glColor4f(0., 0., 1., .5);

  break;

case kFlatColorShadow:

  glColor4f(0., 0., 0., .5);

  break;

case kFlatColorLight:

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

  break;

default:

  if (color >= 0 && color < 256) {

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

  } else {

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

  }

  break;

}

#ifdef PANDORA

	/*

	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_TRIANGLE_FAN,0,3);

	}

	glDisableClientState(GL_VERTEX_ARRAY);

	glDisableClientState(GL_NORMAL_ARRAY);

	*/


	int v,ni;

	GLfloat vtx[verticesCount*3];

	GLfloat nrm[verticesCount*3];

	glEnableClientState(GL_VERTEX_ARRAY);

	if (_normals) {

	glEnableClientState(GL_NORMAL_ARRAY);

	}

	v = 0;

	ni = 0;

	while (verticesCount--)

        	{

        	vtx[v++] = vertices->x; vtx[v++] = vertices->y; vtx[v++] = vertices->z;

        	if (_normals) {

        	Vertex4f n;

        	n.x = vertices->nx;    	n.y = vertices->ny;    	n.z = vertices->nz;

        	n.normalize();

        	nrm[ni++] = n.x; nrm[ni++] = n.y; nrm[ni++] = n.z;

                	}

        	++vertices;

        	}

	glVertexPointer(3, GL_FLOAT, 0, vtx);

	if (_normals) {

    	glNormalPointer(GL_FLOAT,0,nrm);

    	}

    	//}

	glDrawArrays(GL_TRIANGLE_FAN,0,verticesCount);

	glDisableClientState(GL_VERTEX_ARRAY);

	glDisableClientState(GL_NORMAL_ARRAY);


#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

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

}


I have found this compiling a win32 version of the game (as suggested ) and enabling time by time the various functions with the gles code converted.


I wasn't able to obtain nothing from gdb (maybe i'm not so expert on this ...it's allways give me segfaults when start...but running the game work in windows) so i "debugged" this way.


SO if i enable the non gles code above i can play the game normally if use the gles convertion (of this function ) i have the same behavior on my pandora the sprites are not visible...the only diff is that on Windows dind't crash if i move.
 
Last edited by a moderator:
the most likely cause is the array's being accessed past thier bounds, but i dont really see how it could happen.


try:


int v;


int ni;


Edit: where does _normals come from? is it always set or not set for the duration of the polygon?
 
Last edited by a moderator:
Back
Top