mirror of https://github.com/buggins/dlangui.git
gl scene fixes
This commit is contained in:
parent
6bcd2c0487
commit
cbd055d054
|
@ -256,6 +256,16 @@ private int nearestPOT(int n) {
|
||||||
return MIN_TEX_SIZE;
|
return MIN_TEX_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int correctTextureSize(int n) {
|
||||||
|
if (n < 16)
|
||||||
|
return 16;
|
||||||
|
version(POT_TEXTURE_SIZES) {
|
||||||
|
return nearestPOT(n);
|
||||||
|
} else {
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// object deletion listener callback function type
|
/// object deletion listener callback function type
|
||||||
void onObjectDestroyedCallback(uint pobject) {
|
void onObjectDestroyedCallback(uint pobject) {
|
||||||
glImageCache.onCachedObjectDeleted(pobject);
|
glImageCache.onCachedObjectDeleted(pobject);
|
||||||
|
@ -307,8 +317,8 @@ private abstract class GLCache
|
||||||
public:
|
public:
|
||||||
this(GLCache cache, int dx, int dy) {
|
this(GLCache cache, int dx, int dy) {
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
_tdx = nearestPOT(dx);
|
_tdx = correctTextureSize(dx);
|
||||||
_tdy = nearestPOT(dy);
|
_tdy = correctTextureSize(dy);
|
||||||
_itemCount = 0;
|
_itemCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,8 +826,8 @@ static class GLTexture {
|
||||||
if (buf) {
|
if (buf) {
|
||||||
_dx = buf.width;
|
_dx = buf.width;
|
||||||
_dy = buf.height;
|
_dy = buf.height;
|
||||||
_tdx = nearestPOT(_dx);
|
_tdx = correctTextureSize(_dx);
|
||||||
_tdy = nearestPOT(_dy);
|
_tdy = correctTextureSize(_dy);
|
||||||
_texture = new Tex2D();
|
_texture = new Tex2D();
|
||||||
if (!_texture.ID) {
|
if (!_texture.ID) {
|
||||||
_texture = null;
|
_texture = null;
|
||||||
|
|
|
@ -50,24 +50,18 @@ class Submesh {
|
||||||
arrayElement(_txcoords, index, 2, 0)[0..2] = v.vec[0..2];
|
arrayElement(_txcoords, index, 2, 0)[0..2] = v.vec[0..2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// add vertex data, returns index of added vertex
|
/// sets vertex data for specified vertex index, returns index of added vertex; pass index -1 to append vertex to end of list
|
||||||
void setVertex(int index, vec3 coord, vec3 normal, vec4 color, vec2 txcoord) {
|
int setVertex(int index, vec3 coord, vec3 normal, vec4 color, vec2 txcoord) {
|
||||||
|
if (index < 0)
|
||||||
|
index = _vertexCount;
|
||||||
setVertexCoord(index, coord);
|
setVertexCoord(index, coord);
|
||||||
setVertexNormal(index, normal);
|
setVertexNormal(index, normal);
|
||||||
setVertexColor(index, color);
|
setVertexColor(index, color);
|
||||||
setVertexTxCoord(index, txcoord);
|
setVertexTxCoord(index, txcoord);
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// add vertex data, returns index of added vertex
|
/// adds indexes for triangle
|
||||||
int addVertex(vec3 coord, vec3 normal, vec4 color, vec2 txcoord) {
|
|
||||||
_coords ~= coord.vec;
|
|
||||||
_normals ~= normal.vec;
|
|
||||||
_colors ~= color.vec;
|
|
||||||
_txcoords ~= txcoord.vec;
|
|
||||||
_vertexCount++;
|
|
||||||
return _vertexCount - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int addTriangleIndexes(int p1, int p2, int p3) {
|
int addTriangleIndexes(int p1, int p2, int p3) {
|
||||||
_indexes ~= p1;
|
_indexes ~= p1;
|
||||||
_indexes ~= p2;
|
_indexes ~= p2;
|
||||||
|
@ -76,4 +70,16 @@ class Submesh {
|
||||||
return _triangleCount - 1;
|
return _triangleCount - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// adds indexes for 2 triangles forming rectangle
|
||||||
|
int addRectangleIndexes(int p1, int p2, int p3, int p4) {
|
||||||
|
_indexes ~= p1;
|
||||||
|
_indexes ~= p2;
|
||||||
|
_indexes ~= p3;
|
||||||
|
_indexes ~= p3;
|
||||||
|
_indexes ~= p4;
|
||||||
|
_indexes ~= p1;
|
||||||
|
_triangleCount++;
|
||||||
|
_triangleCount++;
|
||||||
|
return _triangleCount - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue