Game Development Community

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
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!

#1
11/09/2007 (4:23 pm)
Below is my console log, it doesn't show anything wrong (as far as I could tell)

//-------------------------- 11/9/2007 -- 17:13:37 -----
Parsing startup arguments
Engine Initialization completed.
Loading compiled script Base/Init.cs.
Initializing engine
------ Initializing Base ------
Assigning defualt video settings.
Compiling Base/client/viewport.cs...
Loading compiled script Base/client/viewport.cs.
Loading compiled script Base/base.cs.
Creating viewport canvas.
Video Init:
   Accelerated OpenGL display device detected.
   Accelerated D3D device detected.
   Voodoo 2 display device not detected.

Activating the OpenGL display device...
Activating the OpenGL display device...
Setting screen mode to 800x600x32 (w)...
Creating a new window...
Acquiring a new device context...
Pixel format set:
  32 color bits, 24 depth bits, 8 stencil bits
Creating a new rendering context...
Making the new rendering context current...
OpenGL driver information:
  Vendor: NVIDIA Corporation
  Renderer: GeForce Go 6150/PCI/SSE2/3DNOW!
  Version: 2.1.0
OpenGL Init: Enabled Extensions
  ARB_multitexture (Max Texture Units: 4)
  EXT_blend_color
  EXT_blend_minmax
  EXT_compiled_vertex_array
  NV_vertex_array_range
  EXT_texture_env_combine
  EXT_packed_pixels
  EXT_fog_coord
  ARB_texture_compression
  EXT_texture_compression_s3tc
  (ARB|EXT)_texture_env_add
  EXT_texture_filter_anisotropic (Max anisotropy: 16)
  WGL_EXT_swap_control
OpenGL Init: Disabled Extensions
  EXT_paletted_texture
  3DFX_texture_compression_FXT1

------ Initializing MyGame client ------
Loading compiled script Base/client/client.cs.
Loading compiled script Base/Client/movement.cs.
Loading compiled script Base/gui/mainMenu.gui.

It looks like everything was executed and compiled ok, any thoughts or suggestions?
#2
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
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!