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

Pages: [1]
1
Solved, I forgot that it might be a good idea to switch from 32bit to 64bit.
Also optimized the code a little. If anyone is interested in something similar.
New problem: Bigger images (9000 x 9000 pixels) causes sf::Image::Create to fail. It returns "Failed to save image "img/cave_1.png"".

It sometimes manage to create 1 image, sometimes 2. But it start saying it cannot create the image.
Smaller images such as 6000 x 6000 pixels starts failing at ~25 images.
Is there something I am missing that I should do?


void MessyClass::SaveImage(int num, char** cave)
{
        sf::Uint8* temp;
        temp = new sf::Uint8[caveY * caveX * 4];
        memset(temp, 255, caveY * caveX * 4);

        for (int y = 0; y < caveY; y++) {
                for (int x = 0; x < caveX; x++) {
                        //if (cave[x][y] == '.') {
                        //      //temp[(y + x * caveY) * 4 + 0] = 255;
                        //      //temp[(y + x * caveY) * 4 + 1] = 255;
                        //      //temp[(y + x * caveY) * 4 + 2] = 255;
                        //      //temp[(y + x * caveY) * 4 + 3] = 255;
                        //}
                        if (cave[x][y] == '#') {
                                temp[(y + x * caveY) * 4 + 0] = 0;
                                temp[(y + x * caveY) * 4 + 1] = 0;
                                temp[(y + x * caveY) * 4 + 2] = 0;
                                //temp[(y + x * caveY) * 4 + 3] = 255;
                        }
                }
        }

        if (CreateDirectoryA("img", NULL))
        {
                std::cout << "Created \"img\" Directory!\n";
                Sleep(100);
        }

        img.create(caveX, caveY, temp);
        img.saveToFile("img/cave_" + std::to_string(num) + ".png");
        delete[] temp;
}

I am doing some procedural generation of caves and is using a 2D array to store each tile.
Now I am trying to use this array to create a png-file, I think I should use "sf::Image::create(...)" but I am not sure how to translate my array into an array that is acceptable to the create.


*EDIT* I got it to work (somewhat, the image is mirrored)
This is how I do it now:
void MessyClass::SaveImage()
{
        sf::Uint8* temp;
        temp = new sf::Uint8[DLA::GetInstance().GetSizeY() * DLA::GetInstance().GetSizeX() * 4];
        int cx = DLA::GetInstance().GetSizeX(), cy = DLA::GetInstance().GetSizeY();
        for (int y = 0; y < cy; y++) {
                for (int x = 0; x < cx; x++) {
                        if (drawFluff[x][y] == '.') {
                                temp[(y + x * cy) * 4 + 0] = 255;
                                temp[(y + x * cy) * 4 + 1] = 255;
                                temp[(y + x * cy) * 4 + 2] = 255;
                                temp[(y + x * cy) * 4 + 3] = 255;
                        }
                        if (drawFluff[x][y] == '#') {
                                temp[(y + x * cy) * 4 + 0] = 0;
                                temp[(y + x * cy) * 4 + 1] = 0;
                                temp[(y + x * cy) * 4 + 2] = 0;
                                temp[(y + x * cy) * 4 + 3] = 255;
                        }
                }
        }
        img.create(DLA::GetInstance().GetSizeX(), DLA::GetInstance().GetSizeY(), temp);
        img.saveToFile("img/cave_" + std::to_string(DLA::GetInstance().GetCavesGenerated()) + ".png");
}

2
General / Re: Differences in debug/release problem.
« on: December 16, 2014, 04:40:00 pm »
I just tried to see if it could be optimization that was doing something and if I use /Ox (Full optimization) in
Debug-mode I get the same problem as in release. And if I disable optimization in Release it works as in Debug-
mode if that could be any hint to what could be wrong.

I do not know how it optimize my code but the same problem occur with /O1, /O2 and /Ox

3
General / Re: Differences in debug/release problem.
« on: December 16, 2014, 04:17:41 am »
I have tried these Frame rate limits in Release:

window.setFramerateLimit(60);
window.setFramerateLimit(100);
window.setFramerateLimit(1000);
window.setFramerateLimit(10000);
window.setFramerateLimit(100000);

They behave the same was in all limits with the wrong physics.
I tried the same in debug, and they also work the same in all limits but with the correct physics in all of them.

4
General / Re: Differences in debug/release problem.
« on: December 16, 2014, 01:08:17 am »
Thanks! I'll take a look :)

5
General / Differences in debug/release problem.
« on: December 16, 2014, 01:02:06 am »
OS: Win7
SFML: 2.1
Language: C++
IDE: VS2013

I am working on a physics simulation, and when I felt it was quite complete I decided to build a release build but the physics is all messed up. Could it be my FPS that is messing things up? On a slower machine I have a lot lower FPS, that is ranging from 80fps with tracers on in debug to 350 in release with tracers on.

I have this in my code:
window.setFramerateLimit(40);
So I guess my FPS counter is a bit misplaced as well.

Code snippet for FPS.
(click to show/hide)

Here below is on image with the "wrong" physics and one image with the correct physics.
Release (wrong), Debug (correct)

The formula I use are the same in both builds it is the gravity law formula. If it matters both builds also uses floats for masses, velocity and such. There is so much code in this so I do not know were to start showing it if it is necessary but since the code works as intended in debug I hope it is a some what easy way to fix this problem. So do anyone have any clue on why this could happen?

Feel free to ask questions if more information is needed since I really do not know what to provide.

6
General / Re: Static Linking?
« on: January 06, 2013, 01:02:04 pm »
Ops I missed that ;D
Thank you! :)

7
General / Static Linking?
« on: January 06, 2013, 12:47:12 pm »
I wonder if it possible to link so I do not need any DLL files when I run my .exe file, so I don't need to move the DLL files to wanted folder all the time.

I tried with adding sfml-*-s.lib files but when I tries to link I get these errors

