update RenderContext
This commit is contained in:
parent
f623a1f883
commit
b324663f10
|
@ -13,20 +13,19 @@ import com.badlogic.gdx.utils.Disposable;
|
||||||
|
|
||||||
public class RenderContext implements Disposable {
|
public class RenderContext implements Disposable {
|
||||||
public final ExtendedSpriteBatch spriteBatch;
|
public final ExtendedSpriteBatch spriteBatch;
|
||||||
public final DecalBatch decalBatch;
|
|
||||||
public final BillboardSpriteBatch billboardSpriteBatch;
|
public final BillboardSpriteBatch billboardSpriteBatch;
|
||||||
public final ShapeRenderer debugGeometryRenderer;
|
public final ShapeRenderer debugGeometryRenderer;
|
||||||
public final ModelBatch modelBatch;
|
public final ModelBatch modelBatch;
|
||||||
public final ScreenPixelScaler pixelScaler;
|
public final ScreenPixelScaler pixelScaler;
|
||||||
public final SolidColorTextureCache solidColorTextures;
|
public final SolidColorTextureCache solidColorTextures;
|
||||||
|
|
||||||
AlphaTestCameraGroupStrategy cameraGroupStrategy;
|
|
||||||
Camera perspectiveCamera;
|
Camera perspectiveCamera;
|
||||||
OrthographicCamera orthographicCamera;
|
OrthographicCamera orthographicCamera;
|
||||||
|
|
||||||
public RenderContext(boolean use2dPixelScaling) {
|
public RenderContext(boolean use2dPixelScaling) {
|
||||||
Gdx.app.debug("RenderContext", "ctor");
|
Gdx.app.debug("RenderContext", "ctor");
|
||||||
spriteBatch = new ExtendedSpriteBatch();
|
spriteBatch = new ExtendedSpriteBatch();
|
||||||
|
billboardSpriteBatch = new BillboardSpriteBatch();
|
||||||
debugGeometryRenderer = new ShapeRenderer();
|
debugGeometryRenderer = new ShapeRenderer();
|
||||||
modelBatch = new ModelBatch();
|
modelBatch = new ModelBatch();
|
||||||
solidColorTextures = new SolidColorTextureCache();
|
solidColorTextures = new SolidColorTextureCache();
|
||||||
|
@ -39,10 +38,6 @@ public class RenderContext implements Disposable {
|
||||||
orthographicCamera = new OrthographicCamera(pixelScaler.getScaledWidth(), pixelScaler.getScaledHeight());
|
orthographicCamera = new OrthographicCamera(pixelScaler.getScaledWidth(), pixelScaler.getScaledHeight());
|
||||||
|
|
||||||
setDefaultPerspectiveCamera();
|
setDefaultPerspectiveCamera();
|
||||||
|
|
||||||
cameraGroupStrategy = new AlphaTestCameraGroupStrategy(perspectiveCamera);
|
|
||||||
decalBatch = new DecalBatch(cameraGroupStrategy);
|
|
||||||
billboardSpriteBatch = new BillboardSpriteBatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Camera getPerspectiveCamera() {
|
public Camera getPerspectiveCamera() {
|
||||||
|
@ -55,8 +50,6 @@ public class RenderContext implements Disposable {
|
||||||
|
|
||||||
public void setPerspectiveCamera(Camera camera) {
|
public void setPerspectiveCamera(Camera camera) {
|
||||||
perspectiveCamera = camera;
|
perspectiveCamera = camera;
|
||||||
if (cameraGroupStrategy != null)
|
|
||||||
cameraGroupStrategy.setCamera(camera);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultPerspectiveCamera() {
|
public void setDefaultPerspectiveCamera() {
|
||||||
|
@ -82,11 +75,9 @@ public class RenderContext implements Disposable {
|
||||||
spriteBatch.setProjectionMatrix(orthographicCamera.combined);
|
spriteBatch.setProjectionMatrix(orthographicCamera.combined);
|
||||||
spriteBatch.setPixelScale(pixelScaler.getScale());
|
spriteBatch.setPixelScale(pixelScaler.getScale());
|
||||||
debugGeometryRenderer.setProjectionMatrix(perspectiveCamera.combined);
|
debugGeometryRenderer.setProjectionMatrix(perspectiveCamera.combined);
|
||||||
billboardSpriteBatch.begin(decalBatch, perspectiveCamera);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPostRender() {
|
public void onPostRender() {
|
||||||
billboardSpriteBatch.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate(float delta) {
|
public void onUpdate(float delta) {
|
||||||
|
@ -116,8 +107,7 @@ public class RenderContext implements Disposable {
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
Gdx.app.debug("RenderContext", String.format("dispose"));
|
Gdx.app.debug("RenderContext", String.format("dispose"));
|
||||||
solidColorTextures.dispose();
|
solidColorTextures.dispose();
|
||||||
|
billboardSpriteBatch.dispose();
|
||||||
spriteBatch.dispose();
|
spriteBatch.dispose();
|
||||||
decalBatch.dispose();
|
|
||||||
cameraGroupStrategy.dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue