mirror of https://github.com/buggins/dlangui.git
fixes for #183
This commit is contained in:
parent
b3da543c8c
commit
cccdc605ce
|
@ -174,7 +174,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>EmbedStandardResources ForceLogs</versionids>
|
<versionids>EmbedStandardResources ForceLogs USE_OPENGL</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>0</mapverbosity>
|
<mapverbosity>0</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
|
@ -480,7 +480,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>EmbedStandardResources ForceLogs</versionids>
|
<versionids>EmbedStandardResources ForceLogs USE_OPENGL</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>0</mapverbosity>
|
<mapverbosity>0</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
|
@ -779,8 +779,8 @@
|
||||||
<File path="src\dlangui\graphics\scene\transform.d" />
|
<File path="src\dlangui\graphics\scene\transform.d" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder name="xpm">
|
<Folder name="xpm">
|
||||||
<File path="src\dlangui\graphics\xpm\xpmcolors.d" />
|
|
||||||
<File path="src\dlangui\graphics\xpm\reader.d" />
|
<File path="src\dlangui\graphics\xpm\reader.d" />
|
||||||
|
<File path="src\dlangui\graphics\xpm\xpmcolors.d" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<File path="src\dlangui\graphics\colors.d" />
|
<File path="src\dlangui\graphics\colors.d" />
|
||||||
<File path="src\dlangui\graphics\domrender.d" />
|
<File path="src\dlangui\graphics\domrender.d" />
|
||||||
|
|
|
@ -174,7 +174,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids> EmbedStandardResources</versionids>
|
<versionids> EmbedStandardResources USE_OPENGL</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>0</mapverbosity>
|
<mapverbosity>0</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
|
@ -378,7 +378,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids> EmbedStandardResources</versionids>
|
<versionids> EmbedStandardResources USE_OPENGL</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>0</mapverbosity>
|
<mapverbosity>0</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
|
|
|
@ -793,6 +793,7 @@ public:
|
||||||
|
|
||||||
/// GL Texture object from image
|
/// GL Texture object from image
|
||||||
static class GLTexture {
|
static class GLTexture {
|
||||||
|
protected string _resourceId;
|
||||||
protected int _dx;
|
protected int _dx;
|
||||||
protected int _dy;
|
protected int _dy;
|
||||||
protected int _tdx;
|
protected int _tdx;
|
||||||
|
@ -831,6 +832,7 @@ static class GLTexture {
|
||||||
|
|
||||||
this(string resourceId) {
|
this(string resourceId) {
|
||||||
import dlangui.graphics.resources;
|
import dlangui.graphics.resources;
|
||||||
|
_resourceId = resourceId;
|
||||||
string path = drawableCache.findResource(resourceId);
|
string path = drawableCache.findResource(resourceId);
|
||||||
this(cast(ColorDrawBuf)imageCache.get(path));
|
this(cast(ColorDrawBuf)imageCache.get(path));
|
||||||
}
|
}
|
||||||
|
@ -859,9 +861,40 @@ static class GLTexture {
|
||||||
}
|
}
|
||||||
|
|
||||||
~this() {
|
~this() {
|
||||||
|
import std.string : empty;
|
||||||
|
if (!_resourceId.empty)
|
||||||
|
GLTextureCache.instance.onItemRemoved(_resourceId);
|
||||||
if (_texture && _texture.ID != 0) {
|
if (_texture && _texture.ID != 0) {
|
||||||
destroy(_texture);
|
destroy(_texture);
|
||||||
_texture = null;
|
_texture = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Cache for GLTexture
|
||||||
|
class GLTextureCache {
|
||||||
|
protected GLTexture[string] _map;
|
||||||
|
|
||||||
|
static __gshared GLTextureCache _instance;
|
||||||
|
|
||||||
|
static @property GLTextureCache instance() {
|
||||||
|
if (!_instance)
|
||||||
|
_instance = new GLTextureCache();
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onItemRemoved(string resourceId) {
|
||||||
|
if (resourceId in _map) {
|
||||||
|
_map.remove(resourceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GLTexture get(string resourceId) {
|
||||||
|
if (auto p = resourceId in _map) {
|
||||||
|
return *p;
|
||||||
|
}
|
||||||
|
GLTexture tx = new GLTexture(resourceId);
|
||||||
|
_map[resourceId] = tx;
|
||||||
|
return tx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -25,8 +25,9 @@ static if (ENABLE_OPENGL):
|
||||||
public import dlangui.core.math3d;
|
public import dlangui.core.math3d;
|
||||||
import dlangui.graphics.scene.mesh;
|
import dlangui.graphics.scene.mesh;
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
import derelict.opengl3.gl3;
|
//import derelict.opengl3.gl3;
|
||||||
import derelict.opengl3.gl;
|
import derelict.opengl3.gl;
|
||||||
|
//import derelict.opengl3.types;
|
||||||
import dlangui.core.types;
|
import dlangui.core.types;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
import std.string;
|
import std.string;
|
||||||
|
@ -114,6 +115,7 @@ string glerrorToString(in GLenum err) pure nothrow {
|
||||||
|
|
||||||
|
|
||||||
class GLProgram : GraphicsEffect {
|
class GLProgram : GraphicsEffect {
|
||||||
|
import derelict.opengl3.types;
|
||||||
@property abstract string vertexSource();
|
@property abstract string vertexSource();
|
||||||
@property abstract string fragmentSource();
|
@property abstract string fragmentSource();
|
||||||
protected GLuint program;
|
protected GLuint program;
|
||||||
|
|
|
@ -1,4 +1,23 @@
|
||||||
module dlangui.graphics.scene.material;
|
module dlangui.graphics.scene.material;
|
||||||
|
|
||||||
class Material {
|
public import dlangui.core.config;
|
||||||
|
|
||||||
|
import dlangui.core.types;
|
||||||
|
import dlangui.core.logger;
|
||||||
|
import dlangui.graphics.glsupport;
|
||||||
|
import dlangui.graphics.gldrawbuf;
|
||||||
|
import dlangui.graphics.scene.effect;
|
||||||
|
|
||||||
|
/// Reference counted Material object
|
||||||
|
alias MaterialRef = Ref!Material;
|
||||||
|
|
||||||
|
class Material : RefCountedObject {
|
||||||
|
protected EffectRef _effect;
|
||||||
|
protected GLTexture _texture;
|
||||||
|
|
||||||
|
@property EffectRef effect() { return _effect; }
|
||||||
|
@property Material effect(EffectRef e) {
|
||||||
|
_effect = e;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ import dlangui.graphics.scene.material;
|
||||||
import dlangui.core.math3d;
|
import dlangui.core.math3d;
|
||||||
import dlangui.core.types;
|
import dlangui.core.types;
|
||||||
|
|
||||||
|
/// Reference counted Mesh object
|
||||||
|
alias MeshRef = Ref!Mesh;
|
||||||
|
|
||||||
/// vertex element type
|
/// vertex element type
|
||||||
enum VertexElementType : ubyte {
|
enum VertexElementType : ubyte {
|
||||||
POSITION = 1,
|
POSITION = 1,
|
||||||
|
@ -157,7 +160,7 @@ struct IndexFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mesh
|
/// Mesh
|
||||||
class Mesh {
|
class Mesh : RefCountedObject {
|
||||||
protected VertexFormat _vertexFormat;
|
protected VertexFormat _vertexFormat;
|
||||||
protected int _vertexCount;
|
protected int _vertexCount;
|
||||||
protected float[] _vertexData;
|
protected float[] _vertexData;
|
||||||
|
|
Loading…
Reference in New Issue