Skip to content

Commit

Permalink
Partial commit: Removed texture atlasing. Instead, framebuffers are n…
Browse files Browse the repository at this point in the history
…ow 100% compatible with textures. Added viewport entity to replace camera and give higher-level framebuffer access and flexibility.
  • Loading branch information
jcorks committed Nov 10, 2023
1 parent 62177c9 commit 5dd75c7
Show file tree
Hide file tree
Showing 55 changed files with 1,746 additions and 1,983 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/lua/1-Entity/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ room:attach(r2);

local display = Topaz.ViewManager.getDefault();
display:setName("Example 1");
display:setRoot(room);
display:getViewport():attach(room);


2 changes: 1 addition & 1 deletion examples/lua/12-Game/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Topaz.Lua.import('piece.lua');


Game.Parameters.Manager = Game.createManager();
Topaz.ViewManager.getDefault():setRoot(Game.Parameters.Manager);
Topaz.ViewManager.getDefault():getViewport():attach(Game.Parameters.Manager);


2 changes: 1 addition & 1 deletion examples/lua/3-Input/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,4 @@ manager:attach(createInputListExample());

-- Finally, insert the base of the tree into
-- the default display itself.
Topaz.ViewManager.getDefault():setRoot(manager);
Topaz.ViewManager.getDefault():getViewport():attach(manager);
2 changes: 1 addition & 1 deletion examples/lua/4-Assets/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ display:addParameterCallback(

reposition();

display:setRoot(entity);
display:getViewport():attach(entity);
2 changes: 1 addition & 1 deletion examples/lua/5-Automation/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ root:attach(createRectangleLinear());
root:attach(createRectangleAccel());
root:attach(createRectangleSlow());

Topaz.ViewManager.getDefault():setRoot(root);
Topaz.ViewManager.getDefault():getViewport():attach(root);

2 changes: 1 addition & 1 deletion examples/lua/6-Text/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ ent.update('Hello world!\nThis is text.');



Topaz.ViewManager.getDefault():setRoot(ent);
Topaz.ViewManager.getDefault():getViewport():attach(ent);


2 changes: 1 addition & 1 deletion examples/lua/7-Particles/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ Topaz.Input.addPointerListener(
end
}
);
Topaz.ViewManager.getDefault():setRoot(emitter);
Topaz.ViewManager.getDefault():getViewport():attach(emitter);
2 changes: 1 addition & 1 deletion examples/lua/8-Shape3D/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ b:setScale({x=0.7, y=0.3, z=0.3})


a:attach(b);
Topaz.ViewManager.getDefault():setRoot(a);
Topaz.ViewManager.getDefault():getViewport():attach(a);
2 changes: 1 addition & 1 deletion examples/lua/9-Object2D/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ Topaz.Input.addPointerListener(
);

room:attach(floor);
Topaz.ViewManager.getDefault():setRoot(room);
Topaz.ViewManager.getDefault():getViewport():attach(room);


2 changes: 1 addition & 1 deletion examples/matte/1-Entity/main.mt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ room.attach(child:r2);

@:display = Topaz.ViewManager.getDefault();
display.setName(name:"Example 1");
display.setRoot(newRoot:room);
display.getViewport().attach(child:room);


2 changes: 1 addition & 1 deletion examples/matte/12-Game/main.mt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@:createManager = import(module:'manager.mt');
@:Parameters = import(module:'parameters.mt');
Parameters.Manager = createManager();
Topaz.ViewManager.getDefault().setRoot(newRoot: Parameters.Manager);
Topaz.ViewManager.getDefault().getViewport().attach(child: Parameters.Manager);


2 changes: 1 addition & 1 deletion examples/matte/3-Input/main.mt
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,4 @@ manager.attach(child:createInputListExample());

// Finally, insert the base of the tree into
// the default display itself.
Topaz.ViewManager.getDefault().setRoot(newRoot: manager);
Topaz.ViewManager.getDefault().getViewport().attach(child: manager);
2 changes: 1 addition & 1 deletion examples/matte/4-Assets/main.mt
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ display.addParameterCallback(

reposition();

display.setRoot(newRoot:entity);
display.getViewport().attach(child:entity);
2 changes: 1 addition & 1 deletion examples/matte/5-Automation/main.mt
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@ root.attach(child:createRectangleLinear());
root.attach(child:createRectangleAccel());
root.attach(child:createRectangleSlow());

Topaz.ViewManager.getDefault().setRoot(newRoot:root);
Topaz.ViewManager.getDefault().getViewport().attach(child:root);

2 changes: 1 addition & 1 deletion examples/matte/6-Text/main.mt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ ent.update(text:'Hello world!\nThis is text.');



Topaz.ViewManager.getDefault().setRoot(newRoot:ent);
Topaz.ViewManager.getDefault().getViewport().attach(child:ent);


2 changes: 1 addition & 1 deletion examples/matte/7-particles/main.mt
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ Topaz.Input.addPointerListener(
}
}
);
Topaz.ViewManager.getDefault().setRoot(newRoot:emitter);
Topaz.ViewManager.getDefault().getViewport().attach(child:emitter);
2 changes: 1 addition & 1 deletion examples/matte/8-Shape3D/main.mt
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ b.setScale(value:{x:0.7, y:0.3, z:0.3})


a.attach(child:b);
Topaz.ViewManager.getDefault().setRoot(newRoot:a);
Topaz.ViewManager.getDefault().getViewport().attach(child:a);
2 changes: 1 addition & 1 deletion examples/matte/9-Object2D/main.mt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ Topaz.Input.addPointerListener(
);

room.attach(child:floor);
Topaz.ViewManager.getDefault().setRoot(newRoot:room);
Topaz.ViewManager.getDefault().getViewport().attach(child:room);


