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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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