Learning Excerise Ken's Labyrinth


Pickle, why does ken's labyrinth need to read from the framebuffer at all?
 
darkblu said:
Pickle, why does ken's labyrinth need to read from the framebuffer at all?

cause the original code only draws the menu once using glDrawBuffer( GL_FRONT), so to show the menu at all i stuck a egl swap buffer in the while loop where the selector is drawn. This works the best on the pandora version where the SDL is really a single buffer, but flickers and ghosts on the wiz where it is double buffered.
I can think of 2 ways to fix this
1. Rework menu so it redraws every loop
2. Store the framebuffer once the menu is drawn as a texture and then draw the texture before the selector.
 
Last edited by a moderator:
This is some opengl code Im trying to converting (unrelated to Ken Lab) (and ignore the glList stuff)
In this example the opengl code change the color for every vertex, does the way I have to opengles work? Or am i overwriting the current color and im going to end up with what ever is the last color assigned?
Which in the second case I believe i need to use a glColorPointer.

Code:
#if defined(OPENGLES)
   GLfloat vtx[] = {
      -4.0, 2.0,
      -2.0, 0.0,
      -3.0,-4.0,
      -2.0,-3.0,
      4.0, 2.0,
      2.0, 0.0,
      3.0,-4.0,
      2.0,-3.0
   };

   //cross top left
   glColor4f(dark_g[0], dark_g[1], dark_g[2], dark_g[3]);

   if (cross)
      glColor4f(bright_g[0], bright_g[1], bright_g[2], bright_g[3]);
   else
      glColor4f(dark_g[0], dark_g[1], dark_g[2], dark_g[3]);

   //cross bottom left
      glColor4f(dark_g[0], dark_g[1], dark_g[2], dark_g[3]);
   if (cross)
      glColor4f(bright_g[0], bright_g[1], bright_g[2], bright_g[3]);

   //cross top right
   glColor4f(dark_g[0], dark_g[1], dark_g[2], dark_g[3]);
   if (cross)
      glColor4f(bright_g[0], bright_g[1], bright_g[2], bright_g[3]);
   else
      glColor4f(dark_g[0], dark_g[1], dark_g[2], dark_g[3]);

   //cross bottom right
   glColor4f(dark_g[0], dark_g[1], dark_g[2], dark_g[3]);
   if (cross)
      glColor4f(bright_g[0], bright_g[1], bright_g[2], bright_g[3]);

   glEnableClientState(GL_VERTEX_ARRAY);
   glVertexPointer(2, GL_FLOAT,0, vtx);

   glDrawArrays(GL_LINES, 0, 4);

   glDisableClientState(GL_TEXTURE_COORD_ARRAY);
   glDisableClientState(GL_VERTEX_ARRAY);
#else
    if (!cross_lh[cross])
    {
        cross_lh[cross]=glGenLists(1);
        glNewList(cross_lh[cross], GL_COMPILE_AND_EXECUTE);
        glBegin(GL_LINES);
        //cross top left
        glColor4fv(dark_g);
        glVertex2f(-4.0,2.0);
        if (cross)
            glColor4fv(bright_g);
        else
            glColor4fv(dark_g);
        glVertex2f(-2.0,0.0);
        //cross bottom left
        glColor4fv(dark_g);
        glVertex2f(-3.0,-4.0);
        if (cross)
            glColor4fv(bright_g);
        glVertex2f(-2.0,-3.0);
        //cross top right
        glColor4fv(dark_g);
        glVertex2f(4.0,2.0);
        if (cross)
            glColor4fv(bright_g);
        else
            glColor4fv(dark_g);
        glVertex2f(2.0,0.0);
        //cross bottom right
        glColor4fv(dark_g);
        glVertex2f(3.0,-4.0);
        if (cross)
            glColor3fv(bright_g);
        glVertex2f(2.0,-3.0);
        glEnd();
        glEndList();
    }
    else
        glCallList(cross_lh[cross]);
#endif
 
Pickle said:
This is some opengl code Im trying to converting (unrelated to Ken Lab) (and ignore the glList stuff)
In this example the opengl code change the color for every vertex, does the way I have to opengles work? Or am i overwriting the current color and im going to end up with what ever is the last color assigned?
Which in the second case I believe i need to use a glColorPointer.
In 'compatibility' desktp GL, glColor can be used in glBegin/glEnd (AKA 'immediate mode') sections to establish the attrbutes of individual vertices. In ES1.x glColor et al are meant to provide global values to vertex attributes that are otherwise not found in the vertex record (i.e. not specified by gl*Pointer functions). IOW, you were right to expect you'll need glColorPointer.
 
Last edited by a moderator:
darkblu said:
Pickle said:
This is some opengl code Im trying to converting (unrelated to Ken Lab) (and ignore the glList stuff)
In this example the opengl code change the color for every vertex, does the way I have to opengles work? Or am i overwriting the current color and im going to end up with what ever is the last color assigned?
Which in the second case I believe i need to use a glColorPointer.
In 'compatibility' desktp GL, glColor can be used in glBegin/glEnd (AKA 'immediate mode') sections to establish the attrbutes of individual vertices. In ES1.x glColor et al are meant to provide global values to vertex attributes that are otherwise not found in the vertex record (i.e. not specified by gl*Pointer functions). IOW, you were right to expect you'll need glColorPointer.

ok thanks for confirming, one other question with the opengl part:
Code:
        //cross bottom right
        glColor4fv(dark_g);
        glVertex2f(3.0,-4.0);
        if (cross)
            glColor3fv(bright_g);
        glVertex2f(2.0,-3.0);
does this mean if cross is false the the second vertex will get the previous color or no color at all?
 
Last edited by a moderator:
Pickle said:
Code:
        //cross bottom right
        glColor4fv(dark_g);
        glVertex2f(3.0,-4.0);
        if (cross)
            glColor3fv(bright_g);
        glVertex2f(2.0,-3.0);
does this mean if cross is false the the second vertex will get the previous color or no color at all?
the previous. basically, the precise meaning of glColor et al (except glVertex) functions is to set the 'current value' - be that for individual glVertex instances (immediate mode in compatibility desktop GL) or for canned semantics arrays, i.e. gl*Pointer functions (but not glVertexAttribPointer which are generic semantics attributes).
 
Last edited by a moderator:
Back
Top