mirror of https://github.com/axmolengine/axmol.git
Combine Studio change for openGL related operation
This commit is contained in:
parent
a5b7674b4d
commit
acd3b5cbc4
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue