Cleanup of some GL stuff
This commit is contained in:
@@ -4680,7 +4680,7 @@ public class Blocks{
|
|||||||
forceDark = true;
|
forceDark = true;
|
||||||
privileged = true;
|
privileged = true;
|
||||||
size = 1;
|
size = 1;
|
||||||
maxInstructionsPerTick = 50;
|
maxInstructionsPerTick = 100;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
worldCell = new MemoryBlock("world-cell"){{
|
worldCell = new MemoryBlock("world-cell"){{
|
||||||
|
|||||||
@@ -169,17 +169,23 @@ public class FloorRenderer{
|
|||||||
//only ever use the base environment texture
|
//only ever use the base environment texture
|
||||||
texture.bind(0);
|
texture.bind(0);
|
||||||
|
|
||||||
//enable all mesh attributes
|
//enable all mesh attributes; TODO remove once the attribute cache bug is fixed
|
||||||
for(VertexAttribute attribute : attributes){
|
if(Core.gl30 == null){
|
||||||
shader.enableVertexAttribute(attribute.alias);
|
for(VertexAttribute attribute : attributes){
|
||||||
|
int loc = shader.getAttributeLocation(attribute.alias);
|
||||||
|
if(loc != -1) Gl.enableVertexAttribArray(loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endc(){
|
public void endc(){
|
||||||
|
//disable all mesh attributes; TODO remove once the attribute cache bug is fixed
|
||||||
//disable all mesh attributes
|
if(Core.gl30 == null){
|
||||||
for(VertexAttribute attribute : attributes){
|
for(VertexAttribute attribute : attributes){
|
||||||
shader.disableVertexAttribute(attribute.alias);
|
int loc = shader.getAttributeLocation(attribute.alias);
|
||||||
|
if(loc != -1) Gl.disableVertexAttribArray(loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//unbind last buffer
|
//unbind last buffer
|
||||||
@@ -244,30 +250,29 @@ public class FloorRenderer{
|
|||||||
|
|
||||||
var mesh = cache[x][y][layer.id];
|
var mesh = cache[x][y][layer.id];
|
||||||
|
|
||||||
if(mesh != null){
|
//this *must* be a vertexbufferobject on gles2, so cast it and render it directly
|
||||||
|
if(mesh != null && mesh.vertices instanceof VertexBufferObject vbo && mesh.indices instanceof IndexBufferObject ibo){
|
||||||
|
|
||||||
//this *must* be a vertexbufferobject, so cast it and render it directly
|
//bindi the buffer and update its contents, but do not unnecessarily enable all the attributes again
|
||||||
if(mesh.vertices instanceof VertexBufferObject vbo && mesh.indices instanceof IndexBufferObject ibo){
|
vbo.bind();
|
||||||
|
//set up vertex attribute pointers for this specific VBO
|
||||||
|
int offset = 0;
|
||||||
|
for(VertexAttribute attribute : attributes){
|
||||||
|
int location = shader.getAttributeLocation(attribute.alias);
|
||||||
|
int aoffset = offset;
|
||||||
|
offset += attribute.size;
|
||||||
|
if(location < 0) continue;
|
||||||
|
|
||||||
//bindi the buffer and update its contents, but do not unnecessarily enable all the attributes again
|
Gl.vertexAttribPointer(location, attribute.components, attribute.type, attribute.normalized, vertexSize * 4, aoffset);
|
||||||
vbo.bind();
|
|
||||||
//set up vertex attribute pointers for this specific VBO
|
|
||||||
int offset = 0;
|
|
||||||
for(VertexAttribute attribute : attributes){
|
|
||||||
int location = shader.getAttributeLocation(attribute.alias);
|
|
||||||
int aoffset = offset;
|
|
||||||
offset += attribute.size;
|
|
||||||
if(location < 0) continue;
|
|
||||||
|
|
||||||
shader.setVertexAttribute(location, attribute.components, attribute.type, attribute.normalized, vertexSize * 4, aoffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
ibo.bind();
|
|
||||||
|
|
||||||
mesh.vertices.render(mesh.indices, Gl.triangles, 0, mesh.getNumIndices());
|
|
||||||
}else{
|
|
||||||
throw new ArcRuntimeException("Non-VBO meshes are not supported for caches.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ibo.bind();
|
||||||
|
|
||||||
|
mesh.vertices.render(mesh.indices, Gl.triangles, 0, mesh.getNumIndices());
|
||||||
|
}else if(mesh != null){
|
||||||
|
//TODO this should be the default branch!
|
||||||
|
mesh.bind(shader);
|
||||||
|
mesh.render(shader, Gl.triangles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,8 +350,8 @@ public class FloorRenderer{
|
|||||||
int vertCount = floats / vertexSize, indCount = vertCount * 6/4;
|
int vertCount = floats / vertexSize, indCount = vertCount * 6/4;
|
||||||
|
|
||||||
Mesh mesh = new Mesh(true, vertCount, indCount, attributes);
|
Mesh mesh = new Mesh(true, vertCount, indCount, attributes);
|
||||||
mesh.setAutoBind(false);
|
|
||||||
mesh.setVertices(vertices, 0, vidx);
|
mesh.setVertices(vertices, 0, vidx);
|
||||||
|
mesh.setAutoBind(false);
|
||||||
mesh.setIndices(indices, 0, indCount);
|
mesh.setIndices(indices, 0, indCount);
|
||||||
|
|
||||||
return mesh;
|
return mesh;
|
||||||
@@ -372,8 +377,6 @@ public class FloorRenderer{
|
|||||||
|
|
||||||
texture = Core.atlas.find("grass1").texture;
|
texture = Core.atlas.find("grass1").texture;
|
||||||
error = Core.atlas.find("env-error");
|
error = Core.atlas.find("env-error");
|
||||||
//not supported due to internal access
|
|
||||||
Mesh.useVAO = false;
|
|
||||||
|
|
||||||
//pre-cache chunks
|
//pre-cache chunks
|
||||||
if(!dynamic){
|
if(!dynamic){
|
||||||
|
|||||||
@@ -1217,29 +1217,10 @@ public class UnitType extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawEngines(Unit unit){
|
public void drawEngines(Unit unit){
|
||||||
float scale = useEngineElevation ? unit.elevation : 1f;
|
if((useEngineElevation ? unit.elevation : 1f) <= 0.0001f) return;
|
||||||
|
|
||||||
if(scale <= 0.0001f) return;
|
|
||||||
|
|
||||||
float rot = unit.rotation - 90;
|
|
||||||
Color color = engineColor == null ? unit.team.color : engineColor;
|
|
||||||
|
|
||||||
for(var engine : engines){
|
for(var engine : engines){
|
||||||
Tmp.v1.set(engine.x, engine.y).rotate(rot);
|
engine.draw(unit);
|
||||||
float ex = Tmp.v1.x, ey = Tmp.v1.y;
|
|
||||||
|
|
||||||
Draw.color(color);
|
|
||||||
Fill.circle(
|
|
||||||
unit.x + ex,
|
|
||||||
unit.y + ey,
|
|
||||||
(engine.radius + Mathf.absin(Time.time, 2f, engine.radius / 4f)) * scale
|
|
||||||
);
|
|
||||||
Draw.color(engineColorInner);
|
|
||||||
Fill.circle(
|
|
||||||
unit.x + ex - Angles.trnsx(rot + engine.rotation, 1f),
|
|
||||||
unit.y + ey - Angles.trnsy(rot + engine.rotation, 1f),
|
|
||||||
(engine.radius + Mathf.absin(Time.time, 2f, engine.radius / 4f)) / 2f * scale
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.color();
|
Draw.color();
|
||||||
@@ -1501,6 +1482,32 @@ public class UnitType extends UnlockableContent{
|
|||||||
public UnitEngine(){
|
public UnitEngine(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void draw(Unit unit){
|
||||||
|
UnitType type = unit.type;
|
||||||
|
float scale = type.useEngineElevation ? unit.elevation : 1f;
|
||||||
|
|
||||||
|
if(scale <= 0.0001f) return;
|
||||||
|
|
||||||
|
float rot = unit.rotation - 90;
|
||||||
|
Color color = type.engineColor == null ? unit.team.color : type.engineColor;
|
||||||
|
|
||||||
|
Tmp.v1.set(x, y).rotate(rot);
|
||||||
|
float ex = Tmp.v1.x, ey = Tmp.v1.y;
|
||||||
|
|
||||||
|
Draw.color(color);
|
||||||
|
Fill.circle(
|
||||||
|
unit.x + ex,
|
||||||
|
unit.y + ey,
|
||||||
|
(radius + Mathf.absin(Time.time, 2f, radius / 4f)) * scale
|
||||||
|
);
|
||||||
|
Draw.color(type.engineColorInner);
|
||||||
|
Fill.circle(
|
||||||
|
unit.x + ex - Angles.trnsx(rot + rotation, 1f),
|
||||||
|
unit.y + ey - Angles.trnsy(rot + rotation, 1f),
|
||||||
|
(radius + Mathf.absin(Time.time, 2f, radius / 4f)) / 2f * scale
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public UnitEngine copy(){
|
public UnitEngine copy(){
|
||||||
try{
|
try{
|
||||||
return (UnitEngine)clone();
|
return (UnitEngine)clone();
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ org.gradle.caching=true
|
|||||||
#used for slow jitpack builds; TODO see if this actually works
|
#used for slow jitpack builds; TODO see if this actually works
|
||||||
org.gradle.internal.http.socketTimeout=100000
|
org.gradle.internal.http.socketTimeout=100000
|
||||||
org.gradle.internal.http.connectionTimeout=100000
|
org.gradle.internal.http.connectionTimeout=100000
|
||||||
archash=f0f5a42492
|
archash=f77ad872f8
|
||||||
|
|||||||
Reference in New Issue
Block a user