Hopefully someone can point me in the right direction.
//Called when application is started.
function OnStart()
{
//Create a layout with objects vertically centered.
//Set full screen mode.
app.SetScreenMode( "Full ");
//Create the main layout.
lay = app.CreateLayout( "Linear", "FillXY" );
//Create a GLView and add it to main layout.
glview = app.CreateGLView( 1, 1, "Fast2d" );
lay.AddChild( glview );
//Add the main layout to app.
app.AddLayout( lay );
app.SetDebugEnabled(false);
StartRendering();
}
function StartRendering()
{
//Render at 30 frames per second
setInterval( DrawFrame, 1000/30 );
}
function DrawFrame()
{
//DrawFrameAdvanced uses the GLView context
DrawFrameAdvanced();
//Render the graphics
glview.Render();
}
function DrawFrameAdvanced()
{
//DrawFrameAdvanced uses GLView context - this will allow us to perform
//more advanced drawing operations, very similar to HTML5 Canvas
var context = glview.GetContext();
//Save the current GLView transform so we can restore
//it later once we have finished drawing
context.save();
// code goes here...
context.strokeStyle = "white";
context.lineWidth = 10;
context.lineCap = 'square';
context.beginPath(); // This is where is it errors out.
context.moveTo(20, 0);
context.lineTo(100, 0);
context.stroke();
context.closePath();
//Restore the previous GLView transform that we saved earlier.
//This means that any transforms we applied while drawing will
//now be discarded.
context.restore();
}