Canvas.setContent() crashes Torque
by Johnathon · in Torque Game Engine · 11/09/2007 (4:22 pm) · 3 replies
Hello everyone, I have created a simple control and I am attempting to push it to the canvas, but when I use the Canvas.setContent method the engine crashes. I do not recieve any error messages in the console log or anything. Could someone please point me in the right direction ?
This is the gui code control I am using, I just copied it straight out of the starter.fps mainmenu gui. I had created my own, but it crashed so I tried a pre-existing one to see if it would fix the problem and it did not.
All of my files are being executed as well (according to the console log)
mainmenu.gui
I create a canvas with the following code.
viewport.cs
and I attempt to push the gui to the canvas in the following code, I tried both PushDialog() & setContent and they would both crash the engine.
init.cs
base.cs
Thanks in advance!
This is the gui code control I am using, I just copied it straight out of the starter.fps mainmenu gui. I had created my own, but it crashed so I tried a pre-existing one to see if it would fix the problem and it did not.
All of my files are being executed as well (according to the console log)
mainmenu.gui
new GuiChunkedBitmapCtrl(MainMenuGui) {
Profile = "GuiContentProfile";
HorizSizing = "width";
VertSizing = "height";
position = "0 0";
Extent = "640 480";
MinExtent = "8 8";
Visible = "1";
bitmap = "./background";
useVariable = "0";
tile = "0";
helpTag = "0";
};I create a canvas with the following code.
viewport.cs
function createViewport(%title)
{
echo("Creating viewport canvas.");
videoSetGammaCorrection($pref::OpenGL::gammaCorrection);
//create the viewport and assign a resolution
%newCanvas = createCanvas(%title);
if (!%newCanvas)
{
quitWithErrorMessage("You can only have one instance of " @ %title @ " running at a time.");
}
setOpenGLTextureCompressionHint( $pref::OpenGL::compressionHint );
setOpenGLAnisotropy( $pref::OpenGL::textureAnisotropy );
setOpenGLMipReduction( $pref::OpenGL::mipReduction );
setOpenGLInteriorMipReduction( $pref::OpenGL::interiorMipReduction );
setOpenGLSkyMipReduction( $pref::OpenGL::skyMipReduction );
setScreenMode(800,600,16,false);
OpenALInitDriver();
}and I attempt to push the gui to the canvas in the following code, I tried both PushDialog() & setContent and they would both crash the engine.
init.cs
function OnStart()
{
Parent::OnStart();
echo("------ Initializing Base ------");
echo("Assigning defualt video settings.");
//Assign default video settings
$pref::Video::allowOpenGL = true;
$pref::Video::displayDevice = "OpenGL";
//location where mission files are stored.
$server::MissionFiles = "*/missions/*.mis";
//Get this game rolling
exec("./client/viewport.cs");
exec("./base.cs");
createViewport($gameName);
InitializeClient();
}base.cs
function InitializeClient()
{
echo ("------ Initializing " @ $gameName @ " client ------");
exec("./client/client.cs");
exec("./Client/movement.cs");
exec("./gui/mainMenu.gui");
%conn = new GameConnection(ServerConnection);
%conn.ConnectLocal();
Canvas.setContent(MainMenuGui);
}If I comment out the Canvas.setContent method the engine runs, I uncomment the method and I recieve a GPF. Thanks in advance!
#2
Taking it from example/common/ui/defaultProfiles.cs:
11/10/2007 (6:48 am)
Do you have GuiContentProfile created before loading mainmenu? (as it used as profile in your gui)Taking it from example/common/ui/defaultProfiles.cs:
if(!isObject(GuiContentProfile)) new GuiControlProfile (GuiContentProfile)
{
opaque = true;
fillColor = "255 255 255";
};
#3
Thanks!
11/10/2007 (10:59 am)
Thanks, I copied the defaultprofiles.cs script into my projects directory and executed it and it fixed it. Just executing the above code didn't fix it. I needed the whole script.Thanks!
Torque Owner Johnathon
It looks like everything was executed and compiled ok, any thoughts or suggestions?