aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-09-23 08:37:15 +0800
committerchai <chaifix@163.com>2018-09-23 08:37:15 +0800
commita3d22ce8cc65603d65e70ab024dea5bce0ec1ce0 (patch)
tree6093deefa1ac8d4aeb87dc1efbb001d89531bc47
parent54f1e742ce9de35013929de6b02948d59db89ccf (diff)
*update
-rw-r--r--build/01HelloWorld/01HelloWorld.vcxproj2
-rw-r--r--build/02Audio/02Audio.vcxproj2
-rw-r--r--build/03Thread/03Thread.vcxproj2
-rw-r--r--build/04Network/04Network.vcxproj2
-rw-r--r--build/05Font/05Font.vcxproj2
-rw-r--r--build/libjin/libjin.vcxproj2
-rw-r--r--libjin/3rdparty/ogl/OpenGL.h314
-rw-r--r--libjin/Graphics/Bitmap.h4
-rw-r--r--libjin/Graphics/Canvas.cpp12
-rw-r--r--libjin/Graphics/OpenGL.h1
-rw-r--r--test/05Font/main.cpp4
11 files changed, 181 insertions, 166 deletions
diff --git a/build/01HelloWorld/01HelloWorld.vcxproj b/build/01HelloWorld/01HelloWorld.vcxproj
index fb2a36a..07d0c09 100644
--- a/build/01HelloWorld/01HelloWorld.vcxproj
+++ b/build/01HelloWorld/01HelloWorld.vcxproj
@@ -21,7 +21,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{F1B984AA-F46D-46C9-9A5A-7606A30E0599}</ProjectGuid>
<RootNamespace>My01HelloWorld</RootNamespace>
- <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
+ <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
diff --git a/build/02Audio/02Audio.vcxproj b/build/02Audio/02Audio.vcxproj
index 1c7ae98..24bed95 100644
--- a/build/02Audio/02Audio.vcxproj
+++ b/build/02Audio/02Audio.vcxproj
@@ -21,7 +21,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{A2D75980-B0AC-498C-B507-4727B4A38E83}</ProjectGuid>
<RootNamespace>My02Audio</RootNamespace>
- <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
+ <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
diff --git a/build/03Thread/03Thread.vcxproj b/build/03Thread/03Thread.vcxproj
index 06187a8..701a062 100644
--- a/build/03Thread/03Thread.vcxproj
+++ b/build/03Thread/03Thread.vcxproj
@@ -21,7 +21,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{0E49D105-2032-4825-9FA1-54B1B94E3655}</ProjectGuid>
<RootNamespace>My03Thread</RootNamespace>
- <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
+ <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
diff --git a/build/04Network/04Network.vcxproj b/build/04Network/04Network.vcxproj
index e428352..01ff795 100644
--- a/build/04Network/04Network.vcxproj
+++ b/build/04Network/04Network.vcxproj
@@ -21,7 +21,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{85071432-24B6-46D4-98D8-DAA63183093C}</ProjectGuid>
<RootNamespace>My04Network</RootNamespace>
- <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
+ <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
diff --git a/build/05Font/05Font.vcxproj b/build/05Font/05Font.vcxproj
index 3bdac9b..918d53e 100644
--- a/build/05Font/05Font.vcxproj
+++ b/build/05Font/05Font.vcxproj
@@ -22,7 +22,7 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{D1953718-E728-4A86-9CCF-8BEC1F5C5F97}</ProjectGuid>
<RootNamespace>My05Font</RootNamespace>
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
diff --git a/build/libjin/libjin.vcxproj b/build/libjin/libjin.vcxproj
index 0cdd2ad..71bf2ce 100644
--- a/build/libjin/libjin.vcxproj
+++ b/build/libjin/libjin.vcxproj
@@ -128,7 +128,7 @@
<ProjectGuid>{407E9199-D39C-4460-B218-0C29AB42483B}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>libjin</RootNamespace>
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
diff --git a/libjin/3rdparty/ogl/OpenGL.h b/libjin/3rdparty/ogl/OpenGL.h
index 4789662..586122b 100644
--- a/libjin/3rdparty/ogl/OpenGL.h
+++ b/libjin/3rdparty/ogl/OpenGL.h
@@ -3,161 +3,175 @@
#include <vector>
/* include gl.h before this file */
-
-/* 2d wrap of opengl 3.0 */
-class OpenGL
+namespace ogl2d
{
-public:
- OpenGL();
- ~OpenGL();
-
- inline void enable(GLenum cap)
- {
- glEnable(cap);
- }
-
- inline void disable(GLenum cap)
- {
- glDisable(cap);
- }
-
- inline void setBlendFunc(GLenum sfactor, GLenum dfactor)
- {
- glBlendFunc(sfactor, dfactor);
- }
-
- inline void setClearColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
- {
- glClearColor(r/255.f, g/255.f, b/255.f, a/255.f);
- }
-
- void pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a = 255);
- void popColor();
- void flushError();
- GLuint genTexture();
- void bindTexture(GLuint texture = 0);
- inline GLuint curTexture()
- {
- return _texture;
- }
- void setTexParameter(GLenum pname, GLint param);
- void texImage(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels = NULL);
- void texSubImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
- void activeTexUnit(unsigned int unit = 0);
- inline void vertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
- {
- glVertexPointer(size, type, stride, pointer);
- }
-
- inline void texCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
- {
- glTexCoordPointer(size, type, stride, pointer);
- }
-
- inline void drawArrays(GLenum mode, GLint first, GLsizei count)
- {
- glDrawArrays(mode, first, count);
- }
-
- inline void drawBuffer(GLenum mode)
- {
-
- }
-
- inline void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
- {
-
- }
-
- inline void enableClientState(GLenum arr)
- {
- glEnableClientState(arr);
- }
-
- inline void disableClientState(GLenum arr)
- {
- glDisableClientState(arr);
- }
-
-private:
- struct { GLubyte r, g, b, a; } _color; // current draw color
- struct { GLubyte r, g, b, a; } _precolor; // previous draw color
- GLuint _texture; // current binded texture
-
-};
-
-/* OpenGL instance singleton */
-extern OpenGL gl;
+ /* 2d wrap of opengl 3.0 */
+ class OpenGL
+ {
+ public:
+ OpenGL();
+ ~OpenGL();
+
+ inline void enable(GLenum cap)
+ {
+ glEnable(cap);
+ }
+
+ inline void disable(GLenum cap)
+ {
+ glDisable(cap);
+ }
+
+ inline void setBlendFunc(GLenum sfactor, GLenum dfactor)
+ {
+ glBlendFunc(sfactor, dfactor);
+ }
+
+ inline void setClearColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+ {
+ glClearColor(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
+ }
+
+ void pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a = 255);
+ void popColor();
+ void flushError();
+ GLuint genTexture();
+ void bindTexture(GLuint texture = 0);
+ inline GLuint curTexture()
+ {
+ return _texture;
+ }
+ void setTexParameter(GLenum pname, GLint param);
+ void texImage(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels = NULL);
+ void texSubImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+ void activeTexUnit(unsigned int unit = 0);
+ inline void vertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+ {
+ glVertexPointer(size, type, stride, pointer);
+ }
+
+ inline void texCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
+ {
+ glTexCoordPointer(size, type, stride, pointer);
+ }
+
+ inline void drawArrays(GLenum mode, GLint first, GLsizei count)
+ {
+ glDrawArrays(mode, first, count);
+ }
+
+ inline void drawBuffer(GLenum mode)
+ {
+
+ }
+
+ inline void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
+ {
+
+ }
+
+ inline void enableClientState(GLenum arr)
+ {
+ glEnableClientState(arr);
+ }
+
+ inline void disableClientState(GLenum arr)
+ {
+ glDisableClientState(arr);
+ }
+
+ inline GLuint genFrameBuffer()
+ {
+ GLuint fbo;
+ glGenFramebuffers(1, &fbo);
+ return fbo;
+ }
+
+ inline void bindFrameBuffer(GLuint fbo)
+ {
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+ }
+
+ private:
+ struct { GLubyte r, g, b, a; } _color; // current draw color
+ struct { GLubyte r, g, b, a; } _precolor; // previous draw color
+ GLuint _texture; // current binded texture
+
+ };
+
+ /* OpenGL instance singleton */
+ extern OpenGL gl;
#if defined(OGL2D_IMPLEMENT)
-OpenGL gl;
-
-OpenGL::OpenGL()
-{
- memset(&_color, 0xff, sizeof(_color));
- memset(&_precolor, 0xff, sizeof(_precolor));
-}
-
-OpenGL::~OpenGL()
-{
-
-}
-
-void OpenGL::pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
-{
- memcpy(&_precolor, &_color, sizeof(_precolor));
- _color.r = r;
- _color.g = g;
- _color.b = b;
- _color.a = a;
- glColor4ub(r, g, b, a);
-}
-
-void OpenGL::popColor()
-{
- memcpy(&_color, &_precolor, sizeof(_precolor));
- glColor4ub(_color.r, _color.g, _color.b, _color.a);
-}
-
-void OpenGL::flushError()
-{
- while (glGetError() != GL_NO_ERROR);
-}
-
-GLuint OpenGL::genTexture()
-{
- GLuint t;
- glGenTextures(1, &t);
- return t;
-}
-
-void OpenGL::bindTexture(GLuint texture)
-{
- glBindTexture(GL_TEXTURE_2D, texture);
-}
-
-void OpenGL::setTexParameter(GLenum pname, GLint param)
-{
- glTexParameteri(GL_TEXTURE_2D, pname, param);
-}
-
-void OpenGL::texImage(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
-{
- glTexImage2D(GL_TEXTURE_2D, 0, internalformat, width, height, 0, format, type, pixels);
-}
-
-void OpenGL::texSubImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
-{
- glTexSubImage2D(GL_TEXTURE_2D, 0, xoffset, yoffset, width, height, format, type, pixels);
-}
-
-void OpenGL::activeTexUnit(unsigned int unit)
-{
- // glActiveTexture selects which texture unit subsequent texture state calls will affect.
- glActiveTexture(GL_TEXTURE0 + unit);
-}
+ OpenGL gl;
+
+ OpenGL::OpenGL()
+ {
+ memset(&_color, 0xff, sizeof(_color));
+ memset(&_precolor, 0xff, sizeof(_precolor));
+ }
+
+ OpenGL::~OpenGL()
+ {
+
+ }
+
+ void OpenGL::pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+ {
+ memcpy(&_precolor, &_color, sizeof(_precolor));
+ _color.r = r;
+ _color.g = g;
+ _color.b = b;
+ _color.a = a;
+ glColor4ub(r, g, b, a);
+ }
+
+ void OpenGL::popColor()
+ {
+ memcpy(&_color, &_precolor, sizeof(_precolor));
+ glColor4ub(_color.r, _color.g, _color.b, _color.a);
+ }
+
+ void OpenGL::flushError()
+ {
+ while (glGetError() != GL_NO_ERROR);
+ }
+
+ GLuint OpenGL::genTexture()
+ {
+ GLuint t;
+ glGenTextures(1, &t);
+ return t;
+ }
+
+ void OpenGL::bindTexture(GLuint texture)
+ {
+ glBindTexture(GL_TEXTURE_2D, texture);
+ }
+
+ void OpenGL::setTexParameter(GLenum pname, GLint param)
+ {
+ glTexParameteri(GL_TEXTURE_2D, pname, param);
+ }
+
+ void OpenGL::texImage(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
+ {
+ glTexImage2D(GL_TEXTURE_2D, 0, internalformat, width, height, 0, format, type, pixels);
+ }
+
+ void OpenGL::texSubImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
+ {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, xoffset, yoffset, width, height, format, type, pixels);
+ }
+
+ void OpenGL::activeTexUnit(unsigned int unit)
+ {
+ // glActiveTexture selects which texture unit subsequent texture state calls will affect.
+ glActiveTexture(GL_TEXTURE0 + unit);
+ }
#endif // OGL2D_IMPLEMENT
+}
#endif \ No newline at end of file
diff --git a/libjin/Graphics/Bitmap.h b/libjin/Graphics/Bitmap.h
index 5754145..5510569 100644
--- a/libjin/Graphics/Bitmap.h
+++ b/libjin/Graphics/Bitmap.h
@@ -42,8 +42,8 @@ namespace graphics
};
-}
-}
+} // graphics
+} // jin
#endif
#endif \ No newline at end of file
diff --git a/libjin/Graphics/Canvas.cpp b/libjin/Graphics/Canvas.cpp
index 511aa12..d53e775 100644
--- a/libjin/Graphics/Canvas.cpp
+++ b/libjin/Graphics/Canvas.cpp
@@ -30,22 +30,22 @@ namespace graphics
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &current_fbo);
/* generate a new render buffer object */
- glGenFramebuffers(1, &fbo);
- glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+ fbo = gl.genFrameBuffer();
+ gl.bindFrameBuffer(fbo);
/* generate texture save target */
- glGenTextures(1, &texture);
+ texture = gl.genTexture();
gl.bindTexture(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);
+ 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 */
- glBindFramebuffer(GL_FRAMEBUFFER, current_fbo);
+ gl.bindFrameBuffer(current_fbo);
}
Canvas::~Canvas()
@@ -64,7 +64,7 @@ namespace graphics
{
if (isBinded(canvas)) return;
current = canvas;
- glBindFramebuffer(GL_FRAMEBUFFER, canvas->fbo);
+ gl.bindFrameBuffer(canvas->fbo);
int w = canvas->size.w;
int h = canvas->size.h;
diff --git a/libjin/Graphics/OpenGL.h b/libjin/Graphics/OpenGL.h
index 0a1c3e3..97db164 100644
--- a/libjin/Graphics/OpenGL.h
+++ b/libjin/Graphics/OpenGL.h
@@ -1,5 +1,6 @@
#include "../3rdparty/GLee/GLee.h"
#include "../3rdparty/ogl/OpenGL.h"
+using namespace ogl2d;
/* GL.h
diff --git a/test/05Font/main.cpp b/test/05Font/main.cpp
index cc6b0e6..3c4fd46 100644
--- a/test/05Font/main.cpp
+++ b/test/05Font/main.cpp
@@ -27,7 +27,7 @@ Color effect(Color col, Texture tex, vec2 uv, vec2 screen)
Buffer buffer;
fs->read("font.ttf", &buffer);
data = FontData::createFontData((const unsigned char*)buffer.data, buffer.size);
- font = Font::createFont(data, 16);
+ font = Font::createFont(data, 12);
//canvas = Canvas::createCanvas(100, 100);
//page = font->typeset("こんにちは世界!", 120, 20);
}
@@ -77,7 +77,7 @@ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
》开始在日本东京电视台播出。2004年,漫画进而改编成电影。2006年,漩涡鸣人入选
美国《新闻周刊》日文版于10月18日发行的特集中选出的“全世界最受尊敬的100位日本
人”。[2]
-)", 10, 10 + 15 * 2, 17,1);
+)", 10, 10 + 15 * 2, 14);
//font->print(u8"你好世界!", 10, 10 + 15*3);
//font->render(page);
glColor4f(1, 1, 1, 1);