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

Pages: [1] 2 3 ... 10
1
Window / Re: Debug Win32 std::length_error (Debug Error Only)
« on: July 06, 2013, 09:53:46 pm »
Do you link to the debug libraries (-d suffix) in debug mode?

Aha! I feel dumb.  ::)

My list of libs was:
Quote
sfml-graphics-d.lib
sfml-audio-d.lib
sfml-main-d.lib
sfml-network-d.lib
sfml-system-d.lib
sfml-window.lib

Happy you caught that! :) Thanks a bunch!

2
Window / Debug Win32 std::length_error (Debug Error Only) [Solved]
« on: July 06, 2013, 07:22:25 pm »
      Hello! :D

      I was toying around today with the opengl sfml window and noticed if  I tried to create the object in Debug, I receive the following message.

Quote
std::length_error at memory location

        I thought maybe it was just a incompatibility so I rebuilt the sfml Debug library with CMAKE and Visual Studio 11, and found myself still having the same issue. On a whim I switched to Release mode, and it works fine.

        Any Ideas? I tried several different methods of initializing the window, including just using a basic "non opengl window". At the moment the exact code is:

sf::Window glWindow(sf::VideoMode(800, 600), "Stuffs", sf::Style::Default, sf::ContextSettings(32));

         I can work in Release for now, but I was hoping to get some ideas as to why debug is failing.

         Thanks a bunch!

3
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 20, 2012, 05:28:07 pm »
I don't belive any of the other downloads contains the CMake-files, so you should try the newest snapshot.

Yea I downloaded the wrong file. XD Hence the big "whoops" XD haha

I have AMAZING NEWS!!! The rebuild works flawlessly! I had a bad build. XD I wonder what other errors I had due to that.... >.>' Time to go play with stuff thats working. ^_^

Laurent, Thanks a TON. I would have never expected it to be the build itself.  ;D

Thank you everyone who helped! Without you, I would still be thinking it was my loop. XD

4
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 20, 2012, 05:12:22 pm »
Did you recompile SFML?

I think I did... It's been a while. I remember it took a bit to get CMake to work. ^^;; But Yes, I'm fairly sure the lib's I'm using I compiled. Would you like me to re compile?  ???

If your answer is yes. I just re downloaded and re tried cmake to get this error:
Quote
CMake Error: The source directory "C:/Users/Travis/Desktop/SFML-2.0-rc" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

-_- Me and CMake never ever get along it seems.

5
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 20, 2012, 04:43:06 pm »
I just want to check something, what's your OS, compiler and version of SFML? Are you sure that you don't mix debug and release?

Windows 8 Pro 64 bit

Compiler Version? ....I'll just list some Visual Studio properties since I cant find one thats called that:

Platform Toolset: Visual Studio 2012 (v110)

Aditional dependencies: "Debug Mode"
sfml-graphics-d.lib
sfml-audio-d.lib
sfml-window-d.lib
sfml-main-d.lib
sfml-network-d.lib
sfml-system-d.lib

Aditional dependencies: "Release Mode"
sfml-graphics.lib
sfml-audio.lib
sfml-window.lib
sfml-main.lib
sfml-network.lib
sfml-system.lib


As for the SFML version, its 2.0 I don't know the exact version number.

But that's all of the info you asked for "I hope" If you need any more information please, do ask. :) I'm happy to help you help me in any way I can.

6
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 20, 2012, 12:52:35 am »
Ok So I found that it ONLY goes corrupt when its in the other class.

I just put the following into my main loop:

                sf::Vector2i mouse_pos;
        mouse_pos = sf::Mouse::getPosition(glWindow);
                std::stringstream MousePosSS;
                MousePosSS << "Mouse Pos: " << "X: " << mouse_pos.x << " Y: " << mouse_pos.y;
                std::string MousePosS;
                MousePosS = MousePosSS.str();
                ConsoleLog.info(MousePosS);
                sf::Text CurserPosText;
                sf::Font CurserPosFont;
                if(!CurserPosFont.loadFromFile("arial.ttf"))
                {

                }
                CurserPosText.setFont(CurserPosFont);
                CurserPosText.setString(MousePosSS.str());
                MousePosSS.str("");
                glWindow.draw(CurserPosText);
                glWindow.display();
 

And it works perfectly.

Any ideas why that in a object of a class in a loop would fail? o.O

Basically this code his how it fails right now... *Is pseudo code may have miss types"

.h

class MyMainClass{
         void MyMainFunction(sf::RenderWindow&);
};
class DevHud{
         void PrintStuff(sf::RenderWindow&);
};
 

.cpp
void MyMainClass::MyMainFunction(sf::RenderWindow& renderWindow){
        DevHud devHud;
        while(true)
        {
                devHud.PrintStuff(renderWindow);
                //Plus some code here to detect exit and what not.
         }
}
void DevHud::PrintStuff(sf::RenderWindow& renderWindow){
                sf::Vector2i mouse_pos;
                mouse_pos = sf::Mouse::getPosition(renderWindow);
                std::stringstream MousePosSS;
                MousePosSS << "Mouse Pos: " << "X: " << mouse_pos.x << " Y: " << mouse_pos.y;
                std::string MousePosS;
                MousePosS = MousePosSS.str();
                consoleLog.info(MousePosS);
                sf::Text CurserPosText;
                sf::Font CurserPosFont;
                if(!CurserPosFont.loadFromFile("visitor2.ttf"))
                {

                }
                CurserPosText.setFont(CurserPosFont);
                CurserPosText.setString(MousePosSS.str());
                MousePosSS.str("");
                renderWindow.draw(CurserPosText);
                /*And yes, I know this is inefficient but its the quickest simplist example I could come up with. I also have not tested this exact code but basically replicated it in my main class. Its just an example of whats going on and whats causing the error. */
}
 

Thats pretty much all that's happening. Just two classes talking to each other and that's all the error I'm getting. Contently the error is:

Quote
Run-Time Check Failure #2 - Stack around the variable 'CurserPosText' was corrupted.

So let me know if I'm doing something that you shouldn't. Or if you know what the error is, ...or if you have any idea at all because I have none.

7
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 19, 2012, 11:04:31 pm »
So still no text after a few hours of playing around with it........ -_-

I'm trying to convert the text back to a string with:

        mouse_pos = sf::Mouse::getPosition(glWindow);
                MousePosSS << "Mouse Pos: " << "X: " << mouse_pos.x << " Y: " << mouse_pos.y;
                MousePosS = MousePosSS.str();
                consoleLog.info(MousePosS);
                CurserPosText.setString(MousePosSS.str());
                sf::String myTest = CurserPosText.getString();
                std::string myString = myTest.toAnsiString();
                consoleLog.info(myString);
 

To see whats in it, to see if that's why it won't show up. Unfortunately this is making my program throw constant breaks for some reason. Any ideas? I really could use a break right about now, because I'm completely out of ideas.

So there I was one day, just clicking around in the debug window pretending to know what I'm doing, and I ran across this....

Quote
-      m_font   0xcccccccc {m_library=??? m_face=??? m_streamRec=??? ...}   const sf::Font *

Looks like the problem is the font yet.

I included a snippit of the error.


Tried to test some stuff......

Get this error:
Quote
Run-Time Check Failure #2 - Stack around the variable 'MyFont' was corrupted.

Came from:
DevHud::DevHud()
{
        DevHudEnabled = false;
        sf::Font MyFont;
        if(!MyFont.loadFromFile("arial.ttf"))
        {

        }
        CurserPosText.setFont(MyFont);
        //Setting up defaults for font/text elements.
        //fontUtils.SetupText(fontUtils.DevHud,DevHudFont,CurserPosText);
        CurserPosText.setPosition(236,240);
        CurserPosText.setCharacterSize(40);
}
 

o.O; Would seem my font became instantly corrupt.....

EDIT

Yep its official the problem is that the font is pointing to blank memory adresses, and as a result, the sf::text is getting currupt font data.  ::) Still have no idea what to do about it. But now I know the root of the issue.

In short the error "I believe" is this:

It creates the Font object -> Loads the font in successfully -> ???Looses its Font info??? ->Tries to set a font to a invalid memory location *bam exception* or it is somehow successful and -> loads in the corrupt font data anyways -> Doesn't display anything because it was given bad memory locations when it tried to load the font and it is now corrupt.

Hope that makes some sense. I'm working on poking it with a stick right now.

Well after poking it with a stick several times. I have found something.

If I call:
fontUtils.SetupText(fontUtils.DevHud,DevHudFont,CurserPosText);
 

It can load its font just fine, it keeps its memory addresses, everything works well. However, the moment I tell a text object that its font is "DevHudFont" the fonts memory addresses show up as a bunch of "0"s in the debug window, and the text as a result gets corrupt font data.

Any ideas on why setting the font would make the font go batty? XD

[attachment deleted by admin]

8
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 19, 2012, 09:07:31 pm »

Have you tried a different position?

CurserPosText.setPosition(236,240);

Just did. I also have it printing X/Y cords just fine in the console window so I know that the string is not empty. Its how I found out to try to put it at 236/240  ;D

Still no text tho.

Not sure if this is a hint but I've discovered that changing my:
sf::Text CurserPosText;

From private to global causes sfml graphics to throw a:
Quote
Unhandled exception at 0x57049035 (sfml-graphics-d-2.dll) in Genesis.exe: 0xC0000005: Access violation writing location 0x00000000.

at:
CurserPosText.setString(MousePos);

Hmm

Found out even more. It will throw the exception if I ever move it from its location to any other location in the header file.
private:
        bool Enabled;
        sf::Text CurserPosText; //If this is moved we will get a exception the first time its called.
        sf::Font DevHudFont;
        sf::String MousePos;
        sf::Vector2i mouse_pos;

        void setVars(EngineWindow&);
 

Maybe its because its used in the constructor?

Apparently moving the "Enabled" bool variable fixed this issue. o.O ...* extremely confused* Still no text.

9
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 19, 2012, 08:50:09 pm »
OK update. I re did the class for the most part so it works a bit different.

I have no compile errors, no debug errors, but also no text displays. ... Not sure why. It seems almost like the font is blank, but I receive no errors when loading the font. I get no errors at all really. But as I said, No text is printed to the screen. I'll post the updated code.

.cpp
#include "stdafx.h"
#include "DevHudDisplay.h"
DevHud::DevHud()
{
        Enabled = false;
        //Setting up defaults for font/text elements.
        fontUtils.SetupText(fontUtils.DevHud,DevHudFont,CurserPosText);
        CurserPosText.setFont(DevHudFont);
        CurserPosText.setPosition(0,0);
}
void DevHud::gatherData(EngineWindow& glWindow,sf::Event& e)
{

                consoleLog.info("running_DH");
                if(e.type == sf::Event::EventType::KeyPressed)//If we detect a tilde toggle the enable variable.
                {
                        if(e.key.code == sf::Keyboard::Tilde)
                        {
                                ToggleDevHud();
                        }
                }


                if(Enabled)//Only set the vars if its enabled.
                {
                        consoleLog.info("Enabled");
                        setVars(glWindow);
                }
}
void DevHud::setVars(EngineWindow& glWindow)
{
                //Mouse Position Vars
        mouse_pos = sf::Mouse::getPosition(glWindow);
                std::stringstream PositionLine;
                PositionLine << "Mouse Pos: " << "X: " << mouse_pos.x << " Y: " << mouse_pos.y;
                MousePos = PositionLine.str();
                CurserPosText.setString(MousePos);
}
void DevHud::ToggleDevHud()
{
        if(Enabled)
        {
                Enabled = false;
        }else if(!Enabled){
                Enabled = true;
        }
}
void DevHud::Draw(EngineWindow& glWindow)
{
        if(Enabled)//Only draw to the render window if enabled.
        {
                glWindow.draw(CurserPosText);
        }
}
 

