mirror of https://github.com/buggins/dlangui.git
fixes for #183
This commit is contained in:
parent
84c9dc4e4e
commit
698e3bc36e
|
|
@ -19,18 +19,24 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
module dlangui.graphics.glsupport;
|
module dlangui.graphics.glsupport;
|
||||||
|
|
||||||
public import dlangui.core.config;
|
public import dlangui.core.config;
|
||||||
|
|
||||||
static if (ENABLE_OPENGL):
|
static if (ENABLE_OPENGL):
|
||||||
|
|
||||||
public import dlangui.core.math3d;
|
public import dlangui.core.math3d;
|
||||||
import dlangui.graphics.scene.mesh;
|
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
import derelict.opengl3.gl;
|
|
||||||
import dlangui.core.types;
|
import dlangui.core.types;
|
||||||
|
|
||||||
import std.conv;
|
import std.conv;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.array;
|
import std.array;
|
||||||
|
|
||||||
|
public import derelict.opengl3.types;
|
||||||
|
public import derelict.opengl3.gl3;
|
||||||
|
public import derelict.opengl3.gl;
|
||||||
|
|
||||||
|
import dlangui.graphics.scene.mesh;
|
||||||
|
import dlangui.graphics.scene.effect;
|
||||||
|
|
||||||
derelict.util.exception.ShouldThrow gl3MissingSymFunc( string symName ) {
|
derelict.util.exception.ShouldThrow gl3MissingSymFunc( string symName ) {
|
||||||
import std.algorithm : equal;
|
import std.algorithm : equal;
|
||||||
foreach(s; ["glGetError", "glShaderSource", "glCompileShader",
|
foreach(s; ["glGetError", "glShaderSource", "glCompileShader",
|
||||||
|
|
@ -112,7 +118,7 @@ string glerrorToString(in GLenum err) pure nothrow {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class GLProgram : GraphicsEffect {
|
class GLProgram : dlangui.graphics.scene.effect.GraphicsEffect {
|
||||||
@property abstract string vertexSource();
|
@property abstract string vertexSource();
|
||||||
@property abstract string fragmentSource();
|
@property abstract string fragmentSource();
|
||||||
protected GLuint program;
|
protected GLuint program;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,22 @@ import dlangui.graphics.glsupport;
|
||||||
import dlangui.graphics.gldrawbuf;
|
import dlangui.graphics.gldrawbuf;
|
||||||
import dlangui.graphics.scene.mesh;
|
import dlangui.graphics.scene.mesh;
|
||||||
|
|
||||||
|
/// Base class for graphics effect / program - e.g. for OpenGL shader program
|
||||||
|
abstract class GraphicsEffect : RefCountedObject {
|
||||||
|
/// get location for vertex attribute
|
||||||
|
int getVertexElementLocation(VertexElementType type);
|
||||||
|
|
||||||
|
void setUniform(string uniformName, mat4 matrix);
|
||||||
|
|
||||||
|
void setUniform(string uniformName, vec2 vec);
|
||||||
|
|
||||||
|
void setUniform(string uniformName, vec3 vec);
|
||||||
|
|
||||||
|
void setUniform(string uniformName, vec4 vec);
|
||||||
|
|
||||||
|
void draw(Mesh mesh);
|
||||||
|
}
|
||||||
|
|
||||||
/// Reference counted Effect object
|
/// Reference counted Effect object
|
||||||
alias EffectRef = Ref!Effect;
|
alias EffectRef = Ref!Effect;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
module dlangui.graphics.scene.mesh;
|
module dlangui.graphics.scene.mesh;
|
||||||
|
|
||||||
import dlangui.graphics.scene.material;
|
|
||||||
import dlangui.core.math3d;
|
import dlangui.core.math3d;
|
||||||
import dlangui.core.types;
|
import dlangui.core.types;
|
||||||
|
//import dlangui.graphics.scene.material;
|
||||||
|
import dlangui.graphics.scene.effect;
|
||||||
|
|
||||||
/// Reference counted Mesh object
|
/// Reference counted Mesh object
|
||||||
alias MeshRef = Ref!Mesh;
|
alias MeshRef = Ref!Mesh;
|
||||||
|
|
@ -46,22 +47,6 @@ class VertexBuffer {
|
||||||
/// location for element is not found
|
/// location for element is not found
|
||||||
enum VERTEX_ELEMENT_NOT_FOUND = -1;
|
enum VERTEX_ELEMENT_NOT_FOUND = -1;
|
||||||
|
|
||||||
/// Base class for graphics effect / program - e.g. for OpenGL shader program
|
|
||||||
abstract class GraphicsEffect : RefCountedObject {
|
|
||||||
/// get location for vertex attribute
|
|
||||||
int getVertexElementLocation(VertexElementType type);
|
|
||||||
|
|
||||||
void setUniform(string uniformName, mat4 matrix);
|
|
||||||
|
|
||||||
void setUniform(string uniformName, vec2 vec);
|
|
||||||
|
|
||||||
void setUniform(string uniformName, vec3 vec);
|
|
||||||
|
|
||||||
void setUniform(string uniformName, vec4 vec);
|
|
||||||
|
|
||||||
void draw(Mesh mesh);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// vertex attribute properties
|
/// vertex attribute properties
|
||||||
struct VertexElement {
|
struct VertexElement {
|
||||||
private VertexElementType _type;
|
private VertexElementType _type;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue