selftiesoftware / core

The core integration of Reposcript into web technologies
Other
4 stars 0 forks source link

investigate GPU acceleration #17

Open oleegholm opened 8 years ago

oleegholm commented 8 years ago

current performance limit

http://repocad.com/editor.html#performanceTest

Jegp commented 8 years ago

This could be implemented in another Printer class which takes a canvas (HTMLCanvasElement) and extracts a WebGL rendering context. If something crashes we should revert to the simple CanvasPrinter. The code could look something like this:

object CanvasPrinter {

  def apply(canvas: HTMLCanvasElement) : CanvasPrinter = {
     // try getting the WebGL context
     // If failed, return a standard CanvasPrinter
  }
}

trait CanvasPrinter extends Printer {
  // (val's without definitions inside a trait is an abstract value that must be implemented in children)
  val canvasCenter: Vector2D // The center of the canvas
  val windowCenter: Vector2D // The center of the browser window 
}

class 2DCanvasPrinter(context: Canvas) extends CanvasPrinter { ... }
class WebGlCanvasPrinter(context : raw.WebGLRenderingContext) { ... }

This would then be called by the user like this: CanvasPrinter(canvas) - this redirects to the apply method in the CanvasPrinter object. Which is cool, because the logic about what printer is actually returned is hidden from the user.

One thing to note is that all the draw functions (like arc, line etc.) does not draw directly, but calls the addAction method which basically creates a stack of all the drawing functions the user would like to perform -- but waits to apply them when the whole rendering context is complete. I'm not sure this is a good idea, so feel free to play around with this.

IstvanM commented 8 years ago

Hey, I think there is an issue with the page. The some source codes don't load up when you open any examples (links). For the performanceTest is the same issue. But actually some other designs were slow a bit too.

Jegp commented 8 years ago

Yeah, the performanceTest script is probably broken (I get a red error in the bottom of the page). some of the scripts are not updated after the syntax or type restrictions changed. I'd like to fix this with a versioning system and a more stable CI. But for now I must admit I don't really care. And we do have a bit of performance problems, but I think the WebGL stuff will make it much better.

oleegholm commented 8 years ago

but the script syntax has not changed, or?? If it has, let me know what the changes are, and I will update the scripts in the library (and perhaps do some cleaning, deleting the not-so-meaningfil drawings).

2016-02-25 22:05 GMT+01:00 Jens Egholm notifications@github.com:

Yeah, the performanceTest script is probably broken (I get a red error in the bottom of the page). some of the scripts are not updated after the syntax or type restrictions changed. I'd like to fix this with a versioning system and a more stable CI. But for now I must admit I don't really care. And we do have a bit of performance problems, but I think the WebGL stuff will make it much better.

— Reply to this email directly or view it on GitHub https://github.com/repocad/web/issues/17#issuecomment-188988209.

Jegp commented 8 years ago

Well we lowecased everything which means that 'h' and 'H' are clashing. I also introduced a warning when there is reference ambiguity, so the 'font' script for instance doesn't compile anymore. The ambiguity parsing can be optimised to infer a value based on its type later on. But for now we're just giving up.