aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Graphics')
-rw-r--r--src/libjin/Graphics/Bitmap.h6
-rw-r--r--src/libjin/Graphics/Canvas.cpp4
-rw-r--r--src/libjin/Graphics/Canvas.h10
-rw-r--r--src/libjin/Graphics/Color.h12
-rw-r--r--src/libjin/Graphics/Drawable.cpp4
-rw-r--r--src/libjin/Graphics/Drawable.h10
-rw-r--r--src/libjin/Graphics/Font.cpp4
-rw-r--r--src/libjin/Graphics/Font.h10
-rw-r--r--src/libjin/Graphics/Graphics.h10
-rw-r--r--src/libjin/Graphics/Shader.cpp27
-rw-r--r--src/libjin/Graphics/Shader.h10
-rw-r--r--src/libjin/Graphics/Shapes.cpp4
-rw-r--r--src/libjin/Graphics/Shapes.h10
-rw-r--r--src/libjin/Graphics/Texture.cpp4
-rw-r--r--src/libjin/Graphics/Texture.h10
-rw-r--r--src/libjin/Graphics/Window.cpp6
-rw-r--r--src/libjin/Graphics/Window.h10
17 files changed, 84 insertions, 67 deletions
diff --git a/src/libjin/Graphics/Bitmap.h b/src/libjin/Graphics/Bitmap.h
index 6333215..53b374b 100644
--- a/src/libjin/Graphics/Bitmap.h
+++ b/src/libjin/Graphics/Bitmap.h
@@ -1,7 +1,7 @@
-#ifndef __JIN_BITMAP_H
-#define __JIN_BITMAP_H
+#ifndef __LIBJIN_BITMAP_H
+#define __LIBJIN_BITMAP_H
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "../Math/Vector2.hpp"
#include "../3rdparty/GLee/GLee.h"
diff --git a/src/libjin/Graphics/Canvas.cpp b/src/libjin/Graphics/Canvas.cpp
index 953278d..1d1a347 100644
--- a/src/libjin/Graphics/Canvas.cpp
+++ b/src/libjin/Graphics/Canvas.cpp
@@ -1,5 +1,5 @@
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "../utils/macros.h"
#include "canvas.h"
@@ -118,4 +118,4 @@ namespace graphics
} // render
} // jin
-#endif // JIN_MODULES_RENDER \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
diff --git a/src/libjin/Graphics/Canvas.h b/src/libjin/Graphics/Canvas.h
index 508562d..ec94d28 100644
--- a/src/libjin/Graphics/Canvas.h
+++ b/src/libjin/Graphics/Canvas.h
@@ -1,7 +1,7 @@
-#ifndef __JIN_CANVAS_H
-#define __JIN_CANVAS_H
+#ifndef __LIBJIN_CANVAS_H
+#define __LIBJIN_CANVAS_H
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "drawable.h"
namespace jin
@@ -30,5 +30,5 @@ namespace graphics
} // render
} // jin
-#endif // JIN_MODULES_RENDER
-#endif // __JIN_CANVAS_H \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
+#endif // __LIBJIN_CANVAS_H
diff --git a/src/libjin/Graphics/Color.h b/src/libjin/Graphics/Color.h
index 786abde..e27c360 100644
--- a/src/libjin/Graphics/Color.h
+++ b/src/libjin/Graphics/Color.h
@@ -1,10 +1,10 @@
/**
* Some color operating here.
*/
-#ifndef __JIN_COLOR_H
-#define __JIN_COLOR_H
+#ifndef __LIBJIN_COLOR_H
+#define __LIBJIN_COLOR_H
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "../utils/endian.h"
@@ -44,7 +44,7 @@ namespace graphics
return !(r == c.r && g == c.g && b == c.b && a == c.a);
}
- #if JIN_BYTEORDER == JIN_BIG_ENDIAN
+ #if LIBJIN_BYTEORDER == LIBJIN_BIG_ENDIAN
unsigned char r, g, b, a;
#else
unsigned char a, b, g, r;
@@ -55,5 +55,5 @@ namespace graphics
} // render
} // jin
-#endif // JIN_MODULES_RENDER
-#endif // __JIN_COLOR_H \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
+#endif // __LIBJIN_COLOR_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Drawable.cpp b/src/libjin/Graphics/Drawable.cpp
index 53b4f85..fec0575 100644
--- a/src/libjin/Graphics/Drawable.cpp
+++ b/src/libjin/Graphics/Drawable.cpp
@@ -1,5 +1,5 @@
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "drawable.h"
#include "../math/matrix.h"
@@ -64,4 +64,4 @@ namespace graphics
} // render
} // jin
-#endif // JIN_MODULES_RENDER \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
diff --git a/src/libjin/Graphics/Drawable.h b/src/libjin/Graphics/Drawable.h
index 8bc528e..bd5dfc5 100644
--- a/src/libjin/Graphics/Drawable.h
+++ b/src/libjin/Graphics/Drawable.h
@@ -1,7 +1,7 @@
-#ifndef __JIN_DRAWABLE
-#define __JIN_DRAWABLE
+#ifndef __LIBJIN_DRAWABLE
+#define __LIBJIN_DRAWABLE
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "../math/Vector2.hpp"
#include "../3rdparty/GLee/GLee.h"
@@ -38,5 +38,5 @@ namespace graphics
} // render
} // jin
-#endif // JIN_MODULES_RENDER
-#endif // __JIN_DRAWABLE \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
+#endif // __LIBJIN_DRAWABLE \ No newline at end of file
diff --git a/src/libjin/Graphics/Font.cpp b/src/libjin/Graphics/Font.cpp
index 6be08e7..3bdc5ca 100644
--- a/src/libjin/Graphics/Font.cpp
+++ b/src/libjin/Graphics/Font.cpp
@@ -1,5 +1,5 @@
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "font.h"
#include <stdio.h>
@@ -181,4 +181,4 @@ namespace graphics
} // graphics
} // jin
-#endif // JIN_MODULES_RENDER \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/Graphics/Font.h b/src/libjin/Graphics/Font.h
index d805d1c..5435581 100644
--- a/src/libjin/Graphics/Font.h
+++ b/src/libjin/Graphics/Font.h
@@ -1,7 +1,7 @@
-#ifndef __JIN_FONT_H
-#define __JIN_FONT_H
+#ifndef __LIBJIN_FONT_H
+#define __LIBJIN_FONT_H
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "drawable.h"
#include "../3rdparty/stb/stb_truetype.h"
@@ -38,5 +38,5 @@ namespace graphics
} // graphics
} // jin
-#endif // JIN_MODULES_RENDER
-#endif // __JIN_FONT_H \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
+#endif // __LIBJIN_FONT_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Graphics.h b/src/libjin/Graphics/Graphics.h
index 9c4ed35..dfd6048 100644
--- a/src/libjin/Graphics/Graphics.h
+++ b/src/libjin/Graphics/Graphics.h
@@ -1,7 +1,7 @@
-#ifndef __JIN_GRAPHICS_H
-#define __JIN_GRAPHICS_H
+#ifndef __LIBJIN_GRAPHICS_H
+#define __LIBJIN_GRAPHICS_H
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "canvas.h"
#include "color.h"
@@ -12,5 +12,5 @@
#include "window.h"
#include "Bitmap.h"
-#endif // JIN_MODULES_RENDER
-#endif // __JIN_GRAPHICS_H \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
+#endif // __LIBJIN_GRAPHICS_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Shader.cpp b/src/libjin/Graphics/Shader.cpp
index f078648..ae64c7e 100644
--- a/src/libjin/Graphics/Shader.cpp
+++ b/src/libjin/Graphics/Shader.cpp
@@ -1,5 +1,5 @@
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "../utils/macros.h"
#include "Shader.h"
@@ -39,21 +39,38 @@ namespace graphics
JSLProgram* JSLProgram::createJSLProgram(const char* program)
{
- return new JSLProgram(program);
+ JSLProgram* jsl = nullptr;
+ try
+ {
+ jsl = new JSLProgram(program);
+ }
+ catch(...)
+ {
+ return nullptr;
+ }
+ return jsl;
}
JSLProgram::JSLProgram(const char* program)
: currentTextureUnit(DEFAULT_TEXTURE_UNIT)
{
- char* fs = (char*)calloc(1, strlen(program) + SHADER_FORMAT_SIZE);
+ int size = strlen(program) + SHADER_FORMAT_SIZE;
+ char* fs = (char*)alloca(size);
+ memset(fs, 0, size);
formatShader(fs, program);
GLuint shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(shader, 1, (const GLchar**)&fs, NULL);
glCompileShader(shader);
+ GLint success;
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
+ if (success == GL_FALSE)
+ throw 0;
pid = glCreateProgram();
glAttachShader(pid, shader);
glLinkProgram(pid);
- free(fs);
+ glGetProgramiv(pid, GL_LINK_STATUS, &success);
+ if (success == GL_FALSE)
+ throw 0;
}
JSLProgram::~JSLProgram()
@@ -197,4 +214,4 @@ namespace graphics
} // graphics
} // jin
-#endif // JIN_MODULES_RENDER \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/Graphics/Shader.h b/src/libjin/Graphics/Shader.h
index 2e6ae16..db6126f 100644
--- a/src/libjin/Graphics/Shader.h
+++ b/src/libjin/Graphics/Shader.h
@@ -1,7 +1,7 @@
-#ifndef __JIN_JSL_H
-#define __JIN_JSL_H
+#ifndef __LIBJIN_JSL_H
+#define __LIBJIN_JSL_H
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include <string>
#include <map>
@@ -49,5 +49,5 @@ namespace graphics
} // graphics
} // jin
-#endif // JIN_MODULES_RENDER
-#endif // __JIN_JSL_H \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
+#endif // __LIBJIN_JSL_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Shapes.cpp b/src/libjin/Graphics/Shapes.cpp
index b2ef3f8..4601375 100644
--- a/src/libjin/Graphics/Shapes.cpp
+++ b/src/libjin/Graphics/Shapes.cpp
@@ -1,5 +1,5 @@
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "Shapes.h"
#include "../math/matrix.h"
@@ -119,4 +119,4 @@ namespace graphics
} // graphics
} // jin
-#endif // JIN_MODULES_RENDER \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/Graphics/Shapes.h b/src/libjin/Graphics/Shapes.h
index 204339f..dc9f272 100644
--- a/src/libjin/Graphics/Shapes.h
+++ b/src/libjin/Graphics/Shapes.h
@@ -1,7 +1,7 @@
-#ifndef __JIN_GEOMETRY_H
-#define __JIN_GEOMETRY_H
+#ifndef __LIBJIN_GEOMETRY_H
+#define __LIBJIN_GEOMETRY_H
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "color.h"
#include "canvas.h"
@@ -33,5 +33,5 @@ namespace graphics
} // graphics
} // jin
-#endif // JIN_MODULES_RENDER
-#endif // __JIN_GEOMETRY_H \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
+#endif // __LIBJIN_GEOMETRY_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Texture.cpp b/src/libjin/Graphics/Texture.cpp
index 2095af4..9958935 100644
--- a/src/libjin/Graphics/Texture.cpp
+++ b/src/libjin/Graphics/Texture.cpp
@@ -1,5 +1,5 @@
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include <fstream>
#include "texture.h"
@@ -53,4 +53,4 @@ namespace graphics
} // graphics
} // jin
-#endif // JIN_MODULES_RENDER \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/Graphics/Texture.h b/src/libjin/Graphics/Texture.h
index 2586d63..f2e45f0 100644
--- a/src/libjin/Graphics/Texture.h
+++ b/src/libjin/Graphics/Texture.h
@@ -1,7 +1,7 @@
-#ifndef __JIN_IMAGE_H
-#define __JIN_IMAGE_H
+#ifndef __LIBJIN_IMAGE_H
+#define __LIBJIN_IMAGE_H
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "../3rdparty/GLee/GLee.h"
#include "Color.h"
@@ -27,5 +27,5 @@ namespace graphics
} // graphics
} // jin
-#endif // JIN_MODULES_RENDER
-#endif // __JIN_IMAGE_H \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
+#endif // __LIBJIN_IMAGE_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Window.cpp b/src/libjin/Graphics/Window.cpp
index 3eb76ad..e5f32ba 100644
--- a/src/libjin/Graphics/Window.cpp
+++ b/src/libjin/Graphics/Window.cpp
@@ -1,5 +1,5 @@
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include <iostream>
#include "window.h"
@@ -16,7 +16,7 @@ namespace graphics
bool Window::initSystem(const SettingBase* s)
{
-#if JIN_DEBUG
+#if LIBJIN_DEBUG
Loghelper::log(Loglevel::LV_INFO, "Init window system");
#endif
@@ -99,4 +99,4 @@ namespace graphics
} // graphics
} // jin
-#endif // JIN_MODULES_RENDER \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
diff --git a/src/libjin/Graphics/Window.h b/src/libjin/Graphics/Window.h
index 2ecd7e4..0d18365 100644
--- a/src/libjin/Graphics/Window.h
+++ b/src/libjin/Graphics/Window.h
@@ -1,7 +1,7 @@
-#ifndef __JIN_RENDER_WINDOW
-#define __JIN_RENDER_WINDOW
+#ifndef __LIBJIN_RENDER_WINDOW
+#define __LIBJIN_RENDER_WINDOW
#include "../modules.h"
-#if JIN_MODULES_RENDER
+#if LIBJIN_MODULES_RENDER
#include "SDL2/SDL.h"
#include "../utils/utils.h"
@@ -49,5 +49,5 @@ namespace graphics
} // render
} // jin
-#endif // JIN_MODULES_RENDER
-#endif // __JIN_RENDER_WINDOW \ No newline at end of file
+#endif // LIBJIN_MODULES_RENDER
+#endif // __LIBJIN_RENDER_WINDOW \ No newline at end of file