update code,because of line space
Signed-off-by: tyBrave <tianyong13@huawei.com>
This commit is contained in:
parent
d18694a96e
commit
a241953878
|
@ -49,9 +49,7 @@ static napi_value Add(napi_env env, napi_callback_info info)
|
|||
|
||||
napi_value sum;
|
||||
napi_create_double(env, value0 + value1, &sum);
|
||||
|
||||
return sum;
|
||||
|
||||
}
|
||||
|
||||
static napi_value Init(napi_env env, napi_value exports)
|
||||
|
|
|
@ -404,7 +404,6 @@ void EGLRender::Init()
|
|||
if (!m_IsGLContextReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
glGenTextures(1, &m_ImageTextureId); // 生成纹理名称
|
||||
glBindTexture(GL_TEXTURE_2D, m_ImageTextureId); // 允许建立一个绑定到目标纹理的有名称的纹理
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
|
@ -420,15 +419,12 @@ void EGLRender::Init()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, GL_NONE);
|
||||
|
||||
m_ProgramObj = GLUtils::CreateProgram(vShaderStr, fShaderStr0, m_VertexShader,
|
||||
m_FragmentShader);
|
||||
if (!m_ProgramObj) {
|
||||
GLUtils::CheckGLError("Create Program");
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate VBO Ids and load the VBOs width data
|
||||
glGenBuffers(DEFAULT_THREE, m_VboIds);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_VboIds[DEFAULT_ZERO]);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vVertices), vVertices, GL_STATIC_DRAW);
|
||||
|
@ -438,11 +434,7 @@ void EGLRender::Init()
|
|||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_VboIds[DEFAULT_TWO]);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
|
||||
|
||||
// Generate VAO Ids
|
||||
glGenVertexArrays(DEFAULT_ONE, m_VaoIds);
|
||||
|
||||
// FBO off screen rendering VAO
|
||||
glBindVertexArray(m_VaoIds[DEFAULT_ZERO]);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_VboIds[DEFAULT_ZERO]);
|
||||
|
@ -470,8 +462,7 @@ void EGLRender::Init()
|
|||
|
||||
int EGLRender::CreateGlEnv()
|
||||
{
|
||||
const EGLint confAttr[] =
|
||||
{
|
||||
const EGLint confAttr[] = {
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
|
||||
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
||||
EGL_RED_SIZE, 8,
|
||||
|
@ -482,15 +473,11 @@ int EGLRender::CreateGlEnv()
|
|||
EGL_STENCIL_SIZE, 8,
|
||||
EGL_NONE
|
||||
};
|
||||
// EGL context attributes
|
||||
const EGLint ctxAttr[] =
|
||||
{
|
||||
const EGLint ctxAttr[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
const EGLint surfaceAttr[] =
|
||||
{
|
||||
const EGLint surfaceAttr[] = {
|
||||
EGL_WIDTH, 1,
|
||||
EGL_HEIGHT, 1,
|
||||
EGL_NONE
|
||||
|
@ -504,64 +491,37 @@ int EGLRender::CreateGlEnv()
|
|||
resultCode = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
// 初始化 egl 方法
|
||||
if (!eglInitialize(m_eglDisplay, &eglMajVers, &eglMinVers)) {
|
||||
resultCode = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
// 获取 EGLConfig 对象,确定渲染表面的配置信息
|
||||
if (!eglChooseConfig(m_eglDisplay, confAttr, &m_eglConf, 1, &numConfigs)) {
|
||||
resultCode = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
// 创建渲染表面 EGLSurface 使用 eglCreateBufferSurface 创建屏幕外渲染区域
|
||||
m_eglSurface = eglCreatePbufferSurface(m_eglDisplay, m_eglConf, surfaceAttr);
|
||||
if (m_eglSurface == EGL_NO_SURFACE) {
|
||||
switch(eglGetError()) {
|
||||
case EGL_BAD_ALLOC:
|
||||
LOGI("gl-->::CreateGlesEnv Not enough resources available");
|
||||
break;
|
||||
case EGL_BAD_CONFIG:
|
||||
LOGI("gl-->::CreateGlesEnv provided EGLConfig is invalid");
|
||||
break;
|
||||
case EGL_BAD_PARAMETER:
|
||||
LOGI("gl-->::CreateGlesEnv provided EGL_WIDTH and EGL_HEIGHT is invalid");
|
||||
break;
|
||||
case EGL_BAD_MATCH:
|
||||
LOGI("gl-->::CreateGlesEnv Check window and EGLConfig attributes");
|
||||
break;
|
||||
default:
|
||||
LOGI("gl-->::CreateGlesEnv happen default error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 创建渲染上下文 EGLContext
|
||||
m_eglCtx = eglCreateContext(m_eglDisplay, m_eglConf, EGL_NO_CONTEXT, ctxAttr);
|
||||
if (m_eglCtx == EGL_NO_CONTEXT) {
|
||||
EGLint error = eglGetError();
|
||||
if (error == EGL_BAD_CONFIG) {
|
||||
LOGI("gl-->::CreateGlesEnv EGL_BAD_CONFIG");
|
||||
resultCode = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 绑定上下文
|
||||
if (!eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglCtx)) {
|
||||
resultCode = -1;
|
||||
break;
|
||||
}
|
||||
LOGI("gl-->::CreateGlesEnv initialize success");
|
||||
} while (false);
|
||||
|
||||
if (resultCode != 0) {
|
||||
LOGI("gl-->::CreateGlesEnv fail");
|
||||
}
|
||||
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
|
@ -683,7 +643,6 @@ void EGLRender::SetIntParams(int paramType, int param)
|
|||
vShader[0] = vShaderStr;
|
||||
break;
|
||||
}
|
||||
|
||||
m_ProgramObj = GLUtils::CreateProgram(vShader[0], fShader[0], m_VertexShader,
|
||||
m_FragmentShader);
|
||||
if (!m_ProgramObj) {
|
||||
|
@ -691,7 +650,6 @@ void EGLRender::SetIntParams(int paramType, int param)
|
|||
LOGI("gl--> EGLRender::SetIntParams Could not create program.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_SamplerLoc = glGetUniformLocation(m_ProgramObj, "s_TextureMap");
|
||||
m_TexSizeLoc = glGetUniformLocation(m_ProgramObj, "u_texSize");
|
||||
}
|
||||
|
@ -704,7 +662,9 @@ void EGLRender::SetIntParams(int paramType, int param)
|
|||
|
||||
void EGLRender::UseProgram()
|
||||
{
|
||||
if (m_ProgramObj == GL_NONE) return;
|
||||
if (m_ProgramObj == GL_NONE) {
|
||||
return;
|
||||
}
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
|
|
@ -37,8 +37,7 @@ public:
|
|||
|
||||
static EGLRender* GetInstance()
|
||||
{
|
||||
if(sInstance == nullptr)
|
||||
{
|
||||
if (sInstance == nullptr) {
|
||||
sInstance = new EGLRender();
|
||||
}
|
||||
return sInstance;
|
||||
|
@ -46,8 +45,7 @@ public:
|
|||
|
||||
static void DestroyRender()
|
||||
{
|
||||
if (sInstance)
|
||||
{
|
||||
if (sInstance) {
|
||||
delete sInstance;
|
||||
sInstance = nullptr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue