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 4 ... 10
16
Graphics / Font .loadFromFile throwing a access violation. [SOLVED]
« on: November 18, 2012, 05:16:31 pm »
I have a bit of an issue where when I try to load a font, in this case, "arial.ttf" in my application, it throws a nice exception:
Quote
Unhandled exception at 0x519E1FF9 (sfml-graphics-2.dll) in Genesis.exe: 0xC0000005: Access violation writing location 0x00000000.

The code that causes it:
        DevHudFont.loadFromFile("arial.ttf");
        CurserPosText.setFont(DevHudFont);
 
You may notice it's not in a if statement, but it throws an exception either way.

The only time it does not throw an exception, is if it cannot find the font. ^^;; Then it just says it couldn't find the font/build the font face.

I should also point out that the font, is, in the same directory as the .exe when it runs. ;)

Any ideas?

17
General / Re: std::cout showing random bits and pieces of other strings?
« on: November 18, 2012, 02:19:56 am »
Didn't read whole, anyway, stuff like:
"blablabla"+some_number; is WRONG.
Add this function to your program and see if wrapping every number in it(as in, don't do +number, do +EEVarToStr(number) instead everywhere) will stop the problem.

Worked perfectly!

Haha, I actually was wondering about the whole "+" thing. I used to do that in java so maybe I just forgot I was in C++ for a moment? ;)

So what exactly does that function you wrote up do? It looks like it is casting a number to a stringstream then returning the string value of that stringstream. Correct?

18
General / std::cout showing random bits and pieces of other strings?
« on: November 18, 2012, 01:52:36 am »
So I was just messing around to day as I usually do, when my console started looking a bit... strange.

For some reason my cout in this code:

Shortened it up, Frex's answer worked.


I have attached a example of what the error looks like below. You can see what I mean hopefully. The strings that its showing at random are in my main class, and they are never even called, so thats why I'm thinking it may be memory related.

I really look forward to some guidance on this issue. ....I'm lost.

EDIT

Also, it will print "Printing the DevHud Data" Every time it goes through the loop. That was intentionally done so I could keep track and see how much was being printed out per loop.

EDIT

Also those strings its showing are declared here:

void Genesis::ValidateFlags()
{
        if((Genesis::WindowX > 0 && Genesis::WindowY <= 0) || (Genesis::WindowY > 0 && Genesis::WindowX <= 0)) //Checks to make sure both X and Y are correct.
        {
                ConsoleLog.error("\"-X\" and \"-Y\" must be used at the same time, have a value greater than 0, and be proper integers!");
                ConsoleLog.error("\"-X\" and \"-Y\" will be ignored.");
                if(Windowed)
                {
                        ConsoleLog.error("\"-WM\" Was dected but due to argument errors will be disabled.");
                        Windowed = false;
                }
        }
        if((Genesis::WindowX>0)&&(Genesis::WindowY>0)&&(Genesis::Windowed==false)) //Makes sure that windowed mode is enabled when X and Y are correct.
        {
                ConsoleLog.error("\"-X\" and \"-Y\" were declared but windowed mode was never set! Did you forget a \"-WM\" ?");
                ConsoleLog.error("\"-X\" and \"-Y\" will be ignored.");
        }
        if((Genesis::WindowX<=0)&&(Genesis::WindowY<=0)&&(Genesis::Windowed==true)) //Make sure that -WM is not missing a X/Y variable!
        {
                ConsoleLog.error("Windowed mode was declared but X and Y are invalid or missing!");
                ConsoleLog.error("-WM will be ignored.");
                Genesis::Windowed=false;
        }
}
 
[/spoiler]
But it can pretty much show anything I think, but it usually shows that stuff.

[attachment deleted by admin]

19
General / Re: Storing a list of resolutions as an array?
« on: November 15, 2012, 11:33:51 pm »

If all of your video modes were invalid, this loop would only be capable of removing half of them.  An element is skipped for every one removed, with the exception of the last element if it happens to be removed -- undefined behavior is invoked in that case.

Well it was equaling 0 entries after the loop. :/ Oh well, I don't even have that loop anymore. I obsoleted it after discovering how much I loved sf::VideoMode::getFullscreenModes()

20
General / Re: Storing a list of resolutions as an array?
« on: November 15, 2012, 05:17:29 pm »
bpp should be 32 (what are you trying to do with other bpps??), or omitted since it's the default.

