Crystal Space
Welcome, Guest. Please login or register.
September 18, 2014, 06:59:42 pm

Login with username, password and session length
Search:     Advanced search
9018 Posts in 2051 Topics by 8478 Members
Latest Member: Annaatkinson
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  2d + 3d = crash
« previous next »
Pages: [1] Print
Author Topic: 2d + 3d = crash  (Read 4080 times)
woozie
Newbie
*
Posts: 4


View Profile
« on: May 08, 2006, 03:19:27 am »

using latest pseudo stable CS/CEL, compiled on latest mingw and mysy, windows xp pro. Trying to simply print text over a 3d room.
I know this has been covered in nemourous places but all the soultions ive read have led me to the code i got now, wich is only crashing the app as soon as i start it. editing around simpmap tutorial.

in simpmap.h ive got
Code:
csRef<iGraphics3D> g3d;
csRef<iGraphics2D> g2d;
csRef<iFontServer> fntsvr;
csRef<iFont> font;
and in the simpmap.cpp

Code:
void Simple::ProcessFrame ()
{
  // First get elapsed time from the virtual clock.
  csTicks elapsed_time = vc->GetElapsedTicks ();
 

 
//Mouse look 
   
                  int w = g3d->GetDriver2D ()->GetWidth()/2;  //sets w = top screen width
                  int h = g3d->GetDriver2D ()->GetHeight()/2; //sets h = to screen height.

 
                  int x = mouse->GetLastX(); 
                  int y = mouse->GetLastY();
                  view->GetCamera ()->GetTransform ().RotateThis (CS_VEC_TILT_DOWN, (y-h) * 0.01);
                  view->GetCamera ()->GetTransform ().RotateOther (CS_VEC_ROT_RIGHT, (x-w) * 0.01);
                  g3d->GetDriver2D ()->SetMousePosition (w, h);
                 
////////////////
 
 
csVector3 obj_move (0);
csVector3 obj_rotate (0);
 

 
//keyboard controls   
    if (kbd->GetKeyState (CSKEY_RIGHT))
    {
      obj_move = CS_VEC_RIGHT * 3.0f;
      //view->GetCamera ()->GetTransform ().RotateOther (CS_VEC_ROT_RIGHT, (x-w) * 0.01);
    }
    if (kbd->GetKeyState (CSKEY_LEFT))
    {
      obj_move = CS_VEC_LEFT * 3.0f;
      //view->GetCamera ()->GetTransform ().RotateOther (CS_VEC_ROT_RIGHT, (x-w) * 0.01);
    }
    if (kbd->GetKeyState (CSKEY_UP))
    {
      obj_move = CS_VEC_FORWARD * 3.0f;
      //view->GetCamera ()->GetTransform ().RotateThis (CS_VEC_TILT_DOWN, (y-h) * 0.01);
    }
    if (kbd->GetKeyState (CSKEY_DOWN))
    {
       obj_move = CS_VEC_BACKWARD * 3.0f;
       //view->GetCamera ()->GetTransform ().RotateThis (CS_VEC_TILT_DOWN, (y-h) * 0.01);
    } 
     


  collider_actor.Move (float (elapsed_time) / 1000.0f, 1.0f,
    obj_move, obj_rotate);




 // Tell 3D driver we're going to display 3D things.
 if (!g3d->BeginDraw (engine->GetBeginDrawFlags () | CSDRAW_3DGRAPHICS))
 return;
   //Tell the camera to render into the frame buffer.
 view->Draw ();
 
  ////////////////////////
 
   if (!g3d->BeginDraw (CSDRAW_2DGRAPHICS))
   return;
   int fg = g2d->FindRGB (255, 0, 0);  // Red.
   fntsvr = g2d->GetFontServer();
   font = fntsvr->LoadFont(CSFONT_COURIER);
   g2d->Write (font, 20, 20, fg, -1, "text");

 
}

void Simple::FinishFrame ()
{
  // Just tell the 3D renderer that everything has been rendered.
  g3d->FinishDraw ();
 
}

Anyone got any idea why this causes it to crash?
Logged

CS - Svn June 4th/06
Cel - Svn June 5th/06

Msys - 1.0.11-2004.04.30-1
MinGW - 5.0.2
CS winlibs - 0.99r0_021
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: May 08, 2006, 05:13:27 am »

