Some checks failed
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-windows (CLANG64) (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
130 lines
2.3 KiB
JavaScript
130 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"
|
|
}
|
|
|
|
prosperon.window = prosperon.engine_start({width:500,height:500})
|
|
context = prosperon.window.make_renderer()
|
|
}
|
|
|
|
render.sprite = function(sprite)
|
|
{
|
|
|
|
context.sprite(sprite)
|
|
}
|
|
|
|
// img here is the engine surface
|
|
render.load_texture = function(img)
|
|
{
|
|
if (!img.surface)
|
|
throw new Error('Image must have a surface.')
|
|
|
|
if (img.texture)
|
|
throw new Error('Image has already been uploaded to GPU.')
|
|
|
|
img.texture = context.load_texture(img.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;
|
|
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
|