.h
#ifndef DEVHUDDISPLAY_H
#define DEVHUDDISPLAY_H
#include "stdafx.h"
#include "WindowManagment.h"
#include "Genesis.h"
#include "ConsoleUtils.h"
class DevHud{
        Log consoleLog;
        Validate validate;
        FontUtils fontUtils;
public:
        DevHud();
        void gatherData(EngineWindow&,sf::Event&);
        void ToggleDevHud();
        void Draw(EngineWindow&);
private:
        bool Enabled;

        sf::Text CurserPosText;
        sf::Font DevHudFont;
        sf::String MousePos;
        sf::Vector2i mouse_pos;

        void setVars(EngineWindow&);
};
#endif
 

The function that sets up the font:
void FontUtils::SetupText(TextStyle s,sf::Font& f,sf::Text& t)
{
        Log consoleLog;
        if(s == FontUtils::DevHud)
        {
                consoleLog.info("Loading the Font");
                if(!f.loadFromFile("Resource/Font/visitor2.ttf"))
                {
                        consoleLog.critical("Unable to load font file!");
                }
                t.setColor(sf::Color::Green);
                t.setCharacterSize(40);
        }
}
 


Calling Point
        DevHud devHud;
        while(true)
        {
                sf::Event e;
        while(glWindow.pollEvent(e))
                {  
                        ConsoleLog.info("EVENT CALLED");
                        devHud.gatherData(glWindow,e);
                        if((e.type == sf::Event::EventType::KeyPressed)&&(e.key.code == sf::Keyboard::Escape))
                        {
                                return;
                        }
                }
                glWindow.clear();
                devHud.Draw(glWindow);
                glWindow.display();
               
        }
 

I moved around some console logs and checked. Every part of the code is running. Its just not displaying anything. o.O

I'll keep tinkering but if you see something wrong, do tell me! :)

10
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 19, 2012, 01:52:29 pm »
Maybe you could compile in debug mode and get a much more detailed output from the debugger? If the code path that is used to reproduce the problem has calls to sfeMovie functions, then comment them out so that your app doesn't crash because of this.

Today after class I plan on re writing devHud in a more usable manner.

Currently it works like.
  • Called when a event is heard to toggle on/off.
  • Draw and Display are within the Event Loop

I plan to make it that.

  • It has a function to return the sf::Text object so that it does not require a draw function within itself, within the event loop.
  • That it has a function to be called within the event loop for changing a bool variable to enable/disable its tracking capabilities
  • If it's never been enabled, or it has been disabled, and its return text function is called, it will return a blank sf::Text. Hmm Or I could add a function to return a bool and do something like.....
if(devHud.Enabled)
{
//Draw Stuff here.
}
 
    I'll decide later.

Once I get all of that done, and my code looking nice. I will switch to debug and post some useful info! :)

11
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 19, 2012, 01:07:55 am »
Okay, you should never draw/display anything inside the event loop. It not only will lead to strange behavior (an event gets only triggered occasionally if you do something) but it's also very bad practice.
You should also never call window.display() twice in one iteration, because the second one will overwrite the first one.
And as already said, you should always clear (window.clear()) the render window before drawing anything on it.

As I already said, I can't help you further, because I'm not gonna guess what could maybe be to cause that comes from code XYZ I don't have access to. If you can confirm that this minimal and complete example does also crash, then it's something with SFML/your setup. If not, then it's something in your code.

The code you provided, DOES work. 100%, no errors at all. ...not sure why mine wont. But at least we know its not SFML.

