// ============================================================
// LCD 极简测试 - 验证环境
// ============================================================

function create(ctx, state, train) {
    ctx.setDebugInfo("测试", "create 被调用");
    
    try {
        state.texture = new GraphicsTexture(512, 320);
        if (state.texture) {
            var g = state.texture.graphics;
            g.setColor(java.awt.Color.RED);
            g.fillRect(0, 0, 512, 320);
            g.setColor(java.awt.Color.WHITE);
            var font = new java.awt.Font("Arial", java.awt.Font.BOLD, 48);
            g.setFont(font);
            g.drawString("LCD测试", 150, 180);
            state.texture.upload();
            state.ready = true;
            ctx.setDebugInfo("测试", "纹理创建成功");
        }
    } catch (e) {
        ctx.setDebugInfo("测试错误", e.toString());
    }
}

function render(ctx, state, train) {
    if (!state.ready || state.texture === null) {
        ctx.setDebugInfo("测试", "纹理未就绪");
        return;
    }
    state.texture.upload();
    ctx.setDebugInfo("测试", "渲染中");
}

function dispose(ctx, state, train) {
    if (state.texture !== null) {
        try { state.texture.close(); } catch(e) {}
        state.texture = null;
    }
    state.ready = false;
    ctx.setDebugInfo("测试", "已卸载");
}