Oh, I was just copying them from a video chart I had found on Wikipedia. ^^;; I'll set them all to 32.

But say, if I make a quickie video mode like....
sf::VideoMode MyMode;
MyMode.Width=800;
MyMode.Height=600;

create(MyMode,"MyWindow",sf::Style::Fullscreen);
 

Will create an error since the bpp was not defined. However
sf::VideoMode MyMode;
MyMode.Width=800;
MyMode.Height=600;
MyMode.BitsPerPixel=32;

create(MyMode,"MyWindow",sf::Style::Fullscreen);
 

Will work perfectly. So thats why I have the bpp for each video mode. :)

Still unsure as to why they are all invalid...

Oh well, I'll just use
reslist = sf::VideoMode::getFullscreenModes();
 

Instead of making my own list, after all, its likely to save me time and be more efficient. ^^;

21
General / Re: Storing a list of resolutions as an array?
« on: November 15, 2012, 04:54:14 pm »
Hate to talk again and have to re post...... but.

isValid() is telling me that all of my video modes in my vector are invalid...

void EngineWindow::PrimeResolutionList()
{
        //Store initial resolutions.
        sf::VideoMode SVGA;
        SVGA.width=800;
        SVGA.height=600;
        SVGA.bitsPerPixel=4;
       
        sf::VideoMode XGAP1;
        XGAP1.width=1152;
        XGAP1.height=864;
        XGAP1.bitsPerPixel=16;
       
    sf::VideoMode XGAP2;
        XGAP2.width=1152;
        XGAP2.height=900;
        XGAP2.bitsPerPixel=16;
       
    sf::VideoMode HD;
        HD.width=1360;
        HD.height=768;
        HD.bitsPerPixel=24;

        sf::VideoMode HD2;
        HD2.width=1366;
        HD2.height=768;
        HD2.bitsPerPixel=24;
       
    sf::VideoMode WXGA;
        WXGA.width=1280;
        WXGA.height=800;
        WXGA.bitsPerPixel=24;

        sf::VideoMode HDP;
        HDP.width=1600;
        HDP.height=900;
        HDP.bitsPerPixel=24;

        sf::VideoMode SXGA;
        SXGA.width=1280;
        SXGA.height=1024;
        SXGA.bitsPerPixel=24;

        sf::VideoMode SXGAP;
        WXGA.width=1400;
        WXGA.height=1050;
    WXGA.bitsPerPixel=24;

        sf::VideoMode WSXGA;
        WSXGA.width=1440;
        WSXGA.height=900;
        WSXGA.bitsPerPixel=24;

        sf::VideoMode UXGA;
        WXGA.width=1600;
        WXGA.height=1200;
        WXGA.bitsPerPixel=24;

        sf::VideoMode WSXGAP;
        WXGA.width=1680;
        WXGA.height=1050;
        WXGA.bitsPerPixel=24;

        sf::VideoMode FULLHD;
        FULLHD.width=1920;
        FULLHD.height=1080;
        FULLHD.bitsPerPixel=24;

        sf::VideoMode WUXGA;
        WXGA.width=1920;
        WXGA.height=1200;
        WXGA.bitsPerPixel=24;

        //Add to the vector.
        reslist.push_back(SVGA);
        reslist.push_back(XGAP1);
        reslist.push_back(XGAP2);
        reslist.push_back(HD);
        reslist.push_back(HD2);
        reslist.push_back(WXGA);
        reslist.push_back(HDP);
        reslist.push_back(SXGA);
        reslist.push_back(SXGAP);
        reslist.push_back(WSXGA);
        reslist.push_back(UXGA);
        reslist.push_back(WSXGAP);
        reslist.push_back(FULLHD);
        reslist.push_back(WUXGA);

        //Iterate through the vector removing incompatable resolutions.
        std::vector<sf::VideoMode>::iterator it;
        for(it=reslist.begin(); it != reslist.end(); it++)
        {
                if(!(*it).isValid())
                {
                        it = reslist.erase(it);
                }
        }
}
 

Any ideas? o.O
Just a side note, I added in the bpp because otherwise if I try to use a VideoMode without a bpp defined, it claims its incompatible. *that is if it actually makes it past that final loop*

I mean. My current resolution is 1920 x 1080, so I don't see why its calling FULLHD invalid... Or a lot of the other ones for that matter.