I was un aware of drawing/displaying in a event loop.... What would be a better way to go about changing/displaying something when the mouse moves then? o.O I just put it in the event loop because I figured it seemed like a easy way to do it. *that however does not mean its correct*

Access to the code? I've posted 90% of the code involved with this error apart from listing all the code from every class. XD But if you do indeed want more, please tell me what of, *or what you would need to see more of*, so that I can post it/send it and such. :)

12
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 18, 2012, 11:48:34 pm »
Well then you'd do it wrong. If you know that the problem doesn't exist for a minimal example, then you should write this, so we can indefinitely exclude SFML as the source of the problem. And since the minimal example doesn't show the problem you'd have to go the other way, the harder way. Strip down everything unrelated of your code until you end up with very few lines that reproduce the problem. Going this way will often solve the problem on its own, since the mistake gets clear to you at some point. ;)


You should always clear the window before drawing anything (except if that happens outside of this class, but then you shouldn't call display within this class).

Having a class with the name Font next to sf::Font doesn't seem that nice. What does your Font class do, because it probably should have a different name...

But overall I don't see why your application should go nuts at the font loading operation. With a complete example one might find out where you screw up earlier. ;)

Well, the Font is what held the function within it for autmatically setting the properties of the text/font that was referenced to it. I could rename it to SetFont and see how that works out.

In other news. It seems I have narrowed it down further. I shoved everything into one function:

void DevHud::display(EngineWindow& glWindow)
{
                consoleLog.info("running_DH");
                mouse_pos = sf::Mouse::getPosition(glWindow);

                std::string MousePosSX = "X: "+validate.EEVarToStr(mouse_pos.x);
                std::string MousePosSY = " Y: "+validate.EEVarToStr(mouse_pos.y);
            MousePos = "Mouse Pos: "+MousePosSX+" "+MousePosSY;
               
                if(!DevHudFont.loadFromFile("Resource/Font/visitor1.ttf"))
                {

                }

                CurserPosText.setFont(DevHudFont);

                CurserPosText.setString(MousePos);

                glWindow.draw(CurserPosText);
            glWindow.display();
                //setVars(glWindow);
                //printToWindow(glWindow);
}
 

Now however I'm receiving a new exception.

Quote
Unhandled exception at 0x58412F78 (sfml-system-2.dll) in Genesis.exe: 0xC0000005: Access violation reading location 0x00000000.

Now it's the system that doesn't like my code. ^^;; Oh yay. *sarcasm*

Hmm, Maybe it would help to know how this function was being called? Here ya go:

void Genesis::TestOverlays(EngineWindow& glWindow)
{
        DevHud devHud;
        while(true)
        {
                sf::Event e;
        while(glWindow.pollEvent(e))
                {  
                        ConsoleLog.info("EVENT CALLED");
                        devHud.display(glWindow);
                        if((e.type == sf::Event::EventType::KeyPressed)&&(e.key.code == sf::Keyboard::Escape))
                        {
                                return;
                        }
                }
                glWindow.display();
               
        }
}
 

I have it display by itself so that it doesn't get overlapped by something else..... But I suppose I could just set it to print and then display the changes in the main class.


13
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 18, 2012, 10:57:46 pm »
You still didn't get what a complete and minimal example is though. ;)
Complete means, there's not a single left which needs to be added to compile and run it.
Minimal means that it exist only out of the most basic set of commands/function calls/variables which are needed to reproduce the error. At best just a few lines within the main function.

If you'd provide such an example, we could most likely tell you with a simple look whar's wrong, if you wouldn't have found it on your own by then. ;)

Well the issue there is, that wouldn't show how I'm referencing anything, and would likely cause me to never be able to re produce the issue, thus finding no fix for it since it cannot be re produced.

I would also like to clarify my previous statement. The issue is not fixed. Its throwing graphic exceptions again, and is generally, completely unstable with anything involving font or text objects.

Also, it still seems the root of all torment is:
                if(!f.loadFromFile("Resource/Font/visitor1.ttf"))
                {
                        consoleLog.critical("Unable to load font file!");
                }
 

For some reason, after sfml loads in the font file, everything goes completely wack. I don't know if its how I'm loading a font file to a referenced font, or what it is. But its extremely unstable after that. To the point where the smallest change in the code can cause exception throwing. It actually has gotten to the point where I call it either a miracle/error when it doesn't throw one.

I have managed to 100% isolate the error to this file. It no longer even sets up the font with a reference.

.cpp
#include "stdafx.h"
#include "DevHudDisplay.h"
void DevHud::display(sf::Event& e,EngineWindow& glWindow)
{
                consoleLog.info("running_DH");
                setVars(glWindow);
                printToWindow(glWindow);
}
void DevHud::setVars(EngineWindow& glWindow)
{
        mouse_pos = sf::Mouse::getPosition(glWindow);

                std::string MousePosSX = "X: "+validate.EEVarToStr(mouse_pos.x);
                std::string MousePosSY = " Y: "+validate.EEVarToStr(mouse_pos.y);
            MousePos = "Mouse Pos: "+MousePosSX+" "+MousePosSY;

                CurserPosText.setString(MousePos);

                //font.SetupText(font.DevHud,DevHudFont,CurserPosText);
                if(!DevHudFont.loadFromFile("Resource/Font/visitor1.ttf"))
                {
                        consoleLog.critical("Unable to load font file!");
                }

                CurserPosText.setColor(sf::Color::Green);
                CurserPosText.setCharacterSize(40);

                CurserPosText.setFont(DevHudFont);

}
void DevHud::printToWindow(EngineWindow& glWindow)
{
        glWindow.draw(CurserPosText);
        glWindow.display();
}
 

.h
#ifndef DEVHUDDISPLAY_H
#define DEVHUDDISPLAY_H
#include "stdafx.h"
#include "WindowManagment.h"
#include "Genesis.h"
#include "ConsoleUtils.h"
class DevHud{
        Log consoleLog;
        Validate validate;
        Font font;
public:
        void display(sf::Event&,EngineWindow&);
private:
        bool Enabled;

        sf::Text CurserPosText;
        sf::Font DevHudFont;
        std::string MousePos;

        sf::Vector2i mouse_pos;

        void setVars(EngineWindow&);
        void printToWindow(EngineWindow&);
};
#endif
 

Hope that helps!

14
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 18, 2012, 10:04:45 pm »
So I just tested it with a different font and its not the font file. I have no clue what it is at this point.

So somehow by moving where the font was declared fixed it. but now I'm dealing with loop/event glitches. Hopefully I'll have a update that makes sense soon enough.

15
Graphics / Re: Font .loadFromFile throwing a access violation.
« on: November 18, 2012, 09:11:44 pm »
You're mixing debug and release or developing in release, either is bad.

No, I build it in release mode. sfe Movie is release mode only atm so I'm forced to. But you are correct, I probably should had mentioned that I was in release mode.

As for showing code. There is not a whole lot to show.

font.SetupText(font.DevHud,DevHudFont,CurserPosText);//accessing a function to setup font that is commonly used.
Which accesses:
/**
Sets the font and text provided based on the enum provided.
*/

void Font::SetupText(TextStyle s,sf::Font& f,sf::Text& t)
{
        Log consoleLog;
        if(s == Font::DevHud)
        {
                if(!f.loadFromFile("Resource/Font/arial.ttf"))
                {
                        consoleLog.critical("Unable to load font file!");
                }

                t.setColor(sf::Color::Green);
                t.setCharacterSize(40);
        }
}
 

I've narrowed it down to:

                if(!f.loadFromFile("Resource/Font/arial.ttf"))
                {
                        consoleLog.critical("Unable to load font file!");
                }
 

Easily enough because if I comment it out, it works.

My real question I suppose is if this could be a problem related to the font file itself?

Pages: [1] 2 3 ... 10
anything