Beispiel #1
0
        public ImmediateModeQuads(GraphicsContextAlpha gl, uint max_quads, params VertexFormat[] formats)
        {
            int num = Math.Log2((int)(max_quads * 4u));

            if (1L << (num & 31) < (long)((ulong)(max_quads * 4u)))
            {
                num++;
            }
            max_quads        = (1u << num) / 4u;
            this.m_max_quads = max_quads;
            ushort[] array  = new ushort[this.m_max_quads * 6u];
            ushort[] array2 = new ushort[]
            {
                0,
                1,
                3,
                0,
                3,
                2
            };
            int i    = 0;
            int num2 = 0;

            while (i < (int)max_quads)
            {
                Common.Assert(num2 + 6 <= array.Length);
                for (int j = 0; j < 6; j++)
                {
                    //array[num2++] = (ushort)(i * 4 + (int)array2[j]); //FIXME: overflow
                    array[num2++] = (ushort)((i * 4 + (int)array2[j]) & 0xffff);
                }
                i++;
            }
            this.m_imm = new ImmediateMode <T>(gl, max_quads * 4u, array, 4, 6, formats);
        }
Beispiel #2
0
 public Camera3D(GraphicsContextAlpha gl, DrawHelpers draw_helpers)
 {
     this.GL             = gl;
     this.m_draw_helpers = draw_helpers;
     this.m_push_depth   = 0;
     this.Frustum        = new Frustum();
 }
Beispiel #3
0
        public SpriteRenderer(GraphicsContextAlpha gl, uint max_sprites)
        {
            this.GL          = gl;
            this.m_imm_quads = new ImmediateModeQuads <Vector4>(this.GL, max_sprites, new VertexFormat[]
            {
                (VertexFormat)259
            });
            Texture2D texture2D = EmbeddedDebugFontData.CreateTexture();

            this.m_embedded_font_texture_info = new TextureInfo();
            this.m_embedded_font_texture_info.Initialize(texture2D, new Vector2i(EmbeddedDebugFontData.NumChars, 1), new TRS(new Bounds2(new Vector2(0f, 0f), new Vector2((float)(EmbeddedDebugFontData.CharSizei.X * EmbeddedDebugFontData.NumChars) / (float)texture2D.Width, (float)EmbeddedDebugFontData.CharSizei.Y / (float)texture2D.Height))));
        }
Beispiel #4
0
 public GraphicsContextAlpha(GraphicsContext context = null)
 {
     this.m_context = context;
     this.m_context_must_be_disposed = false;
     if (this.m_context == null)
     {
         this.m_context = new GraphicsContext();
         this.m_context_must_be_disposed = true;
     }
     this.ModelMatrix          = new MatrixStack(16u);
     this.ViewMatrix           = new MatrixStack(16u);
     this.ProjectionMatrix     = new MatrixStack(8u);
     this.m_white_texture      = GraphicsContextAlpha.CreateTextureUnicolor(4294967295u);
     this.m_white_texture_info = new TextureInfo(this.m_white_texture);
     this.DebugStats           = new GraphicsContextAlpha.DebugStats_();
 }
Beispiel #5
0
 public Camera2D(GraphicsContextAlpha gl, DrawHelpers draw_helpers)
 {
     this.GL                        = gl;
     this.m_draw_helpers            = draw_helpers;
     this.m_data.m_support_scale    = 1f;
     this.m_data.m_support_unit_vec = Math._01;
     this.m_data.m_support_is_y     = true;
     this.m_data.m_center           = Math._00;
     this.m_data.m_aspect           = 1f;
     this.m_data.m_znear            = -1f;
     this.m_data.m_zfar             = 1f;
     this.m_push_depth              = 0;
     this.m_prev_touch_state        = false;
     this.m_touch_state             = false;
     this.m_drag_mode               = 0;
     this.m_drag_start_pos          = Math._00;
 }
Beispiel #6
0
 public DrawHelpers(GraphicsContextAlpha gl, uint max_vertices)
 {
     this.GL = gl;
     this.m_shader_program = Common.CreateShaderProgram("cg/default.cgx");
     this.m_shader_program.SetUniformBinding(0, "MVP");
     this.m_shader_program.SetAttributeBinding(0, "p");
     this.m_shader_program.SetAttributeBinding(1, "vin_color");
     this.m_current_color         = Colors.Magenta;
     this.m_shader_depth          = 0u;
     this.m_view_matrix_tag       = 4294967295u;
     this.m_model_matrix_tag      = 4294967295u;
     this.m_projection_matrix_tag = 4294967295u;
     this.m_imm = new ImmediateMode <DrawHelpers.Vertex>(gl, max_vertices, null, 0, 0, new VertexFormat[]
     {
         (VertexFormat)259,
         (VertexFormat)259
     });
 }
Beispiel #7
0
 public ImmediateMode(GraphicsContextAlpha gl, uint max_vertices, ushort[] indices, int vertices_per_primitive, int indices_per_primitive, params VertexFormat[] formats)
 {
     this.GL                       = gl;
     this.m_max_vertices           = max_vertices;
     this.m_vertices_per_primitive = vertices_per_primitive;
     this.m_indices_per_primitive  = indices_per_primitive;
     this.m_vertices_tmp           = new T[this.m_max_vertices];
     this.m_frame_count            = 4294967295u;
     this.m_pos                    = 0u;
     if (indices != null)
     {
         this.m_max_indices = (uint)indices.Length;
         Common.Assert(this.m_vertices_per_primitive != 0);
         Common.Assert(this.m_indices_per_primitive != 0);
         Common.Assert((ulong)this.m_max_vertices / (ulong)((long)this.m_vertices_per_primitive) * (ulong)((long)this.m_vertices_per_primitive) == (ulong)this.m_max_vertices);
         Common.Assert((ulong)this.m_max_indices / (ulong)((long)this.m_indices_per_primitive) * (ulong)((long)this.m_indices_per_primitive) == (ulong)this.m_max_indices);
         Common.Assert((ulong)this.m_max_vertices / (ulong)((long)this.m_vertices_per_primitive) == (ulong)this.m_max_indices / (ulong)((long)this.m_indices_per_primitive));
     }
     else
     {
         this.m_max_indices = 0u;
     }
     this.m_vbuf_pool = new VertexBufferPool(indices, this.m_vertices_per_primitive, this.m_indices_per_primitive, formats);
 }