22
General / Re: Storing a list of resolutions as an array?
« on: November 15, 2012, 04:31:39 pm »
Just wanted to say I have everything working flawlessly.

Thank you for your help. :)

23
General / Re: Storing a list of resolutions as an array?
« on: November 15, 2012, 03:28:33 pm »
If you only want to get list of fullscreen modes you can use sf::VideoMode::getFullscreenModes() to get a vector filled with them.

Would that include resolutions as well? o.O *probably a dumb question*

Is there a similar function for wide screen modes? *I don't have VS open to check atm* Just checked and I didn't see one. Oh well, I'm just going to make a huge list of resolutions for now so that only the resolutions compatible with the sizes of the sprites are available *after all I have a manual override if I need a specific resolution* Then I'll just sort it all out later.

24
General / Re: Storing a list of resolutions as an array?
« on: November 15, 2012, 02:24:09 am »
What would be a good input for bits per pixel? Or should I just ignore that completely?

25
General / Re: Storing a list of resolutions as an array?
« on: November 15, 2012, 01:47:11 am »
Well sf::VideoMode is what you'll have to apply to your window, once you'd change the resolution, thus you'd could use it directly instead of copying the values of the sf::Vector2u first into a sf::VideoMode. On top of that you can also directly check if the resolution is actually a valid one for the current PC/monitor (if(vec[2].isValid())).

Oh wow that actually makes a bunch of sense! Thanks a lot! :D

That isValid could come in VERY handy. I was wondering about that. XD But now I know there is a easy way to check, so thanks for showing me that. :)

26
General / Re: Storing a list of resolutions as an array?
« on: November 15, 2012, 12:20:33 am »
You can simply use a std::vector<sf::VideoMode>. If you don't know what a std::vector is then you left out one of the most important part in your literature about learning C++. ;)

I somehow always do that. XD

Thanks a ton though! sf::VideoMode would work, any specific reason you chose sf::VideoMode over sf::Vector2u?

27
General / Storing a list of resolutions as an array?
« on: November 14, 2012, 11:42:32 pm »
Hey everyone. :)

I in my program am needing to have a reference list of resolutions. *actually several lists for wide screen/full screen* But I'm trying to find the best method of storing such a list and was hoping that I could find some help on this subject. I thought maybe if I made a sf::Vector2u array and then stored the values within it. But am unsure on how proper that would be.

So its not really a question regarding broken code as much as it is me just asking for general input on the subject of storing a list of resolutions. It would also be nice if I had the ability to get a resolution by a number "like an array", say for instance. MyResolutionList[5].x

As Always, I'm looking forward to your input. :)

28
General / Re: VS 11, and variadic templates with std::thread
« on: November 06, 2012, 10:02:15 pm »
I mean, here so that you can see the whole picture:

LoadingScreens.cpp
#include "stdafx.h"
#include "LoadingScreens.h"
void LoadingScreens::Display(_LST ST,EngineWindow& glWindow)
{
        IsLoading=true;

        LoadingScreen CurrLoadScreen;

        switch(ST){
        case GNS_Cold:
                CurrLoadScreen = GNS_Cold_F();
                break;
        default:
                return;
        }
        LoadingScreens loadingScreens;
        auto RunLoadingScreenT = std::mem_fn(&LoadingScreens::RunLoadingScreen);
        std::thread t(RunLoadingScreenT,loadingScreens,CurrLoadScreen,glWindow);
}
LoadingScreens::LoadingScreen LoadingScreens::GNS_Cold_F()
{
        LoadingScreen GNS_Cold_LS;
        GNS_Cold_LS.LST_Alias = LoadingScreens::_LST::GEN_Cold;
    GNS_Cold_LS.IsStatic = true;
        GNS_Cold_LS.ResourcePath = "Resource/LoadingScreens/Genesis/Cold/Loading_Main.png";

        return GNS_Cold_LS;
}
void LoadingScreens::RunLoadingScreen(LoadingScreen LS,EngineWindow& glWindow) //This should run in a thread.
{
        if(LS.IsStatic){
                sf::Sprite LSS;
                LSS.setTexture(texture.getTexture(LS.ResourcePath));
                LSS.setPosition(glWindow.GetCenter().x,glWindow.GetCenter().y);
                glWindow.draw(LSS);
                glWindow.display();
        }else{
                        sfe::Movie LSM;
                        if(!LSM.openFromFile(LS.ResourcePath))
                        {
                                return;
                        }
                        LSM.setPosition(glWindow.GetCenter().x,glWindow.GetCenter().y);
                        LSM.play();
                        while(IsLoading)
                        {
                                glWindow.draw(LSM);
                                glWindow.display();
                        }
        }
}

 

