Learning Excerise Ken's Labyrinth


darkblu said:
the above looks a bit iffy. in what cases is texturedepth 1 and 2, respectively - does it have to do anything with the bitdepth of the image buffers? if it has any relation to those, then you may be better off doing something like:

yep, looks like 1 is 32 and 2 is 16

static char texturedepthmenu[3][30]={
"Driver default",
"32 bit",
"16 bit"
};
 
Last edited by a moderator:
ok, then, in that case:

Code:
    GLint colourformat = GL_RGBA;
    GLint datatype = GL_UNSIGNED_BYTE;

    switch(texturedepth) {
	case 1:
            datatype = GL_UNSIGNED_BYTE;
	    break;
	case 2:
            datatype = GL_UNSIGNED_SHORT_4_4_4_4;
            // or GL_UNSIGNED_SHORT_5_6_5, or GL_UNSIGNED_SHORT_5_5_5_1
            // - whatever the original code's idea of 16-bit textures is
	    break;
    }
 
GL_UNSIGNED_SHORT_5_5_5_1 and GL_UNSIGNED_SHORT_4_4_4_4 seem to work...everything is displaying the same though

I think i see the issue with the textures generating mipmaps:
Code:
     while (1) {
     if (hasalpha) TextureAvg32(bufs[level],cw,ch);
 #ifndef OPENGLES        
     glPixelStorei (GL_UNPACK_ROW_LENGTH, cw);
 #endif
     glTexImage2D (GL_TEXTURE_2D,level, format, cw, ch, 0, GL_RGBA,
               datatype, bufs[level]);
     glFinish();
 
you can drop the while cycle altogether, and rewrite the above for ES as:

Code:
#ifdef OPENGLES        
    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cw, ch, 0, GL_RGBA, // apparently format is always GL_RGBA so no need to keep it in a var, only datatype really changes
        datatype, ptr_original_top_lod_for_this_texture);
 #endif

(technically, it'd be the same for desktop GL, but i've not looked into the original code so i don't know what the motives for that manual mipmap generation were)
 
Sorry i read it wrong, theres 2 ways its making the mipmaps and the one that works the best is this glu version. I try your idea with the internal mipmapping.

Code:
void BuildMipmaps(Uint32* pix, int w, int h, int hasalpha, int maxlevel) {
    if (hasalpha) TextureAvg32(pix,w,h);
#ifndef OPENGLES        
    glPixelStorei (GL_UNPACK_ROW_LENGTH, w);
#endif
    gluBuild2DMipmaps(GL_TEXTURE_2D,hasalpha?GL_RGBA:GL_RGB,w,h,GL_RGBA,GL_UNSIGNED_BYTE,pix);
}
 
ok, let's try to close the formats question once for all.

i've never used glu with ES, so i don't know how that function above would respond, but in ES (both 1.x and 2.0) you need to have the same internalformat and format specifiers to tex(sub)image data. so in case your user data is:

  • 2-byte/pixel, no alpha: internalformat & format = GL_RGB, datatype = GL_UNSIGNED_SHORT_5_6_5
  • 2-byte/pixel, with alpha: internaformat & format = GL_RGBA, datatype = GL_UNSIGNED_SHORT_4_4_4_4, or GL_UNSIGNED_SHORT_5_5_5_1
  • 3-byte/pixel, no alpha: internalformat & format = GL_RGB, datatype = GL_UNSIGNED_BYTE
  • 3-byte/pixel, with alpha: no such core format in ES, you need to reformat that, or pray for the presence of a suitable extension
  • 4-byte/pixel, no alpha (you can't have that, so you pretend you have alpha, though you actually don't): see below
  • 4-byte/pixel, with alpha: internalformat & format = GL_RGBA, datatype = GL_UNSIGNED_BYTE

i believe the above covers all core ES cases.
 
Pickle said:
Sorry i read it wrong, theres 2 ways its making the mipmaps and the one that works the best is this glu version. I try your idea with the internal mipmapping.

Code:
void BuildMipmaps(Uint32* pix, int w, int h, int hasalpha, int maxlevel) {
    if (hasalpha) TextureAvg32(pix,w,h);
#ifndef OPENGLES        
    glPixelStorei (GL_UNPACK_ROW_LENGTH, w);
#endif
    gluBuild2DMipmaps(GL_TEXTURE_2D,hasalpha?GL_RGBA:GL_RGB,w,h,GL_RGBA,GL_UNSIGNED_BYTE,pix);
}

you can remove BuildMipmaps completelty.

just ensure that when the texture is created (thats where glTexImage2D and the glTexParameter* functions are called) you add glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

dont need to fuzz around with gluBuild2DMipMaps or other stuff. i use it wherever i need mipmaps, since glu* is basically skipped with GLES (except that GLUES lib that imitates glu behaviour)
 
Last edited by a moderator:
Problem spotted!
glTexCoordPointer(3, GL_FLOAT, 0, tex); should beglTexCoordPointer(2, GL_FLOAT, 0, tex);

all in game is render right now :)

now all thats needs fixing is the menu and the sound.
 
better yet, post your mesh- building and drawing code.

edit: good to hear you spotted it.
 
This is a really nice thread, well done you guys. Great to see you all working it out ..

Pickle, are you interested in doing a bit of a writeup about your experience with this port? I think it would be very beneficial to see what you encountered and how you fixed it as you went along - maybe with more details than this thread can provide? Your trailblazing may well lead the way to a lot more GL -> GLES ports in the future, and that can only be a good thing ..
 
torpor said:
Pickle, are you interested in doing a bit of a writeup about your experience with this port? I think it would be very beneficial to see what you encountered and how you fixed it as you went along - maybe with more details than this thread can provide? Your trailblazing may well lead the way to a lot more GL -> GLES ports in the future, and that can only be a good thing ..
Some documentation like this would indeed be very useful. I know roughly what I'm doing with basic GL stuff, but my eyes glaze over when I see some of this GLES code. Some kind of GL -> GLES cookbook would be ideal, but even a decent tutorial or "case study" like this project would go a long way.
 
Last edited by a moderator:
The wiki could be updated with code examples. The GL_QUADS example is wrong for opengles 1.1.

The 2 critical parts getting this to work were the conversion of GL_QUADS and creating subtextures. There were other minor changes I could handle on my own. Getting SDL to work with EGL was also very useful, that can be found in the avp thread.
Going through this i think i maybe start some other ports of opengl code, like d1x/d2x.

I did some playing around with this on the pandora last night, and its pretty fast without the music turned on. id also like to see if I cant get it to run on the wiz this weekend.
 
So, this is about using HW acceleration or just to learn the engine? (Sorry, my english is not that great and especialy not when it comes to Tech-talk ^^")
I remember this game, it is a simple and early Work from Ken Silverman, right? The great guy who did the legendary BUILD engine for Duke 3D? Still a "simple" raycasting "2.5D" engine but with alot of nice ideas. :) I spent Years with the D3D BUILD Editor and playing with some MAP ideas. The best is that even the GP2X can handle Duke3D full speed and my custom maps were also compatible. ^^
 
fusion_power said:
So, this is about using HW acceleration or just to learn the engine? (Sorry, my english is not that great and especialy not when it comes to Tech-talk ^^")
I remember this game, it is a simple and early Work from Ken Silverman, right? The great guy who did the legendary BUILD engine for Duke 3D? Still a "simple" raycasting "2.5D" engine but with alot of nice ideas. :) I spent Years with the D3D BUILD Editor and playing with some MAP ideas.

it was to get a an handle on opengl and opengl-es, which with some help has worked out like I hoped it would. Ive actually never played this game until now(ive heard of it before though)

This game was a raycast style game (wolf3d clone) by Ken Silverman, because of the methods used to draw the original port went ahead and just converted all the soft VGA code into opengl code. Its a game that if it had a software render could have run on the gp2x. But now with the ability to use opengles on the wiz and pandora this game is possible.
 
Last edited by a moderator:
Im hitting a block on how to handle the glDrawBuffer, it just doesnt work well with EGL being double buffered. If I do nothing the menu's dont show since there isnt a egl swap buffers.
If i add the swap buffers it flashes cause the 2 buffers are different and the second never gets updated.

Is there anyway to copy of side of the surface buffer to the other side, i dont seem to see anything that would work.
 
Back
Top