[update] Tidied a part of codes.

This commit is contained in:
falsycat 2019-10-14 00:00:00 +00:00
parent 6f7dd2c142
commit e1745f1c2b
11 changed files with 30 additions and 53 deletions

View File

@ -93,8 +93,7 @@ class ActorProgram {
verts_ = ArrayBuffer.Create();
vao_.Bind();
VertexArrayAttacher attacher;
with (attacher) {
with (VertexArrayAttacher()) {
index = 0;
type = GL_FLOAT;
dimension = 2;
@ -102,8 +101,7 @@ class ActorProgram {
}
verts_.Bind();
ArrayBufferAllocator verts_allocator;
with (verts_allocator) {
with (ArrayBufferAllocator()) {
const v = [vec2(-1, 1), vec2(1, 1), vec2(1, -1), vec2(-1, -1),];
data = v.ptr;
size = typeof(v[0]).sizeof * v.length;

View File

@ -72,8 +72,7 @@ class BackgroundProgram {
verts_ = ArrayBuffer.Create();
vao_.Bind();
VertexArrayAttacher attacher;
with (attacher) {
with (VertexArrayAttacher()) {
index = 0;
type = GL_FLOAT;
dimension = 2;
@ -81,8 +80,7 @@ class BackgroundProgram {
}
verts_.Bind();
ArrayBufferAllocator verts_allocator;
with (verts_allocator) {
with (ArrayBufferAllocator()) {
const v = [vec2(-1, 1), vec2(1, 1), vec2(1, -1), vec2(-1, -1),];
data = v.ptr;
size = typeof(v[0]).sizeof * v.length;

View File

@ -152,8 +152,7 @@ class CircleElementProgram {
///
void SetupVertexArray(ref VertexArrayRef vao,
ref ArrayBufferRef verts, ref ArrayBufferRef instances) {
VertexArrayAttacher attacher;
with (attacher) {
with (VertexArrayAttacher()) {
// verts
type = GL_FLOAT;
dimension = 2;

View File

@ -30,8 +30,7 @@ class ElementDrawer(Program, Element, vec2[] vertices) :
program_.SetupVertexArray(vao_, verts_, instances_);
verts_.Bind();
ArrayBufferAllocator verts_allocator;
with (verts_allocator) {
with (ArrayBufferAllocator()) {
const v = vertices; // place to memory
data = v.ptr;
@ -41,8 +40,7 @@ class ElementDrawer(Program, Element, vec2[] vertices) :
}
instances_.Bind();
ArrayBufferAllocator instance_allocator;
with (instance_allocator) {
with (ArrayBufferAllocator()) {
size = Instance.sizeof * elements.length;
usage = GL_DYNAMIC_DRAW;
Allocate(instances_);

View File

@ -30,8 +30,7 @@ class PostEffect {
tex_ = TextureRect.Create();
sampler_ = Sampler.Create();
TextureRectAllocator allocator;
with (allocator) {
with (TextureRectAllocator()) {
internalFormat = GL_RGB;
size = sz;
format = GL_RED;
@ -40,8 +39,7 @@ class PostEffect {
Allocate(tex_);
}
SamplerConfigurer configurer;
with (configurer) {
with (SamplerConfigurer()) {
filterMin = GL_NEAREST;
filterMag = GL_NEAREST;
Configure(sampler_);
@ -152,8 +150,7 @@ class PostEffectProgram {
ubo_index_ = gl.GetUniformBlockIndex(program_.id, "Instance".toStringz);
vao_.Bind();
VertexArrayAttacher attacher;
with (attacher) {
with (VertexArrayAttacher()) {
index = 0;
type = GL_FLOAT;
dimension = 2;
@ -161,8 +158,7 @@ class PostEffectProgram {
}
verts_.Bind();
ArrayBufferAllocator verts_allocator;
with (verts_allocator) {
with (ArrayBufferAllocator()) {
const v = [vec2(-1, 1), vec2(1, 1), vec2(1, -1), vec2(-1, -1),];
data = v.ptr;
size = typeof(v[0]).sizeof * v.length;
@ -171,8 +167,7 @@ class PostEffectProgram {
}
ubo_.Bind();
UniformBufferAllocator ub_allocator;
with (ub_allocator) {
with (UniformBufferAllocator()) {
size = PostEffect.Instance.sizeof;
usage = GL_DYNAMIC_DRAW;
Allocate(ubo_);

View File

@ -127,8 +127,7 @@ class CubeProgram {
material_index_ = gl.GetUniformBlockIndex(program_.id, "Material".toStringz);
material_.Bind();
UniformBufferAllocator material_allocator;
with (material_allocator) {
with (UniformBufferAllocator()) {
data = null;
size = Material.sizeof;
usage = GL_DYNAMIC_DRAW;
@ -140,8 +139,7 @@ class CubeProgram {
instances_ = ArrayBuffer.Create();
vao_.Bind();
VertexArrayAttacher attacher;
with (attacher) {
with (VertexArrayAttacher()) {
index = 0;
type = GL_FLOAT;
offset = vec3.sizeof * 0;
@ -175,8 +173,7 @@ class CubeProgram {
}
verts_.Bind();
ArrayBufferAllocator verts_allocator;
with (verts_allocator) {
with (ArrayBufferAllocator()) {
enum v = [
// left
vec3(-1, 1, -1), vec3(-1, 1, 1), vec3(-1, -1, 1),
@ -224,8 +221,7 @@ class CubeProgram {
}
instances_.Bind();
ArrayBufferAllocator instances_allocator;
with (instances_allocator) {
with (ArrayBufferAllocator()) {
data = null;
size = MaxInstanceCount * mat4.sizeof;
usage = GL_DYNAMIC_DRAW;

View File

@ -166,11 +166,13 @@ private class FirstSetupState : AbstractSceneState {
override UpdateResult Update(KeyInput input) {
const ratio = anime_.Update();
owner.lobby_.cube_matrix.rotation += LoadingCubeRotationSpeed * (ratio+0.2);
owner.lobby_.cube_interval = cube_interval_ease_.Calculate(ratio);
with (owner.lobby_) {
cube_matrix.rotation += LoadingCubeRotationSpeed * (ratio+0.2);
cube_interval = cube_interval_ease_.Calculate(ratio);
owner.lobby_.background.inner_color = bg_inner_ease_.Calculate(ratio);
owner.lobby_.background.outer_color = bg_outer_ease_.Calculate(ratio);
background.inner_color = bg_inner_ease_.Calculate(ratio);
background.outer_color = bg_outer_ease_.Calculate(ratio);
}
if (anime_.isFinished) {
stage_appear_state_.Initialize(0);

View File

@ -29,7 +29,6 @@ class Text {
static assert(TextProgram.Vertex.sizeof == float.sizeof * 5);
vertices_.Bind();
ArrayBufferAllocator vertices_allocator;
with (ArrayBufferAllocator()) {
size = text.length * TextProgram.Vertex.sizeof * 4;
usage = GL_STATIC_DRAW;
@ -103,8 +102,7 @@ class Text {
}
texture_.Bind();
Texture2DAllocator texture_allocator;
with (texture_allocator) {
with (Texture2DAllocator()) {
level = 0;
internalFormat = GL_RGBA8;
data = pixels.ptr;
@ -115,8 +113,7 @@ class Text {
}
indices_.Bind();
ElementArrayBufferAllocator indices_allcator;
with (indices_allcator) {
with (ElementArrayBufferAllocator()) {
size = glyph_count * 6 * ushort.sizeof;
usage = GL_STATIC_DRAW;
Allocate(indices_);

View File

@ -59,8 +59,7 @@ class TextProgram {
program_.Validate();
sampler_ = Sampler.Create();
SamplerConfigurer configurer;
with (configurer) {
with (SamplerConfigurer()) {
filterMin = GL_LINEAR;
filterMag = GL_LINEAR;
Configure(sampler_);
@ -70,8 +69,7 @@ class TextProgram {
///
void SetupVertexArray(ref VertexArrayRef vao, ref ArrayBufferRef vertices) {
vao.Bind();
VertexArrayAttacher attacher;
with (attacher) {
with (VertexArrayAttacher()) {
index = 0;
type = GL_FLOAT;
offset = 0;

View File

@ -99,8 +99,7 @@ class TitleTextProgram {
tex_ = CreateTextureFromBuffer(ImgBuf);
sampler_ = Sampler.Create();
SamplerConfigurer configurer;
with (configurer) {
with (SamplerConfigurer()) {
filterMin = GL_LINEAR;
filterMag = GL_LINEAR;
Configure(sampler_);
@ -110,8 +109,7 @@ class TitleTextProgram {
vertices_ = ArrayBuffer.Create();
vao_.Bind();
VertexArrayAttacher attacher;
with (attacher) {
with (VertexArrayAttacher()) {
index = 0;
type = GL_FLOAT;
offset = 0;
@ -128,8 +126,7 @@ class TitleTextProgram {
}
vertices_.Bind();
ArrayBufferAllocator allocator;
with (allocator) {
with (ArrayBufferAllocator()) {
const v = [
-1f, 1f, 0f, 1f, 0f,
-1f, -1f, 0f, 1f, 1f,

View File

@ -23,8 +23,7 @@ Texture2DRef CreateTextureFromImage(sfImage* img) {
sz.y.isPowerOf2.enforce();
auto tex = Texture2D.Create();
Texture2DAllocator allocator;
with (allocator) {
with (Texture2DAllocator()) {
level = 0;
internalFormat = GL_RGBA8;
data = sfImage_getPixelsPtr(img);