From 71416cb4b388956d6132f6c8b5b77b0fb38b7a27 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 22 Dec 2018 10:46:06 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9vector=E5=88=86=E9=87=8F=E5=88=AB?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/graphics/je_graphic.h | 4 ++-- src/libjin/graphics/je_mesh.cpp | 18 +++++++++--------- src/libjin/graphics/je_vertex.h | 8 +++++--- src/libjin/graphics/je_window.h | 4 ++-- src/libjin/math/je_matrix.cpp | 7 +++---- src/libjin/math/je_vector2.hpp | 14 +++++++++++--- 6 files changed, 32 insertions(+), 23 deletions(-) (limited to 'src/libjin') diff --git a/src/libjin/graphics/je_graphic.h b/src/libjin/graphics/je_graphic.h index f47adbf..92c7c46 100644 --- a/src/libjin/graphics/je_graphic.h +++ b/src/libjin/graphics/je_graphic.h @@ -42,12 +42,12 @@ namespace JinEngine /// /// /// - inline int getWidth() const { return mSize.w; } + inline int getWidth() const { return mSize.w(); } /// /// /// - inline int getHeight() const { return mSize.h; } + inline int getHeight() const { return mSize.h(); } /// /// Get opengl texture token. diff --git a/src/libjin/graphics/je_mesh.cpp b/src/libjin/graphics/je_mesh.cpp index 4c27433..b96a4ff 100644 --- a/src/libjin/graphics/je_mesh.cpp +++ b/src/libjin/graphics/je_mesh.cpp @@ -24,8 +24,8 @@ namespace JinEngine void Mesh::pushVertex(float x, float y, float u, float v, Color color) { Vertex vert; - vert.x = x; vert.y = y; - vert.u = u; vert.v = v; + vert.xy.x = x; vert.xy.y = y; + vert.uv.u = u; vert.uv.v = v; vert.color = color; pushVertex(vert); } @@ -37,14 +37,14 @@ namespace JinEngine if (mVertices.size() == 2) { const Vertex& v0 = mVertices[0]; - mBound.l = min(v0.x, vert.x); - mBound.r = max(v0.x, vert.x); - mBound.t = min(v0.y, vert.y); - mBound.b = max(v0.y, vert.y); + mBound.l = min(v0.xy.x, vert.xy.x); + mBound.r = max(v0.xy.x, vert.xy.x); + mBound.t = min(v0.xy.y, vert.xy.y); + mBound.b = max(v0.xy.y, vert.xy.y); } else { - float x = vert.x, y = vert.y; + float x = vert.xy.x, y = vert.xy.y; mBound.l = x < mBound.l ? x : mBound.l; mBound.r = x > mBound.r ? x : mBound.r; mBound.t = y < mBound.t ? y : mBound.t; @@ -63,8 +63,8 @@ namespace JinEngine shader->sendMatrix4(SHADER_MODELVIEW_MATRIX, &modelViewMatrix); shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.getProjectionMatrix()); shader->beginUploadAttributes(); - shader->uploadVertices(2, GL_FLOAT, sizeof(Vertex), &(mVertices[0].x)); - shader->uploadUV(2, GL_FLOAT, sizeof(Vertex), &(mVertices[0].u)); + shader->uploadVertices(2, GL_FLOAT, sizeof(Vertex), &(mVertices[0].xy)); + shader->uploadUV(2, GL_FLOAT, sizeof(Vertex), &(mVertices[0].uv)); shader->uploadColor(4, GL_UNSIGNED_BYTE, sizeof(Vertex), &(mVertices[0].color), GL_TRUE); shader->endUploadAttributes(); diff --git a/src/libjin/graphics/je_vertex.h b/src/libjin/graphics/je_vertex.h index d149cfc..d2b482c 100644 --- a/src/libjin/graphics/je_vertex.h +++ b/src/libjin/graphics/je_vertex.h @@ -1,6 +1,8 @@ #ifndef __JE_MATH_VERTEX_H__ #define __JE_MATH_VERTEX_H__ +#include "../math/je_vector2.hpp" + #include "je_color.h" namespace JinEngine @@ -10,9 +12,9 @@ namespace JinEngine struct Vertex { - float x, y; // Coordinates - float u, v; // UV - Color color; // Color + Math::Vector2 xy; + Math::Vector2 uv; + Color color; }; } diff --git a/src/libjin/graphics/je_window.h b/src/libjin/graphics/je_window.h index 902e873..387395e 100644 --- a/src/libjin/graphics/je_window.h +++ b/src/libjin/graphics/je_window.h @@ -53,12 +53,12 @@ namespace JinEngine /// /// /// - inline int getW(){ return mSize.w; } + inline int getW(){ return mSize.w(); } /// /// /// - inline int getH(){ return mSize.h; } + inline int getH(){ return mSize.h(); } /// /// diff --git a/src/libjin/math/je_matrix.cpp b/src/libjin/math/je_matrix.cpp index f422002..96eae86 100644 --- a/src/libjin/math/je_matrix.cpp +++ b/src/libjin/math/je_matrix.cpp @@ -184,11 +184,10 @@ namespace JinEngine for (int i = 0; i