class Tessell::Render::GL::GLBackend

Defined in:

tessell/render/gl/gl_backend.cr

Constructors

Instance Method Summary

Instance methods inherited from class Tessell::Render::Backend

begin_frame(dirty : Array(Tessell::Rect) | Nil = nil, theme : Tessell::Render::Theme = Tessell::Render::Theme.light) : Nil begin_frame, close : Nil close, create_texture(width : Int32, height : Int32, pixels : Bytes) : Int32 create_texture, destroy_texture(handle : Int32) : Nil destroy_texture, draw_draw_list(list : Tessell::Render::DrawList, from : Int32 = 0, count : Int32 = -1) : Int32 draw_draw_list, draw_polygon(points : Array(Tessell::Point), color : UInt32, even_odd : Bool = true) : Bool draw_polygon, draw_text(vertices : Array(Vertex), batches : Array(TextBatch), batch_count : Int32 = batches.size, from_batch : Int32 = 0, clip : Tessell::Rect | Nil = nil) : Int32 draw_text, end_frame : Nil end_frame, init(width : Int32, height : Int32) : Nil init, resize(width : Int32, height : Int32) : Nil resize, resolved_texture(page : Int32, color : Bool) : Int32
resolved_texture(page : Int32) : Int32
resolved_texture
, resolved_texture_external(handle : Int32) : Int32 resolved_texture_external, stats : FrameStats stats, sync_atlas(atlas : Text::GlyphAtlas) : Nil sync_atlas, sync_atlas_dirty(atlas : Text::GlyphAtlas) : Nil sync_atlas_dirty, update_texture(handle : Int32, x : Int32, y : Int32, width : Int32, height : Int32, pixels : Bytes) : Nil update_texture

Class methods inherited from class Tessell::Render::Backend

text_batch_end(size : Int32, batch_count : Int32, from_batch : Int32) : Int32 text_batch_end

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def begin_frame(dirty : Array(Tessell::Rect) | Nil = nil, theme : Tessell::Render::Theme = Tessell::Render::Theme.light) : Nil #

[View source]
def close : Nil #

[View source]
def create_texture(width : Int32, height : Int32, pixels : Bytes) : Int32 #

---- 外部纹理生命周期(issue #45/#28)---- pixels 为 straight RGBA8;上传保持 straight,绘制 Image 命令时 临时切换 blend 为 straight-alpha 语义(见 draw_image_cmd)。


[View source]
def delete_textures : Nil #

[View source]
def destroy_texture(handle : Int32) : Nil #
Description copied from class Tessell::Render::Backend

销毁外部纹理;handle 失效后再绘制 Image 命令属应用层错误。


[View source]
def draw_draw_list(list : Tessell::Render::DrawList, from : Int32 = 0, count : Int32 = -1) : Int32 #

Draw Kit/core primitive commands. Colors are 0xRRGGBBAA, alpha-premultiplied before submit because begin_frame uses (GL_ONE, GL_ONE_MINUS_SRC_ALPHA). Text commands are skipped: text is submitted by draw_text with atlas batches, allowing a host to interleave shape/text segments in command order (issue #15). Returns non-text commands submitted; clip is applied per command.


[View source]
def draw_polygon(points : Array(Tessell::Point), color : UInt32, even_odd : Bool = true) : Bool #
Description copied from class Tessell::Render::Backend

Fill a polygon using stencil/cover when supported (e.g. GLBackend). points are in screen space, color is premultiplied RGBA8, and even_odd selects fill rule (true = even-odd). Base returns false = unsupported; backends that perform the fill must return true and account stencil_fills in stats.


[View source]
def draw_text(vertices : Array(Tessell::Render::Vertex), batches : Array(Tessell::Render::TextBatch), batch_count : Int32 = batches.size, from_batch : Int32 = 0, clip : Tessell::Rect | Nil = nil) : Int32 #
Description copied from class Tessell::Render::Backend

Issue #15 contract: text is part of the command order — a host may draw text segments interleaved with draw_draw_list segments. from_batch selects the unsubmitted suffix of batches; clip restricts the text segment to a scissor rect (nil = unclipped). Return value = quads submitted by THIS call (delta, issue #46); stats.submitted_quads is the FRAME cumulative total (reset only in begin_frame) — interleaved submissions accumulate, never reset.


[View source]
def end_frame : Nil #

[View source]
def init(width : Int32, height : Int32) : Nil #

[View source]
def page_texture_ids : Array(Int32) #

[View source]
def resize(width : Int32, height : Int32) : Nil #

[View source]
def resolved_texture(page : Int32, color : Bool) : Int32 #

Color batches resolve RGBA pages; gray batches resolve R8 pages.


[View source]
def resolved_texture(page : Int32) : Int32 #

[View source]
def resolved_texture_external(handle : Int32) : Int32 #

返回 GL texture name(宿主可据此判断支持;0 = handle 不存在)。


[View source]
def set_clear_color(r : Float32, g : Float32, b : Float32, a : Float32 = 1.0_f32) : Nil #

[View source]

[View source]
def stencil_bits : Int32 #

[View source]
def sync_atlas(atlas : Tessell::Text::GlyphAtlas) : Nil #
Description copied from class Tessell::Render::Backend

全量重传 glyph atlas 所有页(冷启动/整体重建用)。动态文本场景禁止 每帧调用——增量路径走 sync_atlas_dirty(issue #22)。


[View source]
def sync_atlas_dirty(atlas : Tessell::Text::GlyphAtlas) : Nil #

Incremental atlas upload (issue #1): uploads only pages whose content revision changed since the last sync (new pages get their first upload; updated pages use glTexSubImage2D over the whole page). Cheap to call every frame — no-op when the atlas has not changed.


[View source]
def update_texture(handle : Int32, x : Int32, y : Int32, width : Int32, height : Int32, pixels : Bytes) : Nil #
Description copied from class Tessell::Render::Backend

增量区域上传(GL 走 glTexSubImage2D 同型链路)。基类 no-op。


[View source]