mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
@@ -1157,7 +1157,7 @@ void GLES2CmdFuncExecuteCmds(GLES2Device* device, GLES2CmdPackage* cmd_package)
|
||||
|
||||
for (uint i = 0; i < cmd_package->cmd_types.Size(); ++i) {
|
||||
GFXCmdType cmd_type = cmd_package->cmd_types[i];
|
||||
uint cmd_idx = cmd_indices[(int)cmd_type];
|
||||
uint& cmd_idx = cmd_indices[(int)cmd_type];
|
||||
|
||||
switch (cmd_type) {
|
||||
case GFXCmdType::BEGIN_RENDER_PASS: {
|
||||
@@ -1230,9 +1230,8 @@ void GLES2CmdFuncExecuteCmds(GLES2Device* device, GLES2CmdPackage* cmd_package)
|
||||
switch (gpu_render_pass->depth_stencil_attachment.depth_load_op) {
|
||||
case GFXLoadOp::LOAD: break; // GL default behaviour
|
||||
case GFXLoadOp::CLEAR: {
|
||||
if (cache->dss.depth_write) {
|
||||
glDepthMask(true);
|
||||
}
|
||||
cache->dss.depth_write = true;
|
||||
glClearDepthf(cmd->clear_depth);
|
||||
gl_clears |= GL_DEPTH_BUFFER_BIT;
|
||||
break;
|
||||
@@ -1919,6 +1918,7 @@ void GLES2CmdFuncExecuteCmds(GLES2Device* device, GLES2CmdPackage* cmd_package)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
cmd_idx++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class CC_GLES2_API GLES2Context : public GFXContext {
|
||||
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS)
|
||||
CC_INLINE intptr_t eagl_context() const { return eagl_context_; }
|
||||
CC_INLINE intptr_t eagl_shared_ctx() const { return eagl_shared_ctx_; }
|
||||
CC_INLINE uint getDefaultFramebuffer() const { return _defaultFBO; }
|
||||
#else
|
||||
CC_INLINE NativeDisplayType native_display() const { return native_display_; }
|
||||
CC_INLINE EGLDisplay egl_display() const { return egl_display_; }
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "GLES2RenderPass.h"
|
||||
#include "GLES2Commands.h"
|
||||
#include "GLES2TextureView.h"
|
||||
#include "GLES2Context.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
@@ -39,15 +40,21 @@ bool GLES2Framebuffer::Initialize(const GFXFramebufferInfo &info) {
|
||||
|
||||
GLES2CmdFuncCreateFramebuffer((GLES2Device*)device_, gpu_fbo_);
|
||||
}
|
||||
|
||||
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS)
|
||||
else
|
||||
{
|
||||
gpu_fbo_->gl_fbo = static_cast<GLES2Context*>(device_->context())->getDefaultFramebuffer();
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLES2Framebuffer::Destroy() {
|
||||
if (gpu_fbo_) {
|
||||
CC_DELETE(gpu_fbo_);
|
||||
GLES2CmdFuncDestroyFramebuffer((GLES2Device*)device_, gpu_fbo_);
|
||||
gpu_fbo_ = nullptr;
|
||||
if(is_offscreen())
|
||||
GLES2CmdFuncDestroyFramebuffer((GLES2Device*)device_, gpu_fbo_);
|
||||
CC_DELETE(gpu_fbo_);
|
||||
gpu_fbo_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ bool GLES2Window::Initialize(const GFXWindowInfo &info) {
|
||||
depth_stencil_texture_ = device_->CreateGFXTexture(depth_stecnil_tex_info);
|
||||
|
||||
GFXTextureViewInfo depth_stecnil_tex_view_info;
|
||||
depth_stecnil_tex_view_info.texture = depth_stencil_texture_;
|
||||
depth_stecnil_tex_view_info.type = GFXTextureViewType::TV2D;
|
||||
depth_stecnil_tex_view_info.format = color_fmt_;
|
||||
depth_stecnil_tex_view_info.base_level = 0;
|
||||
@@ -96,7 +97,8 @@ bool GLES2Window::Initialize(const GFXWindowInfo &info) {
|
||||
|
||||
GFXFramebufferInfo fbo_info;
|
||||
fbo_info.render_pass = render_pass_;
|
||||
fbo_info.color_views.push_back(color_tex_view_);
|
||||
if(color_tex_view_)
|
||||
fbo_info.color_views.push_back(color_tex_view_);
|
||||
fbo_info.depth_stencil_view = depth_stencil_tex_view_;
|
||||
fbo_info.is_offscreen = is_offscreen_;
|
||||
framebuffer_ = device_->CreateGFXFramebuffer(fbo_info);
|
||||
|
||||
@@ -1278,7 +1278,7 @@ void GLES3CmdFuncExecuteCmds(GLES3Device* device, GLES3CmdPackage* cmd_package)
|
||||
|
||||
for (uint i = 0; i < cmd_package->cmd_types.Size(); ++i) {
|
||||
GFXCmdType cmd_type = cmd_package->cmd_types[i];
|
||||
uint cmd_idx = cmd_indices[(int)cmd_type];
|
||||
uint& cmd_idx = cmd_indices[(int)cmd_type];
|
||||
|
||||
switch (cmd_type) {
|
||||
case GFXCmdType::BEGIN_RENDER_PASS: {
|
||||
@@ -1358,9 +1358,8 @@ void GLES3CmdFuncExecuteCmds(GLES3Device* device, GLES3CmdPackage* cmd_package)
|
||||
switch (gpu_render_pass->depth_stencil_attachment.depth_load_op) {
|
||||
case GFXLoadOp::LOAD: break; // GL default behaviour
|
||||
case GFXLoadOp::CLEAR: {
|
||||
if (cache->dss.depth_write) {
|
||||
glDepthMask(true);
|
||||
}
|
||||
cache->dss.depth_write = true;
|
||||
glClearDepthf(cmd->clear_depth);
|
||||
gl_clears |= GL_DEPTH_BUFFER_BIT;
|
||||
break;
|
||||
@@ -1884,6 +1883,7 @@ void GLES3CmdFuncExecuteCmds(GLES3Device* device, GLES3CmdPackage* cmd_package)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
cmd_idx++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class CC_GLES3_API GLES3Context : public GFXContext {
|
||||
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS)
|
||||
CC_INLINE intptr_t eagl_context() const { return eagl_context_; }
|
||||
CC_INLINE intptr_t eagl_shared_ctx() const { return eagl_shared_ctx_; }
|
||||
CC_INLINE uint getDefaultFramebuffer() const { return _defaultFBO; }
|
||||
#else
|
||||
CC_INLINE NativeDisplayType native_display() const { return native_display_; }
|
||||
CC_INLINE EGLDisplay egl_display() const { return egl_display_; }
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "GLES3RenderPass.h"
|
||||
#include "GLES3Commands.h"
|
||||
#include "GLES3TextureView.h"
|
||||
#include "GLES3Context.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
@@ -39,15 +40,22 @@ bool GLES3Framebuffer::Initialize(const GFXFramebufferInfo &info) {
|
||||
|
||||
GLES3CmdFuncCreateFramebuffer((GLES3Device*)device_, gpu_fbo_);
|
||||
}
|
||||
|
||||
#if (CC_PLATFORM == CC_PLATFORM_MAC_IOS)
|
||||
else
|
||||
{
|
||||
gpu_fbo_->gl_fbo = static_cast<GLES3Context*>(device_->context())->getDefaultFramebuffer();
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLES3Framebuffer::Destroy() {
|
||||
if (gpu_fbo_) {
|
||||
CC_DELETE(gpu_fbo_);
|
||||
GLES3CmdFuncDestroyFramebuffer((GLES3Device*)device_, gpu_fbo_);
|
||||
gpu_fbo_ = nullptr;
|
||||
if(is_offscreen())
|
||||
GLES3CmdFuncDestroyFramebuffer((GLES3Device*)device_, gpu_fbo_);
|
||||
CC_DELETE(gpu_fbo_);
|
||||
gpu_fbo_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ bool GLES3Window::Initialize(const GFXWindowInfo &info) {
|
||||
depth_stencil_texture_ = device_->CreateGFXTexture(depth_stecnil_tex_info);
|
||||
|
||||
GFXTextureViewInfo depth_stecnil_tex_view_info;
|
||||
depth_stecnil_tex_view_info.texture = depth_stencil_texture_;
|
||||
depth_stecnil_tex_view_info.type = GFXTextureViewType::TV2D;
|
||||
depth_stecnil_tex_view_info.format = color_fmt_;
|
||||
depth_stecnil_tex_view_info.base_level = 0;
|
||||
@@ -96,7 +97,8 @@ bool GLES3Window::Initialize(const GFXWindowInfo &info) {
|
||||
|
||||
GFXFramebufferInfo fbo_info;
|
||||
fbo_info.render_pass = render_pass_;
|
||||
fbo_info.color_views.push_back(color_tex_view_);
|
||||
if(color_tex_view_)
|
||||
fbo_info.color_views.push_back(color_tex_view_);
|
||||
fbo_info.depth_stencil_view = depth_stencil_tex_view_;
|
||||
fbo_info.is_offscreen = is_offscreen_;
|
||||
framebuffer_ = device_->CreateGFXFramebuffer(fbo_info);
|
||||
|
||||
Reference in New Issue
Block a user