aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/render/canvas.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-05-18 14:39:38 +0800
committerchai <chaifix@163.com>2018-05-18 14:39:38 +0800
commit1b773ad2c250e09c09c065eb3eec64bfebde09ca (patch)
treeb3f1f367694d5f86cc0caa7f4eea2e6a1d3424c5 /src/libjin/render/canvas.cpp
parent91a592da979827b1735901388dba8712e6e3ecf3 (diff)
修改userdata创建方式
Diffstat (limited to 'src/libjin/render/canvas.cpp')
-rw-r--r--src/libjin/render/canvas.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libjin/render/canvas.cpp b/src/libjin/render/canvas.cpp
index 376c076..89d0d77 100644
--- a/src/libjin/render/canvas.cpp
+++ b/src/libjin/render/canvas.cpp
@@ -6,26 +6,26 @@ namespace jin
{
namespace render
{
- Canvas::Canvas() :Drawable()
+ Canvas::Canvas(int w, int h)
+ : Drawable(w, h)
{
+ init();
}
Canvas::~Canvas()
{
}
- // no canvas has binded
shared GLint Canvas::cur = -1;
- bool Canvas::init(int w, int h)
+ bool Canvas::init()
{
- Drawable::init(w, h);
- Drawable::setVertices(
+ setVertices(
new float [DRAWABLE_V_SIZE] {
0, 0,
- 0, (float)h,
- (float)w, (float)h,
- (float)w, 0,
+ 0, (float)height,
+ (float)width, (float)height,
+ (float)width, 0,
},
new float [DRAWABLE_V_SIZE] {
0, 1,
@@ -47,7 +47,7 @@ namespace render
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);