mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-25 22:17:59 +07:00
Cleanup of some GL stuff
This commit is contained in:
parent
771c2270df
commit
22905de094
@ -4680,7 +4680,7 @@ public class Blocks{
|
||||
forceDark = true;
|
||||
privileged = true;
|
||||
size = 1;
|
||||
maxInstructionsPerTick = 50;
|
||||
maxInstructionsPerTick = 100;
|
||||
}};
|
||||
|
||||
worldCell = new MemoryBlock("world-cell"){{
|
||||
|
@ -169,17 +169,23 @@ public class FloorRenderer{
|
||||
//only ever use the base environment texture
|
||||
texture.bind(0);
|
||||
|
||||
//enable all mesh attributes
|
||||
for(VertexAttribute attribute : attributes){
|
||||
shader.enableVertexAttribute(attribute.alias);
|
||||
//enable all mesh attributes; TODO remove once the attribute cache bug is fixed
|
||||
if(Core.gl30 == null){
|
||||
for(VertexAttribute attribute : attributes){
|
||||
int loc = shader.getAttributeLocation(attribute.alias);
|
||||
if(loc != -1) Gl.enableVertexAttribArray(loc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void endc(){
|
||||
|
||||
//disable all mesh attributes
|
||||
for(VertexAttribute attribute : attributes){
|
||||
shader.disableVertexAttribute(attribute.alias);
|
||||
//disable all mesh attributes; TODO remove once the attribute cache bug is fixed
|
||||
if(Core.gl30 == null){
|
||||
for(VertexAttribute attribute : attributes){
|
||||
int loc = shader.getAttributeLocation(attribute.alias);
|
||||
if(loc != -1) Gl.disableVertexAttribArray(loc);
|
||||
}
|
||||
}
|
||||
|
||||
//unbind last buffer
|
||||
@ -244,30 +250,29 @@ public class FloorRenderer{
|
||||
|
||||
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
|
||||
if(mesh.vertices instanceof VertexBufferObject vbo && mesh.indices instanceof IndexBufferObject ibo){
|
||||
//bindi the buffer and update its contents, but do not unnecessarily enable all the attributes again
|
||||
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
|
||||
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.");
|
||||
Gl.vertexAttribPointer(location, attribute.components, attribute.type, attribute.normalized, vertexSize * 4, aoffset);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
Mesh mesh = new Mesh(true, vertCount, indCount, attributes);
|
||||
mesh.setAutoBind(false);
|
||||
mesh.setVertices(vertices, 0, vidx);
|
||||
mesh.setAutoBind(false);
|
||||
mesh.setIndices(indices, 0, indCount);
|
||||
|
||||
return mesh;
|
||||
@ -372,8 +377,6 @@ public class FloorRenderer{
|
||||
|
||||
texture = Core.atlas.find("grass1").texture;
|
||||
error = Core.atlas.find("env-error");
|
||||
//not supported due to internal access
|
||||
Mesh.useVAO = false;
|
||||
|
||||
//pre-cache chunks
|
||||
if(!dynamic){
|
||||
|
@ -1217,29 +1217,10 @@ public class UnitType extends UnlockableContent{
|
||||
}
|
||||
|
||||
public void drawEngines(Unit unit){
|
||||
float scale = useEngineElevation ? unit.elevation : 1f;
|
||||
|
||||
if(scale <= 0.0001f) return;
|
||||
|
||||
float rot = unit.rotation - 90;
|
||||
Color color = engineColor == null ? unit.team.color : engineColor;
|
||||
if((useEngineElevation ? unit.elevation : 1f) <= 0.0001f) return;
|
||||
|
||||
for(var engine : engines){
|
||||
Tmp.v1.set(engine.x, engine.y).rotate(rot);
|
||||
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
|
||||
);
|
||||
engine.draw(unit);
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
@ -1501,6 +1482,32 @@ public class UnitType extends UnlockableContent{
|
||||
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(){
|
||||
try{
|
||||
return (UnitEngine)clone();
|
||||
|
@ -25,4 +25,4 @@ org.gradle.caching=true
|
||||
#used for slow jitpack builds; TODO see if this actually works
|
||||
org.gradle.internal.http.socketTimeout=100000
|
||||
org.gradle.internal.http.connectionTimeout=100000
|
||||
archash=f0f5a42492
|
||||
archash=f77ad872f8
|
||||
|
Loading…
Reference in New Issue
Block a user