[update] Tidied a part of codes.

This commit is contained in:
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_);