aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-09-07 00:27:46 +0800
committerchai <chaifix@163.com>2018-09-07 00:27:46 +0800
commit5e4a2c8fa58f30a93506c1db21aa7a9921c0affc (patch)
tree644837c30568296c311eb68b199048ad5f3b8a83 /src/libjin/Graphics
parentd395ac00770e1dad6f9a2ba98ef23b8b719d0d16 (diff)
*format source code
Diffstat (limited to 'src/libjin/Graphics')
-rw-r--r--src/libjin/Graphics/Bitmap.h1
-rw-r--r--src/libjin/Graphics/Canvas.h8
-rw-r--r--src/libjin/Graphics/Drawable.h3
-rw-r--r--src/libjin/Graphics/Font.h2
-rw-r--r--src/libjin/Graphics/Shader.cpp2
-rw-r--r--src/libjin/Graphics/Shader.h4
-rw-r--r--src/libjin/Graphics/Window.h1
-rw-r--r--src/libjin/Graphics/base.shader.h17
8 files changed, 17 insertions, 21 deletions
diff --git a/src/libjin/Graphics/Bitmap.h b/src/libjin/Graphics/Bitmap.h
index d050c43..464ca7f 100644
--- a/src/libjin/Graphics/Bitmap.h
+++ b/src/libjin/Graphics/Bitmap.h
@@ -18,7 +18,6 @@ namespace graphics
static Bitmap* createBitmap(int w, int h);
~Bitmap();
-
void bindPixels(Color* pixels, int w, int h);
void setPixels(Color* pixels, int w, int h);
void setPixel(const Color& pixel, int x, int y);
diff --git a/src/libjin/Graphics/Canvas.h b/src/libjin/Graphics/Canvas.h
index b5cf8a2..3b0a40a 100644
--- a/src/libjin/Graphics/Canvas.h
+++ b/src/libjin/Graphics/Canvas.h
@@ -13,12 +13,12 @@ namespace graphics
{
public:
static Canvas* createCanvas(int w, int h);
- ~Canvas();
-
- void bind();
static void unbind();
- static bool hasbind(GLint fbo);
+ static bool hasbind(GLint fbo);
+ ~Canvas();
+ void bind();
+
protected:
Canvas(int w, int h);
diff --git a/src/libjin/Graphics/Drawable.h b/src/libjin/Graphics/Drawable.h
index b3fc565..bdec5b4 100644
--- a/src/libjin/Graphics/Drawable.h
+++ b/src/libjin/Graphics/Drawable.h
@@ -16,7 +16,6 @@ namespace graphics
public:
Drawable(int w = 0, int h = 0);
virtual ~Drawable();
-
void setAnchor(int x, int y);
void draw(int x, int y, float sx, float sy, float r);
inline int getWidth() const { return size.x; }
@@ -28,7 +27,7 @@ namespace graphics
GLuint texture;
/* TODO: vertex buffer object */
- GLuint vbo;
+ /* GLuint vbo; */
jin::math::Vector2<unsigned int> size;
jin::math::Vector2<int> anchor;
float vertCoord[DRAWABLE_V_SIZE];
diff --git a/src/libjin/Graphics/Font.h b/src/libjin/Graphics/Font.h
index 5311c96..d805d1c 100644
--- a/src/libjin/Graphics/Font.h
+++ b/src/libjin/Graphics/Font.h
@@ -16,10 +16,8 @@ namespace graphics
{
public:
Font();
-
void loadFile(const char* file);
void loadMemory(const unsigned char* data);
-
void render(
const char* text, // rendered text
float x, float y, // render position
diff --git a/src/libjin/Graphics/Shader.cpp b/src/libjin/Graphics/Shader.cpp
index 1af861f..13e259d 100644
--- a/src/libjin/Graphics/Shader.cpp
+++ b/src/libjin/Graphics/Shader.cpp
@@ -45,7 +45,7 @@ namespace graphics
JSLProgram::JSLProgram(const char* program)
: currentTextureUnit(DEFAULT_TEX_UNIT)
{
- char* fs = (char*)calloc(1, strlen(program) + base_size);
+ char* fs = (char*)calloc(1, strlen(program) + SHADER_FORMAT_SIZE);
formatShader(fs, program);
GLuint shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(shader, 1, (const GLchar**)&fs, NULL);
diff --git a/src/libjin/Graphics/Shader.h b/src/libjin/Graphics/Shader.h
index 0356dd5..ad484db 100644
--- a/src/libjin/Graphics/Shader.h
+++ b/src/libjin/Graphics/Shader.h
@@ -35,12 +35,12 @@ namespace graphics
void sendColor(const char* name, const Color* col);
protected:
+ static JSLProgram* currentJSLProgram;
+
GLint claimTextureUnit(const std::string& name);
JSLProgram(const char* program);
void bindDefaultTexture();
- static JSLProgram* currentJSLProgram;
-
GLuint pid;
GLint currentTextureUnit;
std::map<std::string, GLint> textureUnits;
diff --git a/src/libjin/Graphics/Window.h b/src/libjin/Graphics/Window.h
index 09ec6dd..22033ee 100644
--- a/src/libjin/Graphics/Window.h
+++ b/src/libjin/Graphics/Window.h
@@ -37,7 +37,6 @@ namespace graphics
SINGLETON(Window);
Window() {};
virtual ~Window() {};
-
bool initSystem(const SettingBase* setting) override;
void quitSystem() override;
diff --git a/src/libjin/Graphics/base.shader.h b/src/libjin/Graphics/base.shader.h
index 0b8eca9..067a60b 100644
--- a/src/libjin/Graphics/base.shader.h
+++ b/src/libjin/Graphics/base.shader.h
@@ -1,3 +1,9 @@
+/*
+ * https://stackoverflow.com/questions/10868958/what-does-sampler2d-store
+ * The sampler2D is bound to a texture unit. The glUniform call binds it to texture
+ * unit zero. The glActiveTexture call is only needed if you are going to use multiple
+ * texture units (because GL_TEXTURE0 is the default anyway).
+*/
static const char* default_tex = "_tex0_";
@@ -21,13 +27,8 @@ void main()
gl_FragColor = effect(gl_Color, %s, gl_TexCoord[0].xy, gl_FragCoord.xy);
}
)";
+
+static const int SHADER_FORMAT_SIZE = strlen(base_shader) + strlen(default_tex) * 2;
+
#define formatShader(buf, program)\
sprintf(buf, base_shader, default_tex, program, default_tex)
-
-#define base_size (strlen(base_shader) + strlen(default_tex)*2)
-/*
- * https://stackoverflow.com/questions/10868958/what-does-sampler2d-store
- * The sampler2D is bound to a texture unit. The glUniform call binds it to texture
- * unit zero. The glActiveTexture call is only needed if you are going to use multiple
- * texture units (because GL_TEXTURE0 is the default anyway).
-*/ \ No newline at end of file