Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8099765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:31:06+00:00 2026-06-05T22:31:06+00:00

when i quit the app, and re-enter it, i got an error: libEGL call

  • 0

when i quit the app, and re-enter it, i got an error:

libEGL   call to OpenGL ES API with no current context (logged once per thread)      (red warning text)
libc     Fatal signal 11 (SIGSEGV) at 0x5f012000 (code=2)                  (black text)

and the error file is: (don’t know where but ok if i don’t use this file)

.h:

#ifndef __CCMaskLayer__LAYER_H__
#define __CCMaskLayer__LAYER_H__

#include "cocos2d.h"
using namespace cocos2d;


class CCMaskLayer : public cocos2d::CCLayer
{
public:
    CCMaskLayer();

    ~CCMaskLayer();

    virtual bool initWithRGBASizeCenterPosition(float red, float green, float blue, float alpha, CCSize s, CCPoint p);  

    virtual void onExit();

    virtual void onEnterTransitionDidFinish();

    LAYER_NODE_FUNC(CCMaskLayer);


    static CCMaskLayer* layerWithCCColor4FSizeCenterPosition(ccColor4F c, CCSize s, CCPoint p);
    static CCMaskLayer* layerWithRGBASizeCenterPosition(float red, float green, float blue, float alpha, CCSize s, CCPoint p);

    void scratchOffCircle(CCPoint center, float radius);
    void scratchOffRect(CCRect rect);


    CC_SYNTHESIZE_RETAIN(CCRenderTexture* , masked, masked);
    CC_SYNTHESIZE(float, r, r);
    CC_SYNTHESIZE(float, g, g);
    CC_SYNTHESIZE(float, b, b);
    CC_SYNTHESIZE(float, a, a);

private:

    void setClear(float red, float green, float blue, float alpha);




};

#endif // __CCMaskLayer__LAYER_H__

.cpp:

#include "CCMaskLayer.h"

using namespace cocos2d;

CCMaskLayer::CCMaskLayer()
{
}

CCMaskLayer::~CCMaskLayer()
{

    masked->release();

}
bool CCMaskLayer::initWithRGBASizeCenterPosition(float red, float green, float blue, float alpha, CCSize s, CCPoint p) {

    if ( !CCLayer::init() )
    {
        return false;
    }

    this->setClear(red, green, blue, alpha);

    CCSize size = s;

    masked = CCRenderTexture::renderTextureWithWidthAndHeight(size.width, size.height);


    masked->getSprite()->setBlendFunc((ccBlendFunc){GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA});

    masked->setPosition(p);
    this->addChild(masked);

    this->setIsTouchEnabled(true);

    return true;
}

void CCMaskLayer::onEnterTransitionDidFinish()
{
    CCLayer::onEnterTransitionDidFinish();
}

void CCMaskLayer::onExit()
{
    CCLayer::onExit();
}



CCMaskLayer* CCMaskLayer::layerWithCCColor4FSizeCenterPosition(ccColor4F c, CCSize s, CCPoint p) {

    return CCMaskLayer::layerWithRGBASizeCenterPosition(c.r, c.g, c.b, c.a, s, p);
}

CCMaskLayer* CCMaskLayer::layerWithRGBASizeCenterPosition(float r, float g, float b, float a, CCSize s, CCPoint p) {
    CCMaskLayer* layer = new CCMaskLayer;
    layer->initWithRGBASizeCenterPosition(r, g, b, a, s, p);
    layer->autorelease();
    return layer;
}



void CCMaskLayer::setClear(float red, float green, float blue, float alpha) {
    r = red;
    g = green;
    b = blue;
    a = alpha;

}


void CCMaskLayer::scratchOffCircle(CCPoint center, float radius) {

    masked->beginWithClear(r, g, b, a);


    glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);

    glDisable(GL_TEXTURE_2D);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
    glColorMask(0.0f, 0.0f, 0.0f, 1.0f);

    glPointSize(radius * 2 * CC_CONTENT_SCALE_FACTOR());
    glEnable(GL_POINT_SMOOTH);
    glVertexPointer(2, GL_FLOAT, 0, &center);   
    glDrawArrays(GL_POINTS, 0, 1);    

    glColorMask(1.0f, 1.0f, 1.0f, 1.0f);    
    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnable(GL_TEXTURE_2D);        


    masked->end();

 } 

void CCMaskLayer::scratchOffRect(CCRect rect) {


    masked->beginWithClear(r, g, b, a);


    glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);

    glDisable(GL_TEXTURE_2D);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
    glColorMask(0.0f, 0.0f, 0.0f, 1.0f);

    CCPoint vertices[4] = {
         rect.origin,                                                                    // bottom, left
         CCPointMake(rect.origin.x, rect.origin.y + rect.size.height),                   // top, left
         CCPointMake(rect.origin.x + rect.size.width, rect.origin.y),                    // bottom, right
         CCPointMake(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height), // top, right
    };
    glVertexPointer(2, GL_FLOAT, 0, &vertices); 
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);



    glColorMask(1.0f, 1.0f, 1.0f, 1.0f);    
    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnable(GL_TEXTURE_2D);        

    masked->end();

 }

note that it works fine for iOS but crashes for android.

EDIT::

if i comment out the last line of scratch off circle/rect methods, nothing will be drawn but it does not crash. so the problem is the line: masked->end() ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:31:08+00:00Added an answer on June 5, 2026 at 10:31 pm

    this happens to be the cocos2d-x bugs. fixed on the new version v2.x. (seems cocos2d-x stops updating 1.x versions which use opengl es 1.x) thus sadly do not support iPhone and iPhone 3g. anyway updating cocos2d-x 2.x works now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you call: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@http://test.com]]; it seems to automatically quit your app
Everytime I quit the app in the simulator. The console display this error message:
I need to force quit my app when I pressed the Answer button in
I have an iPhone app running in the simulator that won't quit. I also
I am experiencing a crash in my app when I quit (via the back
the following program force quit and crashes, I don't understand why, import android.app.Activity; import
My custom error messages quit working somewhere along the way and I'm getting this
How can I quit iPhone4 app? When I use exit(0) the app goes in
Why does my app quit when user scrolls down the UITableView, past the first/last
I almost got my little console-app working, the only problem is that the variable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.