Files
cell/scripts/modules/sdl_render.js
John Alanbrook 6705ce8980
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
sdl renderer
2025-04-23 20:39:07 -05:00

120 lines
2.2 KiB
JavaScript

var render = {}
var context
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"
}
// for (var i in default_conf)
// config[i] ??= default_conf[i]
prosperon.window = prosperon.engine_start({width:500,height:500})
console.log(prosperon.window)
context = prosperon.window.make_renderer("vulkan")
}
// 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)
{
if (typeof image === 'string')
image = graphics.texture(image)
rect.width ??= image.texture.width
rect.height ??= image.texture.height
context.texture(image.texture, rect);
}
render.clip = function(rect)
{
context.clip(rect)
}
render.circle = function(pos, radius, color = Color.white)
{
}
render.ellipse = function(pos, radiuses, color = Color.white)
{
}
render.line = function(points, color = Color.white)
{
context.draw_color(color)
context.line(points)
}
render.point = function(pos, color = Color.white)
{
context.draw_color(color)
context.point([pos])
}
render.rectangle = function(rect, color = Color.white)
{
}
render.geometry = function(mesh, pipeline)
{
}
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