diff options
author | chai <chaifix@163.com> | 2018-09-08 15:31:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-09-08 15:31:43 +0800 |
commit | 5361adf3b8714ca55dedf3a8883fcf143d470ac4 (patch) | |
tree | fc84ce7b79406570af822d5edddae67ff390362d /src | |
parent | 93696c0c85afc21e29c7bd57dc9c577a7d662bba (diff) |
*update
Diffstat (limited to 'src')
-rw-r--r-- | src/libjin/Common/Array.hpp | 13 | ||||
-rw-r--r-- | src/libjin/Graphics/Drawable.cpp | 4 | ||||
-rw-r--r-- | src/libjin/Graphics/Font.cpp | 2 | ||||
-rw-r--r-- | src/libjin/Graphics/Shapes.cpp | 1 | ||||
-rw-r--r-- | src/libjin/Graphics/Window.cpp | 11 | ||||
-rw-r--r-- | src/libjin/Graphics/Window.h | 2 |
6 files changed, 19 insertions, 14 deletions
diff --git a/src/libjin/Common/Array.hpp b/src/libjin/Common/Array.hpp index de22961..7c0f058 100644 --- a/src/libjin/Common/Array.hpp +++ b/src/libjin/Common/Array.hpp @@ -4,7 +4,7 @@ namespace jin { - /* ԶͷŶڴĶ̬ */ + /* ԶͷŶڴջϴĶ̬ */ template<typename T> class Array { @@ -62,6 +62,17 @@ namespace jin } private: + /** + * http://blog.jobbole.com/106923/ + * new ڴ洴 + * 1. new ڴ + * 2. ù캯 + * + * new, deleteڷͷڴ棬 + */ + void* operator new(size_t t); + void operator delete(void* ptr); + T * data; unsigned int length; diff --git a/src/libjin/Graphics/Drawable.cpp b/src/libjin/Graphics/Drawable.cpp index fec0575..acdb6e1 100644 --- a/src/libjin/Graphics/Drawable.cpp +++ b/src/libjin/Graphics/Drawable.cpp @@ -36,8 +36,6 @@ namespace graphics static jin::math::Matrix t; t.setTransformation(x, y, r, sx, sy, anchor.x, anchor.y); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texture); // push modle matrix @@ -57,8 +55,6 @@ namespace graphics // bind texture to default screen glBindTexture(GL_TEXTURE_2D, 0); - - glDisable(GL_TEXTURE_2D); } } // render diff --git a/src/libjin/Graphics/Font.cpp b/src/libjin/Graphics/Font.cpp index 3bdc5ca..1d88280 100644 --- a/src/libjin/Graphics/Font.cpp +++ b/src/libjin/Graphics/Font.cpp @@ -78,7 +78,6 @@ namespace graphics int len = strlen(text); - glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glEnableClientState(GL_VERTEX_ARRAY); @@ -146,7 +145,6 @@ namespace graphics glDisableClientState(GL_VERTEX_ARRAY); glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); } void Font::box(const char* text, int fontHeight, int spacing, int lineHeight, int* w, int * h) diff --git a/src/libjin/Graphics/Shapes.cpp b/src/libjin/Graphics/Shapes.cpp index 4601375..f4c5093 100644 --- a/src/libjin/Graphics/Shapes.cpp +++ b/src/libjin/Graphics/Shapes.cpp @@ -32,7 +32,6 @@ namespace graphics void line(int x1, int y1, int x2, int y2) { - glDisable(GL_TEXTURE_2D); float verts[] = { x1, y1, x2, y2 diff --git a/src/libjin/Graphics/Window.cpp b/src/libjin/Graphics/Window.cpp index e5f32ba..8d42bbf 100644 --- a/src/libjin/Graphics/Window.cpp +++ b/src/libjin/Graphics/Window.cpp @@ -67,15 +67,16 @@ namespace graphics return false; SDL_GL_SetSwapInterval(vsync ? 1 : 0); SDL_GL_MakeCurrent(wnd, ctx); + /* default configuration */ glClearColor(0.f, 0.f, 0.f, 1.f); - glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glColor4f(1, 1, 1, 1); - glEnable(GL_BLEND); + glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - Canvas::unbind(); + /* avoid white screen blink on windows */ swapBuffers(); + /* bind to default canvas */ + Canvas::unbind(); return true; } @@ -85,7 +86,7 @@ namespace graphics SDL_Quit(); } - inline void Window::swapBuffers() + void Window::swapBuffers() { if (wnd) SDL_GL_SwapWindow(wnd); diff --git a/src/libjin/Graphics/Window.h b/src/libjin/Graphics/Window.h index ebd776e..6b247a6 100644 --- a/src/libjin/Graphics/Window.h +++ b/src/libjin/Graphics/Window.h @@ -31,7 +31,7 @@ namespace graphics inline int getW(){ return size.w; } inline int getH(){ return size.h; } inline int getFPS(){ return fps; } - inline void swapBuffers(); + void swapBuffers(); private: SINGLETON(Window); |