Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - stevend

Pages: [1] 2
1
General / issue deciding on gui and issues using win32 and cpGUI!!!
« on: January 20, 2010, 04:00:47 am »
thanks for everybodys help here! i have having some issue at the moment deciding which direction i should go for GUI!

i tried to integrate with win32, and i got a window up and i can draw into a box in the win 32 window, but sfml is not firing any event commands for key press events and stuff now. (instead of me showing code, image me taking the event and keypress code from the tutorial and adding it to the win32 tutorial). do i maybe have to proccess events throught win32 api now :( ??

GetEvent(); is returning that the event stack is empty i presume.

second

i tried cpGUI with all the elements.

first i tried to link with cpGUI.lib and all goes fine. when i JUST declare cpGuiContainer... and nothing else ... i get linker errors....

Quote
Error   1   error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)   MSVCRT.lib   2dtile


and more

so i have included cpGUI.cpp and cpGUI.h into my project and tried to build them, but when i do, i get these linker errors...

Quote
Error   1   error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::White" (?White@Color@sf@@2V12@B)   cpGUI.obj   2dtile


Error   2   error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Black" (?Black@Color@sf@@2V12@B)   cpGUI.obj   2dtile




and a few more...

so i thought maybe it wasnt linking with the graphics library because i use #pragma comment to link, so i added #pragma comment(lib, "sfml-graphics.lib")  to cpGUI.h but it didnt help at all..

( i also tried linking through build properties... no luck)

any ideas?

i thought i should mention i like the idea of cpGUI better than using win32 so that is top priority.

2
Graphics / program crashes on exit
« on: January 20, 2010, 01:51:31 am »
oh right i suppose i should do that too.

i added a unload function to my factory class and i call it in main after the game has finished running and the window has closed.

3
Graphics / program crashes on exit
« on: January 20, 2010, 12:14:15 am »
yes i do now :P it was just really early and i havent touched c++ for a few months  :lol:


Code: [Select]
   //! Creates or returns the factory instance
factory * factory::instance()
{
if (!dinstance)
 dinstance = new factory;

return dinstance;
}


Code: [Select]
//! Creates the SFML window and passes off execution
void factory::init (int width, int height, bool fullscr)
{
  window = new sf::RenderWindow(sf::VideoMode(width, height, 32), "2dtile");

  window->UseVerticalSync(true);
  window->SetFramerateLimit(60);
 
  this->StateManager.Init();

  this->GameLoop();
 
}




do you like my engine framework :P ? im designing a 2d mmorpg. oh noes! ;)

4
Graphics / program crashes on exit
« on: January 19, 2010, 11:34:58 pm »
and im not calling it any more. as my previous posts have stated i have changed my code and no longer call the destructor. i do beleive you. lol

5
Graphics / program crashes on exit
« on: January 19, 2010, 11:33:05 pm »
Code: [Select]
class factory
{
protected:
//! Pointer to the factory
static factory *dinstance;

factory ()
{

};

~factory (void) { };

public:
//! Creates or returns the factory instance
static factory *instance();

//! Initialize the game engine
void init (int width, int height, bool fullscr);

private:

//! SFML Rendering Device
sf::RenderWindow * window;

//! SFML events Device
sf::Event  Event;

//! Main Game Loop
void GameLoop ();

//! Main Event Loop
void EventLoop ();

//! Resource Manager Instance
resman ResourceManager;

//! State Manager Instance
stateman StateManager;


};

6
Graphics / program crashes on exit
« on: January 19, 2010, 11:24:45 pm »
resman is declared like

resman ResourceManager;

and is located in a singleton factory class

7
Graphics / program crashes on exit
« on: January 19, 2010, 11:06:57 pm »
yeah, thats why i said i didnt see

Quote
i didnt see the reason why it would matter


So i fixed a memory leak, and i also fixed my program crashing on exit. dont ask me why or how but me putting the contents or resman's destructor into a separate and calling it where i would call the destructor has fixed my problem. all my code is above. if you see anything im doing wrong now, please, let me know.

8
Graphics / program crashes on exit
« on: January 19, 2010, 10:33:54 pm »
this is my resource manager.

Code: [Select]
#pragma once

#include "include.h"

namespace engine
{
class resman
{
public:

resman ()
{

};

~resman (void)
{
for (int i = 0; i < (int) _images.size(); i++)
{
delete _images.at(i);
}
};

//! Load or retreive an image from memory
sf::Image * GetImage(string filepath);

private:

//! Array of images loaded into memory
std::vector <sf::Image *> _images;

//! Array of path names of images loaded into memory
std::vector <std::string> images;


};
};


Code: [Select]
#include "include.h"

#include "factory.h"
class factory;

namespace engine
{

sf::Image * resman::GetImage(string filepath)
{
for (int i = 0; i < (int)images.size(); i++)
{
if (images.at(i).compare(filepath)==0)
return _images.at(i);

}

 // Not Found?

 sf::Image *ImgTemp = new sf::Image();
 if(ImgTemp->LoadFromFile(filepath))
 {
_images.push_back(ImgTemp);
images.push_back(filepath);
return ImgTemp;
 }
 else
 {
delete ImgTemp;
 }

 return NULL;
}


}



i put the code in the destructor so i might as well move it to a function and call it then from what you say.

i didnt see the reason why it would matter if i destroyed the resource manager class right before i call app.close();

Code: [Select]
// Close window : exit
if (Event.Type == sf::Event::Closed)
{
this->ResourceManager.~resman();

window->Close();
}


thats where i would call it[/code]

9
Graphics / program crashes on exit
« on: January 19, 2010, 09:40:28 pm »
i was right, i fixed it by putting this in my resource manager deconstructor:

Code: [Select]
for (int i = 0; i < (int) _images.size(); i++)
{
delete _images.at(i);
}



and calling this before i call app->close();

Code: [Select]
this->ResourceManager.~resman();


sorry for worrying so much. this is where everything got sticky a long time ago when i tried to use sfml and now it seems im getting the hang of it faster. thanks anyways!

10
Graphics / program crashes on exit
« on: January 19, 2010, 07:54:55 pm »
ok so if i dont load and display the sprite it doesnt crash on exit.

should i be disposing of the loaded sf::Image before i exit possibly?

11
Graphics / program crashes on exit
« on: January 19, 2010, 07:51:13 pm »
ok so i am basically using the example code from the tutorials.

i have made a little resource manager and all i do is load
and display a sprite.

when i press esc or the X my program crashes instead of gracefully exiting.....

when i try and debug i get this
Quote

Windows has triggered a breakpoint in 2dtile.exe.

This may be due to a corruption of the heap, which indicates a bug in 2dtile.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while 2dtile.exe has focus.

The output window may have more diagnostic information.


any one have any ideas what could be happening? ps: there is no more diagnostics information   :roll:

12
Graphics / reference of an image? just a quick question
« on: January 19, 2010, 07:48:06 pm »
thanks, that was easy enough, programming in the morning can make me go nuts haha.


now my program crashes when i exit.... ill have to do some more debugging...

13
Graphics / reference of an image? just a quick question
« on: January 19, 2010, 07:34:14 pm »
ok so i have made my own resource manager

and there is a function to return a pointer to an image?

its defined like this

sf::Image * GetImage(filepath);

when i try to do this:

mysprite.setimage(GetImage(filepath));

i get this error:

Error   1   error C2664: 'sf::Sprite::SetImage' : cannot convert parameter 1 from 'sf::Image *' to 'const sf::Image &'   

how would i pass this back or what would i cast this as to make it work? thank you!

14
Graphics / problem with SetSubRect
« on: August 11, 2009, 04:58:34 pm »
wow now i feel like a dumbass  :roll:  thanks for the help

15
Graphics / problem with SetSubRect
« on: August 11, 2009, 08:03:03 am »
could you possibly provide a link? and a little help?

ive searched through the doxygen and all i could find was a page on sf::Rect and it didnt reeally help me what so ever.

thanks, any help is appreciated.

Pages: [1] 2