Code: [Select]
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Cyan" (__imp_?Cyan@Color@sf@@2V12@B)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Yellow" (__imp_?Yellow@Color@sf@@2V12@B)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Shape::setOutlineThickness(float)" (__imp_?setOutlineThickness@Shape@sf@@QAEXM@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Shape::setOutlineColor(class sf::Color const &)" (__imp_?setOutlineColor@Shape@sf@@QAEXABVColor@2@@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Shape::setFillColor(class sf::Color const &)" (__imp_?setFillColor@Shape@sf@@QAEXABVColor@2@@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RectangleShape::setSize(class sf::Vector2<float> const &)" (__imp_?setSize@RectangleShape@sf@@QAEXABV?$Vector2@M@2@@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RectangleShape::RectangleShape(class sf::Vector2<float> const &)" (__imp_??0RectangleShape@sf@@QAE@ABV?$Vector2@M@1@@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Magenta" (__imp_?Magenta@Color@sf@@2V12@B)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Green" (__imp_?Green@Color@sf@@2V12@B)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Transformable::setPosition(float,float)" (__imp_?setPosition@Transformable@sf@@QAEXMM@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::RenderStates const sf::RenderStates::Default" (__imp_?Default@RenderStates@sf@@2V12@B)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::locale const &)" (__imp_??0String@sf@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABVlocale@3@@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Black" (__imp_?Black@Color@sf@@2V12@B)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Font::loadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?loadFromFile@Font@sf@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Font::~Font(void)" (__imp_??1Font@sf@@QAE@XZ)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Font::Font(void)" (__imp_??0Font@sf@@QAE@XZ)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Blue" (__imp_?Blue@Color@sf@@2V12@B)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Text::setColor(class sf::Color const &)" (__imp_?setColor@Text@sf@@QAEXABVColor@2@@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Text::setStyle(unsigned int)" (__imp_?setStyle@Text@sf@@QAEXI@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Text::setCharacterSize(unsigned int)" (__imp_?setCharacterSize@Text@sf@@QAEXI@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Text::setFont(class sf::Font const &)" (__imp_?setFont@Text@sf@@QAEXABVFont@2@@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Text::setString(class sf::String const &)" (__imp_?setString@Text@sf@@QAEXABVString@2@@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Text::Text(void)" (__imp_??0Text@sf@@QAE@XZ)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Red" (__imp_?Red@Color@sf@@2V12@B)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates const &)" (__imp_?draw@RenderTarget@sf@@QAEXABVDrawable@2@ABVRenderStates@2@@Z)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Text::~Text(void)" (__imp_??1Text@sf@@UAE@XZ)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RectangleShape::`default constructor closure'(void)" (__imp_??_FRectangleShape@sf@@QAEXXZ)
1>Draw.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RectangleShape::~RectangleShape(void)" (__imp_??1RectangleShape@sf@@UAE@XZ)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::White" (__imp_?White@Color@sf@@2V12@B)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: virtual bool __thiscall sf::RenderWindow::activate(bool)" (__imp_?activate@RenderWindow@sf@@EAE_N_N@Z)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) protected: virtual void __thiscall sf::RenderWindow::onResize(void)" (__imp_?onResize@RenderWindow@sf@@MAEXXZ)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) protected: virtual void __thiscall sf::RenderWindow::onCreate(void)" (__imp_?onCreate@RenderWindow@sf@@MAEXXZ)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual class sf::Vector2<unsigned int> __thiscall sf::RenderWindow::getSize(void)const " (__imp_?getSize@RenderWindow@sf@@UBE?AV?$Vector2@I@2@XZ)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UAE@XZ)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IABUContextSettings@1@@Z)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::display(void)" (__imp_?display@Window@sf@@QAEXXZ)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (__imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::isOpen(void)const " (__imp_?isOpen@Window@sf@@QBE_NXZ)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl sf::Keyboard::isKeyPressed(enum sf::Keyboard::Key)" (__imp_?isKeyPressed@Keyboard@sf@@SA_NW4Key@12@@Z)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z)
1>Window.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::clear(class sf::Color const &)" (__imp_?clear@RenderTarget@sf@@QAEXABVColor@2@@Z)

8
Graphics / Re: Problems with sf::Text
« on: January 04, 2013, 04:33:40 pm »
I only have a few days till this assignment is due, and this was the only thing still bugging me :p
So I'll try and set it up when our game-dev-assignment starts :)

9
Graphics / Re: Problems with sf::Text
« on: January 04, 2013, 02:58:30 pm »
I was hoping it would work when everything else works :)
I will be using VS2010 instead, I have it on my computer @ home ^^
I googled earlier and saw a similar problem about compiling for 2012 and you replied you didn't use it
so I guess it's easier to just setup SFML on 2010 instead and go from there ;P

Thanks for all the help! :)

10
Graphics / Re: Problems with sf::Text
« on: January 04, 2013, 02:39:05 pm »
http://www.sfml-dev.org/download.php
C++ | version 2.0 RC
For 2010

11
Graphics / Re: Problems with sf::Text
« on: January 04, 2013, 02:22:13 pm »
I use the pre-compiled version.
I use Visual Studio 2012 on a win7 machine.

12
Graphics / Re: Problems with sf::Text
« on: January 04, 2013, 02:03:03 pm »
Oh, OK. Then the documentation is a bit misguiding!

http://www.sfml-dev.org/documentation/2.0/classsf_1_1Text.php
"Note that you don't need to load a font to draw text, SFML comes with a built-in font that is implicitely used by default."

Anyway! I get the same error when I load a font. I even copied the font into the same folder as the code (and the debug folder).

Code: [Select]
Draw::Draw(sf::RenderWindow* rw) : m_Window(rw), m_Text("Hello World")
{
if (!m_Font.loadFromFile("arial.ttf"))
{
std::cout << std::endl << "Press Enter to shutdown..." << std::endl;
std::cin.ignore();
std::cin.get();
exit(0);
}
m_Text.setFont(m_Font); // fails here if I try to use setFont
m_Text.setPosition(200, 200);
m_Text.setCharacterSize(15);
m_Text.setColor(sf::Color::Black);
}

Code: [Select]
void Draw::drawBox(int comments, int rows, int chars, int blanks, int tabs)
{
m_Window->draw(m_Text); // fails at draw if I don't have setFont
// Code for drawing boxes below
}

13
Graphics / Re: Problems with sf::Text
« on: January 04, 2013, 01:37:16 pm »
I have tried with a font loaded from file, but according to the documentation it isn't required.
I have tried both with and without a font set.

Sometimes I get the error that the variable 'text' or 'font' is corrupt but I have no clue why this is happening.

14
Graphics / Problems with sf::Text
« on: January 03, 2013, 05:25:36 pm »
Hi! I have some really annoying problem I cannot figure out how to mend.
When I compile & run the application I get this error:

"Unhandled exception at 0x5105551E (sfml-graphics-d-2.dll) in codeCounter.exe: 0xC0000005: Access violation reading location 0x00000004."

Here is my class:
Code: [Select]
class Draw
{
public:
Draw(sf::RenderWindow* rw);
~Draw();

void drawBox(int comments, int rows, int chars, int blanks, int tabs);

private:
sf::RenderWindow* m_Window;
sf::RectangleShape m_Box;
sf::Font m_Font;
sf::Text m_Text;
};

Code: [Select]
void Draw::drawBox(int comments, int rows, int chars, int blanks, int tabs)
{
m_Text.setPosition(200, 200);
m_Text.setCharacterSize(15);
m_Text.setColor(sf::Color::Black);

m_Window->draw(m_Text); // if I remove this, the application work, but I wouldn't have no text!
//....
}

If I have a break-point on the m_Text it say "No information available, no symbols from sfml-graphics-d-2.dll loaded".

Anyone that know how I can mend this annoying problem? ^^

Pages: [1]
anything