OpenGL issues - use of undeclared identifiers

Hi,

I am trying to convert the example here from ObjectiveC to C*+ but I am running into some problems, the following code gives me issues:
Link: http://www.raywenderlich.com/3857/how-to-create-dynamic-textures-with-ccrendertexture
I added a* sign before each line that tell’s me I am missing a reference:

glDisable(GL_TEXTURE_2D);

  • glDisableClientState(GL_TEXTURE_COORD_ARRAY);

float gradientAlpha = 0.7;
CCPoint vertices[4];
ccColor4F colors[4];
int nVertices = 0;

vertices[nVertices] = CCPointMake(0, 0);
colors[nVertices**] = ;
vertices[nVertices] = CCPointMake;
colors[nVertices**] = (ccColor4F){0, 0, 0, 0};
vertices[nVertices] = CCPointMake(0, textureSize);
colors[nVertices**] = ;
vertices[nVertices] = CCPointMake;
colors[nVertices**] = (ccColor4F){0, 0, 0, gradientAlpha};

  • glVertexPointer(2, GL_FLOAT, 0, vertices);
  • glColorPointer(4, GL_FLOAT, 0, colors);

glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)nVertices);

  • glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnable(GL_TEXTURE_2D);

I tried #include “CCGL.h” but that didn’t solve it and I got the latest from GitHub as well which also didn’t solve it.

The API calls that I am using here are from OpenGLES 1.0 and I assume my code automatically uses 2.0, I think I rather make it work in 2.0 then figure out how to use 1.0

I know this must be easy to fix, but so far I haven’t been able to extract the answer from Google yet.

-Mark

Ok,

I am silly, the comments area in the last comment it shows the solution.

Sorry

Hi there!

Did you converted the tutorial with success?

I’m trying to convert it too, but i’m having problems rendering the gradients and stripes.

I will write here my code for “spriteWithColor” method…

CCSprite* HelloWorld::sprite(cocos2d::ccColor4F bgColor, float textureSize)
{
    CCRenderTexture *rt = CCRenderTexture::create(textureSize, textureSize);

    rt->beginWithClear(bgColor.r, bgColor.g, bgColor.b, bgColor.a);

    //gradient
    float gradientAlpha = 0.7;
    CCPoint vertices[4];
    ccColor4F colors[4];
    int nVertices = 0;

    vertices[nVertices] = CCPointMake(0, 0);
    colors[nVertices++] = (ccColor4F){0, 0, 0, 0 };
    vertices[nVertices] = CCPointMake(textureSize, 0);
    colors[nVertices++] = (ccColor4F){0, 0, 0, 0};
    vertices[nVertices] = CCPointMake(0, textureSize);
    colors[nVertices++] = (ccColor4F){0, 0, 0, gradientAlpha};
    vertices[nVertices] = CCPointMake(textureSize, textureSize);
    colors[nVertices++] = (ccColor4F){0, 0, 0, gradientAlpha};

    CC_NODE_DRAW_SETUP();
    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color );
    glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
    glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, colors);
    glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)nVertices);

    //noise
    CCSprite *noise = CCSprite::create("Noise.png");
    noise->setBlendFunc((ccBlendFunc){ GL_DST_COLOR, GL_ZERO });
    noise->setPosition(ccp(textureSize/2, textureSize/2));
    noise->visit();

    rt->end();

    return CCSprite::createWithTexture(rt->getSprite()->getTexture());
}

Can you or anyone help me with this?

Thank you

Hey, did you manage to do that? I have the same problem. Even now, after 4 years I can’t find any solution