views:

34

answers:

2

Hello everyone,

Here's my problem. I'm drawing a box using a GL_TRIANGLE_STRIP. There is no texture involved, no material and no shaders. I'm just rendering colored triangle.

You can see what it looks like here : Fail box

But as you can see, I've some clear color fading problem. There is no lighting activated either.

Here the code I use to init and render the box.

//here init code
for(list<Particle*>::iterator p = this->shapes[this->activeShape].particles.begin();
                p != this->shapes[this->activeShape].particles.end(); p++)
            {
                float yValue = 20.0f;

                this->vertexArray[this->activeShape][current].Position.x = (*p)->x0.x;
                this->vertexArray[this->activeShape][current].Position.y = -yValue;
                this->vertexArray[this->activeShape][current].Position.z = (*p)->x0.y;


                this->vertexArray[this->activeShape][current + listSize].Position.x = (*p)->x0.x;
                this->vertexArray[this->activeShape][current + listSize].Position.y = yValue;
                this->vertexArray[this->activeShape][current + listSize].Position.z = (*p)->x0.y;

                current++;
            }


        // render code
                glFrontFace(GL_CW);
                glEnable(GL_BLEND);

                glVertexPointer(3, GL_FLOAT, sizeof(LsmVertexColor), &this->vertexArray[this->activeShape][0].Position);
                glEnableClientState(GL_VERTEX_ARRAY);

                glColor4f(SCULPTY_R, SCULPTY_G, SCULPTY_B, SCULPTY_A);

                glDrawElements(GL_TRIANGLE_STRIP, 20, GL_UNSIGNED_SHORT, &this->indexArray[this->activeShape][0]);
                glDrawElements(GL_TRIANGLE_STRIP, 20, GL_UNSIGNED_SHORT, &this->indexArray[this->activeShape][22]);
                glDrawElements(GL_TRIANGLE_STRIP, 10, GL_UNSIGNED_SHORT, &this->indexArray[this->activeShape][44]);
                glDrawElements(GL_TRIANGLE_STRIP, 10, GL_UNSIGNED_SHORT, &this->indexArray[this->activeShape][54]);

I'm using OpenGL ES 1.1 (I know I'm not up-to-date) and the program is running on iPhone/iPad.

A: 

Try adding:

glDisable(GL_LIGHTING);

to make sure there is really no lighting even if by default.

PierreBdR
I did that, and here the list of all the things I disable before rendering glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glDisable( GL_COLOR_MATERIAL ); glDisable(GL_BLEND); glShadeModel( GL_FLAT ); glDisable( GL_FOG );Basically everthing that OpengGL can do :D
Pencrace
BTW, it's still not working in case it wasn't clear
Pencrace
A: 

Hello again,

I forgot to mention that I'm using the engine Sio2 Engine. I went hardstyle and hooked the entire openGL init and redid it myself. For some reason, one of the glEnable(GL_TEXTURE_2D) call was making the weird effect appear.

I unfortunately can't explain why, but if you're using Sio2 Engine and end up with some strange effect of color fading... then check if it is solved by commenting one of the two calls to enable GL_TEXTURE_2D in the engine code.

I welcome any explanation, I don't have time to go deeper and find it myself.

Pencrace
Small precision, no need to comment anything, I checked I bit more (because it is never good to remove a bit of something which is working).So if you render something without using the engine pipeline, don't render it after sio2ResourceRender() is called.
Pencrace