当前位置:编程学习 > wap >>

cocos2d-x中修改窗口背景色

cocos2d-x中默认的窗口背景色是黑色的。这个貌似因为opengl的默认初始化颜色就是黑色。
 
既然是opengl渲染的,那么初始化的颜色一定是用gl函数处理的,如下
 
[cpp]  
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);  
 
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);搜索之,找到一个
 
 
[cpp] 
void CCDirector::setGLDefaultValues(void)  
{  
    // This method SHOULD be called only after openGLView_ was initialized   
    CCAssert(m_pobOpenGLView, "opengl view should not be null");  
  
    setAlphaBlending(true);  
    // XXX: Fix me, should enable/disable depth test according the depth format as cocos2d-iphone did   
    // [self setDepthTest: view_.depthFormat];   
    setDepthTest(true);  
    setProjection(m_eProjection);  
  
    // 这里设置默认颜色   
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);  
//    glClearColor(255.0f, 255.0f, 255.0f, 1.0f);   
}  
 
void CCDirector::setGLDefaultValues(void)
{
    // This method SHOULD be called only after openGLView_ was initialized
    CCAssert(m_pobOpenGLView, "opengl view should not be null");
 
    setAlphaBlending(true);
    // XXX: Fix me, should enable/disable depth test according the depth format as cocos2d-iphone did
    // [self setDepthTest: view_.depthFormat];
    setDepthTest(true);
    setProjection(m_eProjection);
 
    // 这里设置默认颜色
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
//    glClearColor(255.0f, 255.0f, 255.0f, 1.0f);
}
底下修改为白色。
 
 
 
补充:移动开发 , 其他 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,