27 changes: 27 additions & 0 deletions include/topaz/assets/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,33 @@ void topaz_image_set_frame_from_texture(
);


/// Sets a frame to be a texture proxy. This means
/// the texture is being lent to the image with no modification,
/// making the image a wrapper for the texture.
///
/// Note that the Image instance will not modify proxy'd
/// texture frames in any way, so its up to the caller
/// to ensure that the texture state matches the image state,
/// such as image vs texture size. Its also up to the caller
/// to ensure that the lifetime of the texture matches that
/// of the image, as the image will not destroy the texture,
/// nor will the image check of the proxy texture is valid.
///
/// This is not normally used and is mostly for implementation
/// purposes, but is exposed in case someone wants to do
/// some more performant image work.
///
/// (No script mapping)
///
void topaz_image_set_frame_from_texture_proxy(
/// Image to modify
topazAsset_t * image,

uint32_t frame,

/// Texture to clone from.
topazRenderer_Texture_t * t
);


/// Gets the texture handle for the frame.
Expand Down
2 changes: 1 addition & 1 deletion include/topaz/backends/api/renderer_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ struct topazRenderer_FramebufferAPI_t {
void * (*renderer_framebuffer_create) (topazRendererAPI_t *, topazRenderer_FramebufferAPI_t *);
void (*renderer_framebuffer_destroy) (void *);


void * (*renderer_framebuffer_get_texture) (void *);
int (*renderer_framebuffer_resize)(void *, int w, int h);
void * (*renderer_framebuffer_get_handle)(void *);
int (*renderer_framebuffer_get_raw_data)(void *, uint8_t *);
Expand Down
114 changes: 1 addition & 113 deletions include/topaz/backends/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,6 @@ enum topazDisplay_Parameter {

};

/// Every display has built in framebuffers that can be
/// used and exchanged between for advanced rendering effects.
///
typedef enum topazDisplay_Framebuffer topazDisplay_Framebuffer;
enum topazDisplay_Framebuffer {
/// The default framebuffer.
topazDisplay_Framebuffer_A,
/// The second framebuffer.
topazDisplay_Framebuffer_B,
/// The 3rd framebuffer.
topazDisplay_Framebuffer_C,
/// The 4th framebuffer.
topazDisplay_Framebuffer_D
};


/// Callback for responding to display events,
typedef void (*topaz_display_callback)(
Expand Down Expand Up @@ -250,48 +235,12 @@ void topaz_display_destroy(
topazDisplay_t * display
);


/// Retrieves the camera associated with the display thats
/// used for 2d operations. This camera is used when the display is set as
/// the main display. see topazViewManager_t
///
topazEntity_t * topaz_display_get_2d_camera(
/// The display to query.
topazDisplay_t * display
);

/// Retrieves the camera associated with the display thats
/// used for 3d operations. This camera is used when the display is set as
/// the main display. see topazViewManager_t
///
topazEntity_t * topaz_display_get_3d_camera(
/// The display to query.
topazEntity_t * topaz_display_get_viewport(
topazDisplay_t * display
);






/// Gets the framebuffer specified.
topazRenderer_Framebuffer_t * topaz_display_get_framebuffer(
/// The disply in question.
topazDisplay_t * display,
/// The framebuffer to get.
topazDisplay_Framebuffer which
);

/// Sets the framebuffer as the main framebuffer. This framebuffer
/// is rendered into the display every frame.
void topaz_display_use_framebuffer(
/// The display to modify.
topazDisplay_t * display,
/// The framebuffer to use.
topazDisplay_Framebuffer which
);


/// Sets a custom post-processing rendering that affects how the
/// framebuffer is rendered to the display. The default in any case
/// is just to take the framebuffer texture and map it to
Expand Down Expand Up @@ -323,35 +272,6 @@ topazRenderer_Framebuffer_t * topaz_display_get_main_framebuffer(
topazDisplay_t * display
);

/// Forces clearing of the results of drawing stored within the current framebuffer.
///
void topaz_display_clear_main_framebuffer(
/// The display to modify
topazDisplay_t * display,

/// which information channel to clear.
topazRenderer_DataLayer layer
);


/// Gets the contents of the current framebuffer and
/// puts the data into an image asset frame.
/// The input image is cleared, resized to match the
/// framebuffer size, and given one frame which matches the
/// the framebuffer data.
///
/// NOTE: in general, this operation is considered "slow" as
/// it requires a lot of communication between the backend
/// renderer and engine, which are most likely on different
/// devices. Use sparringly!
void topaz_display_capture_main_framebuffer(
/// The display to query.
topazDisplay_t * display,
/// The image to populate.
topazAsset_t * image
);





Expand Down Expand Up @@ -417,15 +337,6 @@ float topaz_display_get_parameter(



/// Sets whether clearing of the framebuffer's contents is done automatically.
/// The default is "true".
///
void topaz_display_auto_clear_framebuffer(
/// The display to modify.
topazDisplay_t * display,
/// Whether to auto-update.
int enable
);



Expand Down Expand Up @@ -494,29 +405,6 @@ void topaz_display_remove_callback(
);


/// Returns the toplevel Entity.
///
/// From here, you can
/// set the Entity that holds the toplevel of the project.
/// By default there is none.
topazEntity_t *topaz_display_get_root(
/// The context to query.
const topazDisplay_t * display
);


/// Sets the root entity for the context.
/// From this entity, all other entities will be updated.
/// topaz handles entities in a hierarchical structure,
/// so the root must be populated and managed.
void topaz_display_set_root(
/// The context to modify.
topazDisplay_t * display,

/// The new root to use.
topazEntity_t * newRoot
);



/// Updates display with input visual data that is
Expand Down
Loading

0 comments on commit 5dd75c7

Please sign in to comment.