Combine Studio change for openGL related operation

This commit is contained in:
XiaoFeng 2015-11-17 13:38:42 +08:00
parent a5b7674b4d
commit acd3b5cbc4
4 changed files with 29 additions and 29 deletions

View File

@ -264,7 +264,7 @@ static keyCodeItem g_keyCodeStructArray[] = {
//////////////////////////////////////////////////////////////////////////
GLViewImpl::GLViewImpl()
GLViewImpl::GLViewImpl(bool initglfw)
: _captured(false)
, _supportTouch(false)
, _isInRetinaMonitor(false)
@ -284,9 +284,11 @@ GLViewImpl::GLViewImpl()
}
GLFWEventHandler::setGLViewImpl(this);
glfwSetErrorCallback(GLFWEventHandler::onGLFWError);
glfwInit();
if (initglfw)
{
glfwSetErrorCallback(GLFWEventHandler::onGLFWError);
glfwInit();
}
}
GLViewImpl::~GLViewImpl()

View File

@ -112,7 +112,7 @@ public:
#endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
protected:
GLViewImpl();
GLViewImpl(bool initglfw = true);
virtual ~GLViewImpl();
bool initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor);

View File

@ -191,17 +191,7 @@ GLProgram::~GLProgram()
{
CCLOGINFO("%s %d deallocing GLProgram: %p", __FUNCTION__, __LINE__, this);
if (_vertShader)
{
glDeleteShader(_vertShader);
}
if (_fragShader)
{
glDeleteShader(_fragShader);
}
_vertShader = _fragShader = 0;
clearShader();
if (_program)
{
@ -230,7 +220,7 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar*
std::string replacedDefines = "";
replaceDefines(compileTimeDefines, replacedDefines);
_vertShader = _fragShader = 0;
clearShader();
if (vShaderByteArray)
{
@ -553,18 +543,6 @@ bool GLProgram::link()
parseVertexAttribs();
parseUniforms();
if (_vertShader)
{
glDeleteShader(_vertShader);
}
if (_fragShader)
{
glDeleteShader(_fragShader);
}
_vertShader = _fragShader = 0;
#if DEBUG || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
glGetProgramiv(_program, GL_LINK_STATUS, &status);
@ -935,5 +913,20 @@ void GLProgram::reset()
_hashForUniforms.clear();
}
void GLProgram::clearShader()
{
if (_vertShader)
{
glDeleteShader(_vertShader);
}
if (_fragShader)
{
glDeleteShader(_fragShader);
}
_vertShader = _fragShader = 0;
}
NS_CC_END

View File

@ -462,6 +462,9 @@ public:
/*Get the built in openGL handle of the program.*/
inline const GLuint getProgram() const { return _program; }
GLuint getVertShader() const { return _vertShader; }
GLuint getFragShader() const { return _fragShader; }
//DEPRECATED
CC_DEPRECATED_ATTRIBUTE bool initWithVertexShaderByteArray(const GLchar* vertexByteArray, const GLchar* fragByteArray)
{ return initWithByteArrays(vertexByteArray, fragByteArray); }
@ -502,6 +505,8 @@ protected:
/**Indicate whether it has a offline shader compiler or not.*/
bool _hasShaderCompiler;
void clearShader();
struct flag_struct {
unsigned int usesTime:1;
unsigned int usesNormal:1;