Skip to content

axmol v3 migrate guide

Deal edited this page Oct 2, 2026 · 5 revisions

axmol v3 removes all APIs that were deprecated in 2.x, and performs a substantial architectural refactor (new RHI layer, unified pointer input, reorganized scene graph, rewritten physics). This guide lists the changes you need to apply when porting a v2.x (2.x LTS) project to v3.

Status: compiled from a full source diff between release/2.x (v2.11.6) and dev (v3 beta1). Every entry below was verified against the actual headers; items that could not be confirmed are explicitly marked unverified.


0. The 30-second overview

Area What happened
Include root core/** → axmol/** (e.g. "base/Director.h" → "axmol/base/Director.h")
Scene graph 2d/Node.h, 2d/Scene.h, 2d/Camera.h, 2d/Component*.h → scene/*.h
Graphics ax::backend::* → ax::rhi::* (DriverBase→GraphicsDevice, CommandBuffer→GraphicsContext)
Input touch + mouse + pen merged into a single pointer pipeline (PointerEvent / PointerEventListener)
Node::draw/visit now take const SceneRenderState& instead of Renderer*
Widgets ui::UIXxx → ui::Xxx (file ui/UIButton.h → ui/Button.h)
Physics chipmunk2D physics/* → box2d-v3 physics/2d/*; bullet physics3d/* → Jolt physics/3d/*
Colors Color3B gone, Color4B→Color32, Color4F→Color
Utils StringUtils→text_utils, hlookup→tlx, Configuration→Environment, Console removed
Build new AX_RENDER_API, AX_ENABLE_PHYSICS_3D, AX_ENABLE_VIDEO, AX_ENABLE_VR CMake options

1. Directory / include layout

v2 (core/...) v3 (axmol/...)
2d/Node.h, 2d/Scene.h, 2d/Camera.h, 2d/CameraBackgroundBrush.h, 2d/Component.h, 2d/ComponentContainer.h scene/Node.h, scene/Scene.h, scene/Camera.h, scene/CameraBackgroundBrush.h, scene/Component.h, scene/ComponentContainer.h
2d/RenderTexture.h renderer/RenderTexture.h (+ new renderer/RenderTexturePass.h)
renderer/backend/*.h rhi/*.h
renderer/backend/ProgramManager.h renderer/ProgramManager.h (moved out of backend, namespace ax)
base/Configuration.h base/Environment.h
base/Console.h removed
base/UTF8.h (holds StringUtils) base/text_utils.h (+ base/UTF8.h keeps namespace StringUtils = text_utils;)
base/AsyncTaskPool.h base/JobSystem.h
base/IMEDelegate.h, base/IMEDispatcher.h base/InputDelegate.h, base/InputSystem.h
base/axstd.h, base/bitmask.h, base/format.h, base/hlookup.h, base/filesystem.h, base/PaddedString.h, base/NS.h tlx/*.hpp (bitmask.hpp, format.hpp, hlookup.hpp, filesystem.hpp, …) — namespace hlookup → tlx
base/{EventTouch,EventMouse,EventKeyboard,EventCustom,…}.h base/{PointerEvent,KeyboardEvent,CustomEvent,…}.h
platform/ApplicationBase.h platform/ApplicationCore.h
platform/RenderView.h, platform/RenderViewImpl.h platform/RenderViewCore.h + platform/{pc,android,ios,winrt}/RenderView-*.h
math/Quaternion.h math/Quat.h
3d/{AABB,OBB,Plane,Ray,Frustum}.h math/{AABB,OBB,Plane,Ray,Frustum}.h
physics/*.h (chipmunk2D) physics/2d/*.h (box2d v3)
physics3d/*.h (bullet3d) physics/3d/*.h (Jolt)
ui/UIXxx.h ui/Xxx.h
ui/UIEditBox/UIEditBox.h ui/EditBox/EditBox.h
ui/UIWebView/UIWebView.h ui/WebView/WebView.h
extensions/cocostudio extensions/sceneio + extensions/sceneext (namespace ax::ext for the latter)

axmol/axmol.h still exists and is still the "everything" umbrella header.

// v2
#include "base/Director.h"
#include "2d/Node.h"
#include "2d/Sprite.h"
#include "ui/UIButton.h"

// v3
#include "axmol/base/Director.h"
#include "axmol/scene/Node.h"
#include "axmol/2d/Sprite.h"
#include "axmol/ui/Button.h"

2. Director

Director loses a lot of 2.x compatibility surface.

v2 v3 note
getGLView() / setGLView() removed use getRenderView() / setRenderView()
getRenderView() → RenderView* getRenderView() → RenderViewCore* return type changed (see §4)
getWinSize(), getWinSizeInPixels() removed → getCanvasSize(), getCanvasSizeInPixels()
convertToGL(), convertToUI() removed see the correction note below
getProjection() / setProjection() and enum class Projection removed entirely (no Projection type exists in v3)
stopAnimation() / startAnimation() deactivate() / activate() also virtual startAnimation(SetIntervalReason) → virtual activate(SetIntervalReason)
drawScene() removed
mainLoop() / mainLoop(float) removed
getConsole() removed (the Console module is gone; AX_ENABLE_CONSOLE too)
pushMatrix/popMatrix/loadIdentityMatrix/loadMatrix/multiplyMatrix/getMatrix/resetMatrixStack (MATRIX_STACK_TYPE) removed
queueOperation(AsyncOperation, void*) / processOperations() postTask(std::function<void()>, TaskTiming) / clearPendingTasks()
isValid() removed
setClearColor(const Color4F&) setClearColor(const Color&) see §8
EVENT_* (const char*) EVENT_* (std::string_view) EVENT_PROJECTION_CHANGED removed; new: EVENT_DISPOSING, EVENT_BEFORE_GFX_DROP, EVENT_AFTER_GFX_DROP
setGLDefaultValues() (deprecated in 2.9) removed → setRenderDefaults()
getJobSystem() getJobSystem() — unchanged plus new runAsync(task, done)
— new: canvasToPixels(), screenToCanvas(), setCanvasSize(), getSafeAreaRect(), isActive(), dispatchDisposing(), getOffscreenCamera(), getOverlayCamera(), performFrameTasks(), performFrameBoundaryTasks()

Correction to earlier drafts of this page: there is no Director::worldToScreen / Director::screenToWorld in v3 (verified: zero occurrences repo-wide). convertToGL / convertToUI were simply removed; use the new canvas helpers (getCanvasSize() / canvasToPixels() / screenToCanvas()) instead.


3. Application & program entry

3.1 main()

// v2
int main(int argc, char** argv)
{
    AppDelegate app;
    return Application::getInstance()->run();
}

// v3
int main(int argc, char** argv)
{
    AppDelegate app;
    return Application::getInstance()->launch(argc, argv);   // NEW: launch(argc, argv)
}

ApplicationCore::run() is still the per-platform loop entry, but user code now calls launch(int argc, tchar_t** argv), which parses arguments into the new ax::CommandLineArgs (axmol/platform/CommandLineArgs.h).

3.2 Context attributes

initGfxContextAttrs() is gone; it is replaced by applicationWillLaunch() plus the static setContextAttrs() on ApplicationCore.

// v2
void AppDelegate::initGfxContextAttrs()
{
    GfxContextAttrs gfxContextAttrs = {8, 8, 8, 8, 24, 8, 0};
    RenderView::setGfxContextAttrs(gfxContextAttrs);
    Device::setPreferredOrientation(Device::Orientation::SensorLandscape);
}

// v3
void AppDelegate::applicationWillLaunch()
{
    setLogFmtFlag(ax::LogFmtFlag::Full);

    // optional: pick an RHI backend instead of Auto
    // ax::rhi::GraphicsCore::setPreferredBackend(ax::rhi::GraphicsBackend::Auto);

    ContextAttrs contextAttrs = {.debugLayerEnabled = false,
                                 .powerPreference   = PowerPreference::HighPerformance};
    // contextAttrs.vsync = false;                       // V-Sync on by default since 2.2
    // contextAttrs.renderScaleMode = RenderScaleMode::Physical;  // high-DPI
    setContextAttrs(contextAttrs);

    Device::setPreferredOrientation(Device::Orientation::SensorLandscape);
}

Other additions: applicationWillLaunch(), applicationWillQuit() (new in 2.10, still present), registerVulkanInterop(), releaseXRDriver(), ApplicationCore::getDirector().


4. Render view / window

RenderViewImpl is gone. The platform-independent base is now ax::RenderViewCore, and each platform ships a concrete class named ax::RenderView:

v2 v3
RenderViewImpl (all platforms) RenderViewCore (base) + RenderView in platform/pc/RenderView-pc.h (GLFW: win32/linux/mac/wasm), platform/android/RenderView-android.h, platform/ios/RenderView-ios.h, platform/winrt/RenderView-winrt.h
GLViewImpl (deprecated alias) removed
// v2
renderView = RenderViewImpl::createWithRect(title, Rect(0, 0, w, h), 1.0F, true);
director->setRenderView(renderView);
renderView->getFrameSize();

// v3
renderView = RenderView::createWithRect(title, Rect(0, 0, w, h), 1.0F, true);
director->setRenderView(renderView);
renderView->getRenderSize();          // preferred

RenderViewCore API changes:

v2 v3
getFrameSize() / setFrameSize(w,h) getWindowSize() / setWindowSize(w,h) (old names kept as AX_DEPRECATED("3.0") shims)
getFrameZoomFactor() / setFrameZoomFactor() getWindowZoomFactor() / setWindowZoomFactor() (old names deprecated)
— new getRenderSize(), getNativeWindowSize(), getNativeDisplay(), getNativeWindow(), getWindowPlatform(), getRenderScale(), setIcon(), setViewportInPoints(), setScissorInPoints(), isVRActive(), getSceneCompositor()
createWithFullScreen(...) createWithFullscreen(...) (lowercase s) — the wiki note about this rename is correct
isOpenGLReady() isGfxContextReady()

New view events: RenderViewCore::EVENT_WINDOW_{POSITIONED,RESIZED,FOCUSED,UNFOCUSED,CLOSE,CURSOR_ENTER}.


5. Scene graph: Node, Scene, Camera

5.1 draw() / visit() signature — the biggest source of compile errors

// v2
virtual void draw(Renderer* renderer, const Mat4& transform, uint32_t flags);
virtual void visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags);

// v3
virtual void draw(const SceneRenderState& state, const Mat4& transform, uint32_t flags);
virtual void visit(const SceneRenderState& state, const Mat4& parentTransform, uint32_t parentFlags);

SceneRenderState (defined in axmol/scene/Node.h) bundles the renderer and the camera/view data for the current pass:

struct AX_DLL SceneRenderState
{
    Renderer* renderer   = nullptr;
    const Camera* camera = nullptr;
    SceneViewData view;          // { view, projection, viewProjection, position }
    unsigned short cameraFlag    = 0;
    bool viewOverridden          = false;

    Renderer* getRenderer() const;
    const Camera* getCamera() const;
    const SceneViewData& getView() const;
    const Mat4& getViewMatrix() const;
    const Mat4& getProjectionMatrix() const;
    const Mat4& getViewProjectionMatrix() const;
};

struct AX_DLL SceneViewData
{
    Mat4 view, projection, viewProjection;
    Vec3 position;
    static SceneViewData fromCamera(const Camera& camera);
    static SceneViewData fromMatrices(const Mat4& view, const Mat4& projection, const Vec3& position);
};

Concrete migration (DrawNode::draw from the engine itself):

// v2
void DrawNode::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
{
    updateUniforms(transform, _customCommandTriangle);
    _customCommandTriangle.init(_globalZOrder);
    renderer->addCommand(&_customCommandTriangle);
}

// v3
void DrawNode::draw(const SceneRenderState& state, const Mat4& transform, uint32_t flags)
{
    updateUniforms(state, transform, _customCommandTriangle);   // now takes the state too
    _customCommandTriangle.init(_globalZOrder);
    state.getRenderer()->addCommand(&_customCommandTriangle);
}

5.2 Other Node changes

v2 v3
convertTouchToNodeSpace(Touch*), convertTouchToNodeSpaceAR(Touch*) convertPointerToNodeSpace(PointerEvent*), convertPointerToNodeSpaceAR(PointerEvent*)
— new virtual bool onPointerHitTest(PointerEvent*, Vec3* outHitPoint) — override this for custom 3D/ray hit testing
backend::ProgramState* (getProgramState, setProgramState, …) rhi::ProgramState*

6. Events & input — touch/mouse unified into pointer

This is the largest behavioral change. Event::Type::TOUCH and ::MOUSE collapse into Event::Type::POINTER; Touch, EventTouch and EventMouse are deleted.

6.1 Class / header mapping

v2 v3 compat alias?
EventTouch PointerEvent (axmol/base/PointerEvent.h) no
Touch removed no
EventMouse removed (folded into PointerEvent, PointerType::Mouse) no
EventListenerTouchOneByOne, EventListenerTouchAllAtOnce, EventListenerMouse one class: PointerEventListener no
EventKeyboard KeyboardEvent yes (using EventKeyboard = KeyboardEvent;)
EventCustom CustomEvent yes
EventFocus FocusEvent yes
EventAcceleration AccelerationEvent yes
EventController ControllerEvent yes
EventListenerKeyboard / …Custom / …Focus / …Controller KeyboardEventListener / CustomEventListener / FocusEventListener / ControllerEventListener yes
— XRInputEvent / XRInputEventListener (new, for VR controllers) —
IMEDelegate InputDelegate no
IMEDispatcher InputSystem no

6.2 Enums

v2 v3
Event::Type::{TOUCH,MOUSE} Event::Type::POINTER
Event::Type::{KEYBOARD,ACCELERATION,FOCUS,GAME_CONTROLLER,CUSTOM} unchanged; new Event::Type::XR_INPUT
EventListener::Type::{TOUCH_ONE_BY_ONE,TOUCH_ALL_AT_ONCE} EventListener::Type::POINTER
EventTouch::EventCode{BEGAN,MOVED,ENDED,CANCELLED} ax::InputPhase{PointerDown,PointerMove,PointerUp,PointerCancel,PointerScroll,KeyDown,KeyUp,KeyRepeat}
EventMouse::MouseEventType{MOUSE_DOWN,…} InputPhase::Pointer{Down,Up,Move,Scroll}
EventMouse::MouseButton{BUTTON_LEFT,…} InputButton::{None=-1,Primary=0/Left,Secondary=1/Right,Tertiary=2/Middle}
— new PointerType{Mouse,Touch,Pen,Controller}
EventKeyboard::KeyCode KeyboardEvent::KeyCode — identical names, no changes needed

EventListener::ListenerID changed from std::string to std::string_view.

6.3 Listener callbacks

// v2 — one by one
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = AX_CALLBACK_2(Paddle::onTouchBegan, this);
listener->onTouchMoved = AX_CALLBACK_2(Paddle::onTouchMoved, this);
listener->onTouchEnded = AX_CALLBACK_2(Paddle::onTouchEnded, this);
// bool Paddle::onTouchBegan(Touch* touch, Event* event)

// v3
auto listener = PointerEventListener::create();
listener->onPointerDown = AX_CALLBACK_1(Paddle::onPointerDown, this);
listener->onPointerMove = AX_CALLBACK_1(Paddle::onPointerMove, this);
listener->onPointerUp   = AX_CALLBACK_1(Paddle::onPointerUp, this);
// bool Paddle::onPointerDown(PointerEvent* event)
  • onTouchBegan→onPointerDown, onTouchMoved→onPointerMove, onTouchEnded→onPointerUp, onTouchCancelled→onPointerCancel, onMouseDown→onPointerDown, onMouseUp→onPointerUp, onMouseMove→onPointerMove, onMouseScroll→onPointerScroll.
  • All callbacks drop the trailing Event* argument → AX_CALLBACK_2 becomes AX_CALLBACK_1.
  • setSwallowTouches / setSwallowMouse are removed: returning true from onPointerDown now claims pointer capture for (pointerId, button); for scroll use event->stopPropagation().
  • There is no "all at once" listener. You receive one PointerEvent per pointer — key your own state on event->getPointerId().
  • New optional onPointerHitTest — std::function<bool(PointerEvent*, Vec3*)>.

6.4 Touch / EventMouse accessor mapping

v2 v3
touch->getLocation() event->getWorldPoint()
touch->getPreviousLocation() event->getPrevWorldPoint()
touch->getStartLocation() event->getStartWorldPoint()
touch->getLocationInView() event->getPoint()
touch->getID() event->getPointerId() (intptr_t)
touch->getCurrentForce() event->getPressure()
e->getMouseButton() e->getButton()
e->getScrollX()/getScrollY() unchanged
e->getDelta() getWorldPoint() - getPrevWorldPoint()
EventTouch::MAX_TOUCHES removed (platform-local caps only)
— new: getPhase(), getPointerType(), getPressedButtons(), isButtonPressed(), isPrimaryPressed(), isPrimary(), isCaptured(), getScrollDelta(), getCamera(), getRay(), getHitResult()

6.5 Keyboard

// v2
listener->onKeyPressed = [](ax::EventKeyboard::KeyCode code, ax::Event* e) { … };
// v3
listener->onKeyPressed = [](ax::KeyboardEvent* e) { auto code = e->getKeyCode(); … };

onKeyRepeat is new; KeyboardEvent::getKeyCode() is now public (it was private in v2).

6.6 IME / text input

// v2
IMEDispatcher::sharedDispatcher()->dispatchInsertText(text, len);
// v3
InputSystem::getInstance()->dispatchInsertText(std::string_view{text});
  • insertText(const char*, size_t) → insertText(std::string_view)
  • deleteBackward(size_t) → deleteBackward(unsigned int)
  • canAttachWithIME() / canDetachWithIME() are now const
  • getContentText() removed
  • IMEKeyboardNotificationInfo::begin/end → single keyboardFrame
  • new: updatePreeditText(), performEditAction(), hitTestWithIME()
  • InputSystem::getInstance() (there is no Director::getInputSystem()), also owns setMultiTouchEnabled(), setInteractive(), and getLastPointerPosition()

6.7 Controller

Controller itself is unchanged. The listener callbacks changed:

// v2: std::function<void(Controller*, int keyCode, Event*)>
// v3: std::function<void(ControllerEvent*)>   // e->getController(), e->getKeyCode()

TextFieldTTF is removed in v3 — use the new ui::InputField.


7. Graphics: ax::backend → ax::rhi

The whole renderer/backend tree was replaced by rhi. There is no backend:: namespace left (verified: zero occurrences in v3).

7.1 Type mapping

v2 ax::backend::… v3 ax::rhi::…
DriverBase GraphicsDevice
CommandBuffer GraphicsContext
TextureBackend Texture
RenderPipeline GraphicsPipeline
Program / ProgramState Program / ProgramState (in ax::rhi)
ShaderModule ShaderModule
TextureDescriptor TextureDesc
RenderPassDescriptor RenderPassDesc
PipelineDescriptor PipelineDesc
DepthStencilDescriptor DepthStencilDesc
PixelBufferDescriptor PixelBufferDesc
VertexLayout VertexLayout (+ new VertexLayoutDesc, VertexLayoutManager)
VertexFormat VertexElementType
StencilOperation StencilOp
CompareFunction CompareFunc
BlendOperation BlendOp
VertexStepMode removed
PixelFormat PixelFormat (same value names; underlying type uint32_t→uint8_t)

7.2 Obtaining the device

// v2
auto* drv = ax::backend::DriverBase::getInstance();
// v3
auto* drv = ax::rhi::GraphicsCore::device();   // convenience macro: axdrv

GraphicsCore is the new system-level entry point (axmol/rhi/GraphicsCore.h):

GraphicsCore::setPreferredBackend(GraphicsBackend backend);      // Auto|OpenGL|D3D11|D3D12|Vulkan|Metal
GraphicsCore::setBackendPriority(GraphicsBackend, int prio);
GraphicsCore::setVulkanMinAndroidApiLevel(int apiLevel);         // default 31
GraphicsCore::setVulkanInterop(VulkanInterop*);                  // OpenXR sharing
GraphicsCore::initialize(); / activate(); / shutdown();
GraphicsCore::device(); backend(); isOpenGL(); isMetal(); isD3D11(); isD3D12(); isVulkan();
GraphicsCore::shaderLanguage(); shaderProfile(); shaderILProfile();

7.3 DriverBase → GraphicsDevice

v2 v3
getInstance() / destroyInstance() GraphicsCore::device() / GraphicsCore::shutdown()
newCommandBuffer() createGraphicsContext(SurfaceHandle surface)
newBuffer(size, type, usage) createBuffer(size, type, usage, const void* initial = nullptr) (also createBuffer(const BufferDesc&, …))
newTexture(const TextureDescriptor&) createTexture(const TextureDesc&, …)
newRenderTarget(...), newDefaultRenderTarget() createRenderTarget(Texture* colorAttachment = nullptr, …)
newDepthStencilState() createDepthStencilState()
newRenderPipeline() createGraphicsPipeline()
newProgram(vs, fs) — source strings createProgram(Data vsData, Data fsData) — precompiled chunks
newShaderModule(stage, source) createShaderModule(ShaderStage, Data& chunk)
getVendor/getRenderer/getVersion → const char* → std::string
setFrameBufferOnly moved to GraphicsContext::setFrameBufferOnly
— new: createComputePipeline, createComputeProgram, createVertexLayout(VertexLayoutDesc&&), createSampler/destroySampler, createTextureFromNativeHandle, waitForGPU(), destroyStaleResources(), getCaps()

7.4 CommandBuffer → GraphicsContext

v2 v3
setRenderPipeline(RenderPipeline*) setGraphicsPipeline(GraphicsPipeline*)
beginRenderPass(const RenderTarget*, const RenderPassDescriptor&) beginRenderPass(RenderTarget*, const RenderPassDesc&)
updatePipelineState(rt, const PipelineDescriptor&) updatePipelineState(rt, const PipelineDesc&, PrimitiveType) — extra arg
drawArrays(PrimitiveType, start, count) drawArrays(size_t start, size_t count, bool wireframe = false)
drawElements(PrimitiveType, IndexFormat, count, offset) drawElements(IndexFormat, size_t count, size_t offset, bool wireframe = false)
readPixels(rt, cb) with PixelBufferDescriptor readPixels(rt, cb) with PixelBufferDesc
— new: getScreenRenderTarget(), updateSurface(), copyTexture(src,dst), dispatch(const ComputeDispatchDesc&) (compute!), submitCurrentFrameCommands(bool), getCompletedFenceValue()

7.5 Program / ProgramState

  • ax::ProgramManager moved from renderer/backend/ProgramManager.h to renderer/ProgramManager.h and is now in namespace ax (not ax::backend).
  • Program now exposes getActiveVertexInputs(), getActiveTextureInfos(), getActiveSamplerInfos(), getSamplerBindings(), getActiveStorageBufferInfos(), getComputeLocalSize(), getProgramType(), getProgramId().
  • ProgramState: setTexture(int location, int slot, rhi::Texture*), setTextureArray(...), setUniform(const rhi::UniformLocation&, const void*, size_t), setUniformBlock(...), getUniformLocation(std::string_view | rhi::Uniform), clone().

7.6 Texture2D

// v2
backend::TextureBackend* tex = sprite->getTexture()->getBackendTexture();
// v3
rhi::Texture* tex = sprite->getTexture()->getRHITexture();

7.7 Shaders

Shaders are no longer authored as GL/GLSL strings handed to newProgram(). v3 compiles shaders ahead of time with axslc and ships binary Data chunks consumed by GraphicsDevice::createProgram(Data, Data). See docs/hlsl-spec.md, docs/hlsl-faq.md and the wiki page Shaders in Axmol3 for the HLSL-based authoring rules.

7.8 Render commands

RenderCommand::init() gained a const SceneViewData& parameter — this affects every *Command subclass:

// v2
void init(float globalZOrder, const Mat4& modelViewTransform, unsigned int flags);
// v3
void init(float globalZOrder, const Mat4& modelViewTransform, unsigned int flags, const SceneViewData& view);

Affected: CustomCommand::init, CallbackCommand::init, QuadCommand::init, TrianglesCommand::init, MeshCommand::init.

RenderTexture was rewritten:

// v2  — RenderTexture is a Node you begin()/end()
auto* rt = RenderTexture::create(w, h);
rt->beginWithClear(0,0,0,0);
rt->end();

// v3  — RenderTexture derives from Texture2D; rendering scope is RenderTexturePass
auto* rt = RenderTexture::create(director->canvasToPixels(size), rhi::PixelFormat::RGBA8);
auto scope = RefPtr<RenderTexturePass>(RenderTexturePass::obtain(rt), tlx::adopt_object);
scope->begin();          // begin(const Camera* camera = nullptr)
…                        // draw
scope->end();

Other changes: create(..., PixelFormat) now takes rhi::PixelFormat; newImage(cb, eglCacheHint) → newImage(cb); getClearColor() returns const Color&.


8. Vertex structs & colors

8.1 Vertex structs renamed and reordered

v2 (base/Types.h, math/Vertex.h) v3 (math/Vertex.h)
V3F_C4B_T2F { Vec3 vertices; Color4B colors; Tex2F texCoords; } V3F_T2F_C4B { Vec3 position; Tex2F texCoord; Color32 color; }
V2F_C4B_T2F, V2F_C4F_T2F V2F_T2F_C4B, V2F_T2F_C4F
V3F_C4B_T2F_Quad, V2F_C4B_T2F_Quad V3F_T2F_C4B_Quad, V2F_T2F_C4B_Quad
V3F_C4F { Vec3 vertices; Color4F colors; } V3F_C4F { Vec3 position; Color color; }

So the wiki note triangles.indices[i].vertices => triangles.indices[i].position should read:

// v2
quad.bl.vertices  = …;  quad.bl.colors = …;  quad.bl.texCoords = …;
// v3
quad.bl.position  = …;  quad.bl.color  = …;  quad.bl.texCoord  = …;

Note the field order changed (position, texcoord, color) — do not just rename, check layout dependent code (custom vertex writing, memcpy, AutoPolygon::calculateUV, …).

8.2 Colors

v2 v3
Color3B removed — use Color32 (or Color)
Color4B Color32
Color4F Color
Vec4Base<T> Vec4Adapter<T>
Color4F parameters in APIs Color (e.g. Director::setClearColor, Renderer::clear)

9. Math

v2 v3
Quaternion (math/Quaternion.h) Quat (math/Quat.h)
3d/AABB.h, 3d/OBB.h, 3d/Plane.h, 3d/Ray.h, 3d/Frustum.h math/AABB.h, math/OBB.h, math/Plane.h, math/Ray.h, math/Frustum.h
3d/VertexAttribBinding.{h,cpp} 3d/VertexInputBinding.{h,cpp}
3d/3DProgramInfo.{h,cpp} removed

10. ui widget module

10.1 File & class renames (the UI prefix is dropped)

v2 v3
ui/UIWidget.h → Widget ui/Widget.h → Widget
UIButton Button
UICheckBox CheckBox
UIAbstractCheckButton AbstractCheckButton
UIImageView ImageView
UILayout LayoutGroup (using Layout = LayoutGroup; alias kept)
UILayoutManager / UILayoutParameter / UILayoutComponent LayoutManager / LayoutParameter / LayoutComponent
UILinearGravity… layout types LinearVerticalLayoutManager, LinearHorizontalLayoutManager, LinearCenter*LayoutManager, RelativeLayoutManager
UIListView ListView
UILoadingBar LoadingBar
UIPageView / UIPageViewIndicator PageView / PageViewIndicator
UIRichText RichText
UIScale9Sprite Scale9Sprite
UIScrollView / UIScrollViewBar ScrollView / ScrollViewBar
UISlider Slider
UIText / UITextAtlas / UITextBMFont Text / TextAtlas / TextBMFont
UITabControl TabView (+ TabHeader)
UIMediaPlayer VideoPlayer (+ VideoController, DefaultVideoController, VideoPlayerControl)
UIHBox / UIVBox / UIRelativeBox HBox / VBox / RelativeBox
UIRadioButton RadioButton (+ new RadioButtonGroup)
UIEditBox EditBox
UIWebView WebView
UITextField, UITextFieldEx removed → new ui::InputField
ui/UIHelper.h ui/UIHelper.h (file name unchanged, class Helper)
ui/axmol-ui.h ui/axmol-ui.h (umbrella, includes updated)

There are no compatibility aliases for these names — ui/UIButton.h will simply fail to compile.

10.2 Widget-level API changes

v2 (ui::Widget) v3
typedef … ccWidgetTouchCallback using WidgetTouchCallback / TouchEventHandler
interceptTouchEvent(TouchEventType, Widget*, Touch*) interceptPointerEvent(Widget*, PointerEvent*)
propagateTouchEvent(...) propagatePointerEvent(Widget*, PointerEvent*)
initRenderer() initRenderNode()
getVirtualRendererSize() resolvePreferredSize(const Vec2& sizeHint)
setTouchEnabled(bool) kept, but now a wrapper over new setPointerEnabled(bool) / isPointerEnabled()
— new addPointerEventListener(), addHoverEventListener(), setPropagatePointerEvents(), isPointerInside(), onPointerHitTest() override
— new enums Widget::PointerPhase{Down,Move,Up,Cancel} and Widget::HoverEventType{ENTER,MOVE,EXIT} (TouchEventType unchanged)
typedef … ccTabCallback / ccTabControlCallback TabCallback / TabViewCallback

ui::EditBox now derives from InputDelegate instead of IMEDelegate, and lives in axmol/ui/EditBox/EditBox.h.


11. Physics

Both 2D and 3D physics were replaced with new component-based APIs.

v2 v3
physics/PhysicsBody.h, PhysicsShape.h, PhysicsJoint.h, PhysicsWorld.h, PhysicsContact.h, PhysicsHelper.h (chipmunk2D) physics/2d/{Rigidbody2D,Collider2D,Joint2D,PhysicsWorld2D,ContactEvent2D,PhysicsMaterial2D,PhysicsUtility2D}.h (box2d v3, b2BodyId internalHandle())
physics3d/Physics3D*.h (bullet3d) physics/3d/{Rigidbody3D,Collider3D,Joint3D,PhysicsWorld3D,ContactEvent3D,PhysicsDebugDraw3D,PhysicsUtility3D}.h (Jolt)
physics/PhysicsHelper.h physics/2d/PhysicsUtility2D.h, physics/3d/PhysicsUtility3D.h
PhysicsBody::createXXX(...) Rigidbody2D + Collider2D subclasses (CircleCollider2D, BoxCollider2D, PolygonCollider2D, EdgeSegmentCollider2D, EdgeChainCollider2D, …)
contacts via PhysicsContact ContactEvent2D / ContactEventListener2D (built on CustomEvent)
PhysicsJoint subclasses FixedJoint2D, DistanceJoint2D, SpringJoint2D, SliderJoint2D, WheelJoint2D, PivotJoint2D, PinJoint2D, MotorJoint2D, FilterJoint2D

CMake: AX_ENABLE_3D_PHYSICS → AX_ENABLE_PHYSICS_3D.


12. Utilities

v2 v3
StringUtils::format(...) (deprecated since 2.1.4) removed — use fmt::format
StringUtils::* text_utils.h; a compatibility alias namespace StringUtils = text_utils; remains in base/UTF8.h
Configuration::getInstance() Environment::getInstance() (same getValue/setValue/loadConfigFile/supportsXXX API)
Console, Director::getConsole() removed (and AX_ENABLE_CONSOLE)
AsyncTaskPool Director::getInstance()->getJobSystem() (plus Director::runAsync)
FileUtils::getFileExtension() (dep. 2.1) getPathExtension()
FileUtils::getFileShortName() (dep. 2.1) getPathBaseName()
FileUtils::createDirectory() (dep. 2.1) createDirectories()
FileUtils::…Async(callback) variants (dep. 2.1) removed
ZipFile::createWithBuffer() (dep. 2.9) createWithData()
HttpClient::sendImmediate() (dep. 2.9) send()
HttpRequest::setResponseCallback/getCallback (dep. 2.9) setCompleteCallback/getCompleteCallback
messageBox(msg, title) (dep. 2.9) showAlert(msg, title, AlertStyle)
FontFreeType::setShareDistanceFieldEnabled (dep. 2.9.2) setGlobalSDFEnabled
Label::createWithBMFont(..., imageOffset, ...) (dep. 2.1) use the non-imageOffset overload
Label::updateBMFontScale() (dep. 2.1) updateFontScale()
Scheduler::performFunctionInCocosThread (dep. 2.1) runOnAxmolThread
hlookup::* tlx::* (axmol/tlx/hlookup.hpp)
axstd.h helpers axmol/tlx/*.hpp (split.hpp, charconv.hpp, flat_map.hpp, static_vector.hpp, …)
Application::initGLContextAttrs() (dep. 2.8) applicationWillLaunch() + setContextAttrs()
EventMouse::getCursorX/Y (dep. 2.2) removed — use getPoint() / getWorldPoint()
UTF8::getCharacterCountInUTF8String (dep. 2.8) text_utils::countUTF8Chars
Director::getGLView/setGLView (dep. 2.8) removed
Director::setGLDefaultValues (dep. 2.9) removed

13. Build system / CMake

New or renamed options (compare CMakeOptions.md in both branches):

v2 v3
AX_ENABLE_3D_PHYSICS AX_ENABLE_PHYSICS_3D
AX_ENABLE_MEDIA AX_ENABLE_VIDEO
AX_ENABLE_CONSOLE removed
AX_USE_COMPAT_GL removed
— AX_RENDER_API = auto | gl | mtl | d3d11 | d3d12 | vk (semicolon-separated list allowed, e.g. -DAX_RENDER_API=vk;gl)
— AX_ENABLE_VR (experimental, default FALSE)
— AX_ENABLE_WAYLAND (default FALSE)
— AX_ENABLE_EXT_SVG (default FALSE)
— AX_PROFILER_BACKEND = TRACY | NONE

Platform macros: AX_PLATFORM_PC → AX_PLATFORM_GLFW (cpp-tests now guard GLFW-only code with it).


14. Extensions

v2 v3
extensions/cocostudio (cocostudio::*, CSLoader, Armature, WidgetReader) split into extensions/sceneio (sceneio::*, readers/serialization) and extensions/sceneext (ax::ext::*, ActionTimeline runtime)
— new extensions/svg (AX_ENABLE_EXT_SVG, exported through axmol-ext.h)

extensions/axmol-ext.h still exists and now also pulls in the SVG extension.


15. Things you get for free (new in v3)

  • Multi-backend RHI: OpenGL(ES), Metal, D3D11, D3D12, Vulkan — selectable at build (AX_RENDER_API) and/or runtime (GraphicsCore::setPreferredBackend).
  • Compute shaders: rhi::ComputePipeline, GraphicsContext::dispatch().
  • VR / OpenXR: axmol/vr/*, AX_ENABLE_VR, XRInputEvent.
  • Unified pointer input with pressure/pen/ray support and XR input events.
  • WeakPtr, JobSystem, InputSystem, Environment, CommandLineArgs, SceneCompositor, RenderTexturePass, SamplerRegistry, VertexLayoutManager, MeshDataCache.
  • New widgets: ui::InputField, ui::TabView, ui::VideoPlayer with pluggable VideoController, ui::RadioButtonGroup.
  • Tracy profiler backend (AX_PROFILER_BACKEND=TRACY).

16. Suggested migration order

  1. Re-point every include: core/… → axmol/…, 2d/{Node,Scene,Camera,Component*} → scene/…, renderer/backend/… → rhi/…, ui/UI* → ui/*.
  2. Fix Color3B/Color4B/Color4F → Color32/Color, Quaternion → Quat, V3F_C4B_T2F → V3F_T2F_C4B (mind the field reorder).
  3. Fix Node::draw/visit overrides to take const SceneRenderState&; get the renderer via state.getRenderer().
  4. Convert touch/mouse listeners to PointerEventListener (drop the Event* argument, remove setSwallowTouches, key multi-touch on getPointerId()).
  5. Port backend:: → rhi:: (DriverBase::getInstance() → GraphicsCore::device() / axdrv, CommandBuffer → GraphicsContext, new* → create*, PixelBufferDescriptor → PixelBufferDesc).
  6. Update the app delegate (applicationWillLaunch + setContextAttrs) and main() (run() → launch(argc, argv)).
  7. Replace Configuration → Environment, StringUtils::format → fmt::format, AsyncTaskPool → getJobSystem(), TextFieldTTF → ui::InputField.
  8. Rewrite physics code against physics/2d (box2d) and physics/3d (Jolt).
  9. Update your CMake options (AX_RENDER_API, AX_ENABLE_PHYSICS_3D, AX_ENABLE_VIDEO, …).

Clone this wiki locally