aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/je_shapes.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-11-18 23:45:58 +0800
committerchai <chaifix@163.com>2018-11-18 23:45:58 +0800
commit4279e16ddb6273a9711ff331d21325dd5f63e769 (patch)
tree0d7ff12807fba478134f3bf9e01fd474c3a0b510 /src/libjin/Graphics/je_shapes.cpp
parent8cb74178c2b8e5883a1181af687fa8cfc0c6e5da (diff)
*修改目录为小写
Diffstat (limited to 'src/libjin/Graphics/je_shapes.cpp')
-rw-r--r--src/libjin/Graphics/je_shapes.cpp130
1 files changed, 0 insertions, 130 deletions
diff --git a/src/libjin/Graphics/je_shapes.cpp b/src/libjin/Graphics/je_shapes.cpp
deleted file mode 100644
index 0b239e7..0000000
--- a/src/libjin/Graphics/je_shapes.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-#include "../core/je_configuration.h"
-#if defined(jin_graphics)
-
-#include <string>
-
-#include "../math/je_matrix.h"
-#include "../math/je_constant.h"
-
-#include "shaders/je_shader.h"
-#include "je_shapes.h"
-
-using namespace JinEngine::Graphics::Shaders;
-
-namespace JinEngine
-{
- namespace Graphics
- {
-
- using namespace Math;
-
- void point(int x, int y)
- {
- float verts[] = { x + 0.5f , y + 0.5f };
-
- Shader* shader = Shader::getCurrentShader();
- shader->setVertexPointer(2, GL_FLOAT, 0, verts);
- Matrix modelMatrix = gl.getModelViewMatrix();
- shader->sendMatrix4(SHADER_MODELVIEW_MATRIX, &modelMatrix);
- shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.getProjectionMatrix());
-
- glDrawArrays(GL_POINTS, 0, 1);
- }
-
- void points(int n, GLshort* p)
- {
- Shader* shader = Shader::getCurrentShader();
- shader->setVertexPointer(2, GL_SHORT, 0, p);
- Matrix modelMatrix = gl.getModelViewMatrix();
- shader->sendMatrix4(SHADER_MODELVIEW_MATRIX, &modelMatrix);
- shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.getProjectionMatrix());
-
- glDrawArrays(GL_POINTS, 0, n);
- }
-
- void line(int x1, int y1, int x2, int y2)
- {
- float verts[] = {
- x1 + 0.5f, y1 + 0.5f,
- x2 + 0.5f, y2 + 0.5f
- };
-
- Shader* shader = Shader::getCurrentShader();
- shader->setVertexPointer(2, GL_FLOAT, 0, verts);
- Matrix modelMatrix = gl.getModelViewMatrix();
- shader->sendMatrix4(SHADER_MODELVIEW_MATRIX, &modelMatrix);
- shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.getProjectionMatrix());
-
- glDrawArrays(GL_LINES, 0, 2);
- }
-
- void circle(RenderMode mode, int x, int y, int r)
- {
- r = r < 0 ? 0 : r;
-
- int points = 40;
- float two_pi = static_cast<float>(PI * 2);
- if (points <= 0) points = 1;
- float angle_shift = (two_pi / points);
- float phi = .0f;
-
- float *coords = new float[2 * (points + 1)];
- for (int i = 0; i < points; ++i, phi += angle_shift)
- {
- coords[2 * i] = x + r * cos(phi);
- coords[2 * i + 1] = y + r * sin(phi);
- }
-
- coords[2 * points] = coords[0];
- coords[2 * points + 1] = coords[1];
-
- polygon(mode, coords, points);
-
- delete[] coords;
- }
-
- void rect(RenderMode mode, int x, int y, int w, int h)
- {
- float coords[] = { x + 0.5f, y + 0.5f, x + w + 0.5f, y + 0.5f, x + w + 0.5f, y + h + 0.5f, x + 0.5f, y + h + 0.5f };
- polygon(mode, coords, 4);
- }
-
- void triangle(RenderMode mode, int x1, int y1, int x2, int y2, int x3, int y3)
- {
- float coords[] = { x1 + 0.5f, y1 + 0.5f, x2 + 0.5f, y2 + 0.5f, x3 + 0.5f, y3 + 0.5f };
- polygon(mode, coords, 3);
- }
-
- void polygon_line(float* p, int count)
- {
- Shader* shader = Shader::getCurrentShader();
- Matrix modelMatrix = gl.getModelViewMatrix();
- shader->sendMatrix4(SHADER_MODELVIEW_MATRIX, &modelMatrix);
- shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.getProjectionMatrix());
- shader->setVertexPointer(2, GL_FLOAT, 0, p);
-
- glDrawArrays(GL_LINE_LOOP, 0, count);
- }
-
- void polygon(RenderMode mode, float* p, int count)
- {
- if (mode == LINE)
- {
- polygon_line(p, count);
- }
- else if (mode == FILL)
- {
- Shader* shader = Shader::getCurrentShader();
- Matrix modelMatrix = gl.getModelViewMatrix();
- shader->sendMatrix4(SHADER_MODELVIEW_MATRIX, &modelMatrix);
- shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.getProjectionMatrix());
- shader->setVertexPointer(2, GL_FLOAT, 0, p);
-
- glDrawArrays(GL_POLYGON, 0, count);
- }
- }
-
- } // namespace Graphics
-} // namespace JinEngine
-
-#endif // defined(jin_graphics) \ No newline at end of file