LoadingScreens.h
#ifndef LOADINGSCREENS_H
#define LOADINGSCREENS_H
#include "stdafx.h"
#include "SpriteUtilities.h"
#include <SFML\Graphics.hpp>
#include <thread>
#include <sfeMovie\Movie.hpp>
#include <functional>
class LoadingScreens{
        Texture texture;
public:
        enum _LST{GNS_Cold,GNS_Anim,GEN_Cold,GEN_Anim,LVL_GEN_Cold,LVL_GEN_Anim};
        void Display(_LST,EngineWindow&);
        void Recall();
private:
        struct LoadingScreen
        {
        public:
                _LST LST_Alias;
                std::string ResourcePath;
                bool IsStatic;
                bool IsGeneric;
                std::string Args;
        };

        bool IsLoading;

        LoadingScreen GNS_Cold_F();

        void RunLoadingScreen(LoadingScreen,EngineWindow&);

};
#endif
 

I mean. I really don't see why this is not working at this point. I personally think this should have worked a long time ago. but as always, I am missing some small key of information that's probably ruining the entire thing.

EDIT

So I have it working with:

std::thread t(&LoadingScreens::RunLoadingScreen,&loadingScreens,CurrLoadScreen,glWindow);
 

But now I get errors from a sf::NonCopyable. So It must be trying to make a copy of "glWindow" but glWindow has inheritance with sf::renderWindow which explains where the error comes from. Is there a way to pass it as a reference?

EDIT

AHA! I knew it! I feel so proud. XD std::ref, I love you.

I will now continue to learn about functors and base C++ knowledge.

29
General / Re: VS 11, and variadic templates with std::thread
« on: November 06, 2012, 09:06:14 pm »
P.S I have no idea if in your original post LoadingScreens and LoadingScreen are the different or just a typo error. I treat them as different.

Oh, that was because I didn't show the header file. ^^;; LoadingScreen is a struct that holds variables for each type of loading screen, and LoadingScreens is the name of the class. :)

But wouldn't you have to initialize "thread_friendly_func" first? Either that or microsoft claims the error is because it is being initialized by itself which I don't really see happening.

Because I looked up, and tried what you said. but It still gives two errors:

Quote
Error   2   error C3536: 'RunLoadingScreenT': cannot be used before it is initialized   
Error   1   error C3867: 'LoadingScreens::RunLoadingScreen': function call missing argument list; use '&LoadingScreens::RunLoadingScreen' to create a pointer to member

Thank you for your help tho, because even after reading about functors, I'm still pretty much clueless as to how they are relevant to what I am doing, or even how to make this work. I mean, I completely understand the operator() and functors.......but I have not functors in any of my code so I fail to see how its aparent to my problem..... *sigh..... I'm honestly starting to wonder if I'll actually ever get threads working... I mean. All I wanted was a simple thread to work. I shutter to think if I wanted to pass four arguments XD, But really, every example I find they don't have to switch out functions and such. Or do half of all of this work. And here I do all of this work, and it still doesn't work. Its rather frustrating at times.

30
General / Re: VS 11, and variadic templates with std::thread
« on: November 06, 2012, 06:37:31 pm »
And instead of continuing this meaningless discussion, you should finally realize that you would have already learned everything you need in the time you have wasted so far, and additionally you could use the gained knowledge in the future for other problems. So please be wise enough and spend 15 minutes on the usage and definition of functors, this is well-invested time.

I highly doubt that in one hours time, I could have read up on everything, deciphered and understood what they actually mean in the documentation, and somehow figured out my problem and solved it. Just as I don't think this discussion is meaningless. I see several good things that have already come from it. I'm planning on reading through it all, but can't help but wonder *Will I actually remember this at a later point in time.*

But for the sake of pleasing you I will read up on the above topic's in the order in which you listed them, and get back to you with questions *if I find any*.

EDIT

Found a really nice article about functors. ^_^

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