Can you check in a debugger where it crashes exactly?

Greetings,
Logged
woozie
Newbie
*
Posts: 4


View Profile
« Reply #2 on: May 08, 2006, 06:05:50 am »

debugging the source it crashes when it hits the line

 
Code:
return csApplicationRunner<Simple>::Run (argc, argv);

now that doesnt seem like much help so i ran the executable through windows debugger, now I myself can only understand half this log but i dont know if any of you can get any help out of this.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Microsoft (R) Windows Debugger  Version 6.6.0003.5
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: C:\CS\omg.exe
Symbol search path is: *** Invalid ***
****************************************************************************
* Symbol loading may be unreliable without a symbol search path.           *
* Use .symfix to have the debugger choose a symbol path.                   *
* After setting your symbol path, use .reload to refresh symbol locations. *
****************************************************************************
Executable search path is:
ModLoad: 00400000 004f3000   image00400000
ModLoad: 7c900000 7c9b0000   ntdll.dll
ModLoad: 7c800000 7c8f4000   C:\WINDOWS\system32\kernel32.dll
ModLoad: 77f10000 77f57000   C:\WINDOWS\system32\GDI32.dll
ModLoad: 77d40000 77dd0000   C:\WINDOWS\system32\USER32.dll
ModLoad: 77dd0000 77e6b000   C:\WINDOWS\system32\ADVAPI32.DLL
ModLoad: 77e70000 77f01000   C:\WINDOWS\system32\RPCRT4.dll
ModLoad: 77c10000 77c68000   C:\WINDOWS\system32\msvcrt.dll
ModLoad: 7c9c0000 7d1d5000   C:\WINDOWS\system32\SHELL32.DLL
ModLoad: 77f60000 77fd6000   C:\WINDOWS\system32\SHLWAPI.dll
(c80.f08): Break instruction exception - code 80000003 (first chance)
eax=00341eb4 ebx=7ffde000 ecx=00000007 edx=00000080 esi=00341f48 edi=00341eb4
eip=7c901230 esp=0022fb20 ebp=0022fc94 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000202
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdll.dll -
ntdll!DbgBreakPoint:
7c901230 cc               int     3
0:000> g
ModLoad: 66500000 6650a000   C:\WINDOWS\system32\wbsys.dll
(c80.f08): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000000 ebx=00000000 ecx=000007cc edx=77e46190 esi=77e46180 edi=00000000
eip=7c918fea esp=0022e808 ebp=0022e87c iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246
ntdll!RtlpWaitForCriticalSection+0x5b:
7c918fea ff4010           inc  dword ptr [eax+0x10] ds:0023:00000010=????????
0:000> g
ModLoad: 773d0000 774d2000   C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
ModLoad: 5d090000 5d127000   C:\WINDOWS\system32\comctl32.dll
ModLoad: 10000000 1004b000   C:\CS\vfs.dll
ModLoad: 6fd00000 6fd12000   C:\CS\libz-cs.dll
ModLoad: 7c000000 7c054000   C:\CS\MSVCR70.dll
ModLoad: 76780000 76789000   C:\WINDOWS\system32\shfolder.dll
ModLoad: 00bc0000 00bf2000   C:\CS\csfont.dll
ModLoad: 00f70000 01016000   C:\CS\gl3d.dll
ModLoad: 5ed00000 5edcc000   C:\WINDOWS\system32\OPENGL32.DLL
ModLoad: 68b20000 68b40000   C:\WINDOWS\system32\GLU32.dll
ModLoad: 73760000 737a9000   C:\WINDOWS\system32\DDRAW.dll
ModLoad: 73bc0000 73bc6000   C:\WINDOWS\system32\DCIMAN32.dll
ModLoad: 01020000 010da000   C:\CS\glwin32.dll
ModLoad: 77c00000 77c08000   C:\WINDOWS\system32\VERSION.dll
ModLoad: 00c00000 00c13000   C:\CS\imgplex.dll
ModLoad: 010e0000 01247000   C:\CS\engine.dll
ModLoad: 01250000 01304000   C:\CS\csparser.dll
ModLoad: 09370000 093e1000   C:\CS\cssynldr.dll
ModLoad: 00c20000 00c38000   C:\CS\sndmanager.dll
ModLoad: 00c40000 00c68000   C:\CS\reporter.dll
ModLoad: 01310000 01342000   C:\CS\stdrep.dll
ModLoad: 77fe0000 77ff1000   C:\WINDOWS\system32\Secur32.dll
ModLoad: 093f0000 09468000   C:\CS\csopcode.dll
ModLoad: 5ad70000 5ada8000   C:\WINDOWS\system32\uxtheme.dll
ModLoad: 01350000 01356000   C:\WINDOWS\system32\ctagent.dll
ModLoad: 69000000 6967f000   C:\WINDOWS\system32\atioglxx.dll
ModLoad: 61dd0000 61dd6000   C:\WINDOWS\system32\MCD32.DLL
ModLoad: 0b9f0000 0ba2c000   C:\CS\shadermgr.dll
ModLoad: 0ba30000 0baae000   C:\CS\xmlshader.dll
ModLoad: 0beb0000 0bf03000   C:\CS\rendstep_std.dll
ModLoad: 0bf10000 0bfb7000   C:\CS\thing.dll
ModLoad: 0bfc0000 0bfe4000   C:\CS\csbmpimg.dll
ModLoad: 0bff0000 0c03f000   C:\CS\csddsimg.dll
ModLoad: 0c040000 0c064000   C:\CS\csgifimg.dll
ModLoad: 0c070000 0c0b1000   C:\CS\csjngimg.dll
ModLoad: 6ff80000 6ff9d000   C:\CS\libjpeg-cs.dll
ModLoad: 6ff00000 6ff36000   C:\CS\libmng-cs.dll
ModLoad: 0c0c0000 0c104000   C:\CS\csjpgimg.dll
ModLoad: 0c310000 0c34b000   C:\CS\thingldr.dll
ModLoad: 0c350000 0c369000   c:\progra~1\mcafee.com\vso\McVSSkt.dll
ModLoad: 71ab0000 71ac7000   C:\WINDOWS\system32\WS2_32.dll
ModLoad: 71aa0000 71aa8000   C:\WINDOWS\system32\WS2HELP.dll
ModLoad: 774e0000 7761d000   C:\WINDOWS\system32\ole32.dll
ModLoad: 0c380000 0c3d2000   C:\CS\frustvis.dll
ModLoad: 0c3e0000 0c42d000   C:\CS\glshader_cg.dll
ModLoad: 0c430000 0c5dc000   C:\CS\cg.dll
ModLoad: 0c5e0000 0c621000   C:\CS\cgGL.dll
ModLoad: 0cd50000 0cda3000   C:\CS\glshader_ps1.dll
ModLoad: 0cdc0000 0ce14000   C:\CS\glshader_fixed.dll
(c80.f08): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000000 ebx=00000032 ecx=0b6aa114 edx=00000001 esi=0022fe28 edi=00000005
eip=004035b9 esp=0022f8a0 ebp=0022f948 iopl=0         nv up ei pl nz na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010206
*** ERROR: Module load completed but symbols could not be loaded for image00400000
image00400000+0x35b9:
004035b9 8b10             mov     edx,[eax]         ds:0023:00000000=????????
0:000> g
(c80.f08): Access violation - code c0000005 (!!! second chance !!!)
eax=00000000 ebx=00000032 ecx=0b6aa114 edx=00000001 esi=0022fe28 edi=00000005
eip=004035b9 esp=0022f8a0 ebp=0022f948 iopl=0         nv up ei pl nz na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000206
image00400000+0x35b9:
004035b9 8b10             mov     edx,[eax]         ds:0023:00000000=????????
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Im starting to think something in the instalation might just be corrupt, if this doesnt give you any idea im going to try downloading and building CS/Cel again. then running it through.  Also some aditional info. Im using Dev cpp 4.9.9.2, graphics card is radeon 9800xt pro, all drivers are up to date. Also when the app is ran, the 3d window is opened and intializaed, nothing is shown but a black screen, it flickers twice (changes black to white really quickly) then crashes. Also if I remove the 2d functions in there, it runs fine.

