Files
cell/scripts/modules/sdl_render.js
John Alanbrook 85ee724754
Some checks failed
Build and Deploy / build-macos (push) Failing after 5s
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
add texture mode for renderer
2025-05-11 09:34:31 -05:00

126 lines
2.3 KiB
JavaScript

var render = {}
var context
var util = use('util')
render.initialize = function(config)
{
var default_conf = {
title:`Prosperon [${prosperon.version}-${prosperon.revision}]`,
width: 1280,
height: 720,
// icon: graphics.make_texture(io.slurpbytes('icons/moon.gif')),
high_dpi:0,
alpha:1,
fullscreen:0,
sample_count:1,
enable_clipboard:true,
enable_dragndrop: true,
max_dropped_files: 1,
swap_interval: 1,
name: "Prosperon",
version:prosperon.version + "-" + prosperon.revision,
identifier: "world.pockle.prosperon",
creator: "Pockle World LLC",
copyright: "Copyright Pockle World 2025",
type: "game",
url: "https://prosperon.dev"
}
config.__proto__ = default_conf
prosperon.window = prosperon.engine_start(config)
context = prosperon.window.make_renderer()
context.logical_size([config.resolution_x, config.resolution_y], config.mode)
}
render.sprite = function(sprite)
{
context.sprite(sprite)
}
// img here is the engine surface
render.load_texture = function(surface)
{
return context.load_texture(surface)
}
var current_color = Color.white
render.image = function(image, rect, rotation, anchor, shear, info)
{
// rect.width = image.rect_px.width;
// rect.height = image.rect_px.height;
image.texture.mode(info.mode)
context.texture(image.texture, image.rect_px, rect, rotation, anchor);
}
render.clip = function(rect)
{
context.clip(rect)
}
render.line = function(points)
{
context.line(points)
}
render.point = function(pos)
{
context.point(pos)
}
render.rectangle = function(rect)
{
context.rects([rect])
}
render.rects = function(rects)
{
context.rects(rects)
}
render.pipeline = function(pipe)
{
// any changes here
}
render.settings = function(set)
{
if (!set.color) return
context.draw_color(set.color)
}
render.geometry = function(image, mesh, pipeline)
{
context.geometry(image, mesh)
}
render.slice9 = function(image, rect, slice, info, pipeline)
{
context.slice9(image.texture, image.rect_px, util.normalizeSpacing(slice), rect);
}
render.get_image = function(rect)
{
return context.get_image(rect)
}
render.clear = function(color)
{
if (color) context.draw_color(color)
context.clear()
}
render.present = function()
{
context.present()
}
render.camera = function(cam)
{
context.camera(cam);
}
return render