Stratos: Punto de Encuentro de Desarrolladores

¡Bienvenido a Stratos!

Acceder

Foros





Ibutton-draw() Crashes

Iniciado por , 31 de Octubre de 2005, 08:53:12 PM

« anterior - próximo »

 another question: i try to use the button class, which is a nice idea btw, but either i am too much "noob" to C and SDL (which could well be), or the class does have an error i don't get debugged at the moment:

i do everything like in the GUI demo code:

definition of the few needed vars:

   //vars for crm32 GUI stuff
   Uint32 btnServerOpen = 0;
   int btnID;


in the init phase:

   //must initiate crm32 also
   if(CRM32Pro_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)<0) {
       ILogSystem.Msg(LOG_NORMAL," · [LOG] - Couldn´t initialize CRM32Pro: %s\n",SDL_GetError());
       return 1;
   }

   [..]

   ILogSystem.Init("GUI.log",LOG_FILE,LOG_NORMAL,"GuiLog");
   btnServerOpen = IButton->Load(GFX_RESOURCE,"btnServerOpen");

   if ( btnServerOpen ) ILogSystem.Msg(LOG_NORMAL,"done loading");
   else ILogSystem.Msg(LOG_NORMAL,"loading error");
   //there is no bug here - the dpf is found and the image loaded



in my main loop:

       //crm32 button stuff:
       IButton->Check();
       IButton->ForceDraw();
       //everything is fine until next line, where it quits without any notice
       ILogSystem.Msg(LOG_NORMAL,"IButton->Draw");



what's wrong here? again im using the GNU C version and the editor i found at the main-page.


thanks for any help,
atomhamster

 i copied your demo initialisation to my initAll() method and only have your code left. also i copied the dpf from the example. the init code crashed and leaves this note in the log:

· Executing at Mon Oct 31 21:23:43 2005
· Running on AMD processor - AthlonXP(B) - MMX - SSE
· Selected 'AthlonXP' optimized code path.

· CRM32Pro successfully initiated.
· [ICursor->Init()] Error: Screen surface not present.

i really don't know what could be wrong. its the exact same code with same settings for the project and all. when i copy the complete demo to my poject, it compiles and runs just fine?!

could it be connected to the variable-definition? i do this outside the main-function, you inside? i'm not enough into c, but it shouldn't be such a problem?


any help appreciated,
atomhamster

TheAzazel

 Have you set up video mode with SDL_VideoMode(...)?

You have to add this code after CRM32Pro_Init() and before others graphics functions:


screen=SDL_VideoMode(...)


screen is a global pointer to SDL_Surface that almost every CRM32Pro function uses it.

Let me know if this help you.

On the other hand, tomorrow I will compile a v4.7x with mingw32 for you, no problem at all :)

Happy halloween!  (twist)

 thanks for the quick answer / detil question. yes, SDL_SetVideoMode() is there:


   //must initiate crm32 also
   if(CRM32Pro_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)<0) {
       ILogSystem.Msg(LOG_NORMAL," · [LOG] - Couldn´t initialize CRM32Pro: %s\n",SDL_GetError());
       return 1;
   }
   atexit(SDL_Quit);

   screen = SDL_SetVideoMode(scrWidth,scrHeight,scrBit, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_SRCALPHA);
   if ( screen == NULL ) {
       printf("cant create screen%s\n", SDL_GetError());
       exit(1);
   }

   imgBullet = SDL_LoadBMP(IMG_BULLET);
   imgCursorWall = SDL_LoadBMP(IMG_CURSOR_WALL);
   SDL_SetAlpha(imgCursorWall, SDL_SRCALPHA, 210);

   imgFont = SDL_LoadBMP(FONT_IMG);
   SFont   = SFont_InitFont(imgFont);
   imgFontBig = SDL_LoadBMP(FONT_IMGBIG);
   SFontBig   = SFont_InitFont(imgFontBig);


   //crm32 button
   ILogSystem.Init("GUI.log",LOG_FILE,LOG_NORMAL,"GuiLog");
   btnServerOpen = IButton->Load(GFX_RESOURCE,"btnServerOpen");
[...]



happy helloween!  :)
atomhamster

 and once again me!  :)

no, i'm still not drunk, but i found out, whats the problem! the difference in both codes (and one hint in the compiler output) was the variable "screen". i used it to store the SDL screen. CRM uses it to store the SDL screen. that's it: use it double and have it defined local in your code and it will crash CRM without any hint.

i think, that's one thing you could possibly change or stress this point in the documentation and in samples.


now it works and i have the button clickable on screen. very nice. maybe though there could arise a problem with the pixel-defined positions of the buttons: if the screen size changes, you need to change the positions by hand. on the other hand, the buttons will need to be placed vey carefully anyways, when they don't have alpha.


thanks for the help and the cool tool - once again  :)

cheers,
atomhamster

TheAzazel

 Well done! I could imagine for your posted logs that the problem was related to "screen" global variable.

In fact, the latest version(4.7x), all functions and global variables have been added to a new main interface to avoid problems like the one you have had.

I could see on your posted code that you use another function to load fonts(I imagine you already know that CRM32Pro has its own fonts function and you could load/store it on DPF too) and also, I saw you load BMP... again, I imagine you know that CRM32Pro can load/store image(with/without alpha per pixel on DPF).

Well, as soon as I have ready a "release" of v4.7x for mingw32, I will post its url here, so you will be the first one to test the new and final library interface :)

cheers

yes, i know both functions are there in your library, but a while ago, i couldn't use crm32 at all, because there was no mingw32 version. i used sdl_font, but i think that's what you also included in crm32? i usually don't like bmp too much and prefer png at the moment. so, maybe i stick with loading images by hand. i also makes live a little easier while you are not final with the graphical design. otherwise i would have to update the  dpf all the time  ;)

im looking forward to the new api! i will have some more time a thursday  ;)

TheAzazel

Cita de: "atomhamster"yes, i know both functions are there in your library, but a while ago, i couldn't use crm32 at all, because there was no mingw32 version. i used sdl_font, but i think that's what you also included in crm32? i usually don't like bmp too much and prefer png at the moment. so, maybe i stick with loading images by hand. i also makes live a little easier while you are not final with the graphical design. otherwise i would have to update the  dpf all the time  ;)

im looking forward to the new api! i will have some more time a thursday  ;)
So for you, mingw32 version was cool :).

You were "almost" right about sdl_font, I saw it and I like it so I rewrote its functions on latest CRM32Pro with deep changes (to acomodate it to CRM32Pro). I know that TTF fonts are under copyrights...so the best way(for my understanding) is to use a surface and an array with all needed information.

Dont worry about DPF, they are the same format as a few years ago and I will not change it to avoid problems with existing ones. If I change something *vital*, I will read old format and update it to new one on a transparent way, so DPF design is fully stable.

Thanks to Warchief for his ideas, last summer I added PNG support using EditorDPF so you could use BMP or PNG with alpha per pixel!

Im working on final api, if you have any suggestions, ideas or so on...please, do not hesitate to contact me.

I have to send you the draft of v4.7x for mingw32...I dont forget you :), I will try that between today and tomorrow...Im very busy on my work...(asco)

cheers and happy coding!

hmmm, when you are asking for suggestions, maybe i have one:

it would be nice, to have some out-of-the-box functions to find a server in a local network and have a serverlist for local nets. this might be more work then you had in mind, but might be nice feature. i read, you are working on udp already - maybe it fits in?

i know a little about the "busy at work" tuff, too - so don't stress yourself!
thanks,
atomhamster






Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.