From 4279e16ddb6273a9711ff331d21325dd5f63e769 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 18 Nov 2018 23:45:58 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E7=9B=AE=E5=BD=95=E4=B8=BA=E5=B0=8F?= =?UTF-8?q?=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/Graphics/je_canvas.cpp | 101 -------------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 src/libjin/Graphics/je_canvas.cpp (limited to 'src/libjin/Graphics/je_canvas.cpp') diff --git a/src/libjin/Graphics/je_canvas.cpp b/src/libjin/Graphics/je_canvas.cpp deleted file mode 100644 index 8f216e6..0000000 --- a/src/libjin/Graphics/je_canvas.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "../core/je_configuration.h" -#if defined(jin_graphics) - -#include "../utils/je_macros.h" -#include "je_canvas.h" -#include "je_window.h" - -namespace JinEngine -{ - namespace Graphics - { - - const Canvas* Canvas::current = nullptr; - const Canvas* const Canvas::DEFAULT_CANVAS = new Canvas(0); - - Canvas* Canvas::createCanvas(int w, int h) - { - return new Canvas(w, h); - } - - Canvas::Canvas(GLuint n) - : fbo(n) - { - } - - Canvas::Canvas(int w, int h) - : Graphic(w, h) - { - GLint current_fbo; - glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); - - // Generate a new render buffer object - fbo = gl.genFrameBuffer(); - gl.bindFrameBuffer(fbo); - - GLuint texture = getGLTexture(); - gl.bindTexture(texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - gl.texImage(GL_RGBA8, w, h, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - gl.bindTexture(0); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); - - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - - // Unbind framebuffer - gl.bindFrameBuffer(current_fbo); - } - - Canvas::~Canvas() - { - } - - bool Canvas::isBinded(const Canvas* cvs) - { - return current == cvs; - } - - /** - * bind to canvas - */ - void Canvas::bind(Canvas* canvas) - { - if (isBinded(canvas)) return; - current = canvas; - gl.bindFrameBuffer(canvas->fbo); - int w = canvas->getWidth(); - int h = canvas->getHeight(); - // Set view port to canvas. - glViewport(0, 0, w, h); - gl.setProjectionMatrix(0, w, 0, h, -1, 1); - } - - /** - * bind to default screen render buffer. - * do some coordinates transform work - * https://blog.csdn.net/liji_digital/article/details/79370841 - * https://blog.csdn.net/lyx2007825/article/details/8792475 - */ - void Canvas::unbind() - { - if (isBinded(DEFAULT_CANVAS)) return; - current = DEFAULT_CANVAS; - /* get window size as viewport */ - Window* wnd = Window::get(); - int w = wnd->getW(); - int h = wnd->getH(); - - glBindFramebuffer(GL_FRAMEBUFFER, DEFAULT_CANVAS->fbo); - - /* set viewport on screen */ - glViewport(0, 0, w, h); - - gl.setProjectionMatrix(0, w, h, 0, -1, 1); - - } - - } // namespace Graphics -} // namespace JinEngine - -#endif // defined(jin_graphics) \ No newline at end of file -- cgit v1.1-26-g67d0