« Last Edit: May 08, 2006, 06:08:45 am by woozie » Logged

CS - Svn June 4th/06
Cel - Svn June 5th/06

Msys - 1.0.11-2004.04.30-1
MinGW - 5.0.2
CS winlibs - 0.99r0_021
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #3 on: May 08, 2006, 07:26:11 am »

Can you check in a debugger that shows C++ line numbers please? Also make sure to compile Crystal Space and your application in debug mode so that you can see the actual line where it crashes.

Greetings,
Logged
yoshi
Newbie
*
Posts: 40


View Profile WWW
« Reply #4 on: May 08, 2006, 11:25:41 pm »

I'm not sure what the problem is, but when I was fiddling with font stuff, I would always get a program crash, too.

Make sure that you check all your pointers before you try to use them... so for instance, when you do
Code:
fntsvr = g2d->GetFontServer();
font = fntsvr->LoadFont(CSFONT_COURIER);
I would do
Code:
fntsvr = g2d->GetFontServer();
if(!fntsvr.isValid()) { ReportError("Couldn't get font server!"); return; }
font = fntsvr->LoadFont(CSFONT_COURIER);
if(!font.isValid()) { ReportError("Couldn't load font!"); return; }
(I might have gotten the isValid() function name wrong, but you get the idea.)

Another caveat: if you try to load a ttf font (it doesn't look like you're trying to do that, but if you decide to), make sure you request the right plugin, i.e. do

CS_REQUEST_PLUGIN("crystalspace.font.server.freetype2", iFontServer)

not

CS_REQUEST_FONTSERVER

because, as I discovered (the hard way and after much frustration), CS_REQUEST_FONTSERVER is a #define for the non-freetype font server, which cannot load ttf files.  You might already know this, but I had a hard time with it so I'm just putting it out there.

Good luck,
-Yoshi
Logged
woozie
Newbie
*
Posts: 4


View Profile
« Reply #5 on: May 17, 2006, 05:55:29 am »

Sorry it took me so long to respond, Anyway i solved this one myself. I was loading the font up in the OnInitialize section, like its done in waterdemo, and it didnt really like that. Ive got a couple of new questions though...

What I want to do (without using aws or cegui) is make...well pretty much the same thing as a consol, but...without using the pre built consol aswell, as that doesnt suit my needs.

I need the user to press a key, say enter. and it will print onto the screen a prompt and take a string, hitting enter closing the prompt again. now the printing is all fine, but when i use  kbd->GetKeyState the prompt is only displayed well the key is held, is there anyway of saying - if (key was pressed) - do this until key is pressed again? (the way ive currently got it is messy as it gets, a boolean, being set back and forth true or false to display the prompt)

And also how can I take in the string? I assume just basic cin wont work, with cs's keyboard objects handling everything.
 
The way im currently printing is just a function i made up quick, to simplify things.

Code:
bool printcon(int r, int g, int b,const char *str)
      {
            if (!g3d->BeginDraw (CSDRAW_2DGRAPHICS))
            {
                 return 0;               
            }                               
            font = g3d->GetDriver2D ()->GetFontServer()->LoadFont(CSFONT_LARGE);
            int glyphWidth, glyphHeight;
            font->GetMaxSize (glyphWidth, glyphHeight);
            int white = g3d->GetDriver2D ()->FindRGB (r, g, b);
            g3d->GetDriver2D ()->Write (font, 1,g3d->GetDriver2D ()->GetHeight () - (glyphHeight == -1? 20 : (glyphHeight+1)),white, -1, str);
           
      }

And of course by made up, its pulled out of snippets of code from various examples....Ive been using C/++ forever, just never got into oop, I had to go off and learn assembly instead >.<. im not quite used to thinking in the object oriented way yet =P

     
Logged

CS - Svn June 4th/06
Cel - Svn June 5th/06

Msys - 1.0.11-2004.04.30-1
MinGW - 5.0.2
CS winlibs - 0.99r0_021
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #6 on: May 17, 2006, 08:58:00 am »


I need the user to press a key, say enter. and it will print onto the screen a prompt and take a string, hitting enter closing the prompt again. now the printing is all fine, but when i use  kbd->GetKeyState the prompt is only displayed well the key is held, is there anyway of saying - if (key was pressed) - do this until key is pressed again? (the way ive currently got it is messy as it gets, a boolean, being set back and forth true or false to display the prompt)


Well best is to use event handling. Don't use GetKeyState() but act on the keys in the event handler. Maybe check out the input console plugin source code on how it does that.

Greetings,
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 7.245 seconds with 15 queries.