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

Pages: [1]
1
Graphics / Re: Fonts, don't we all love fonts...
« on: October 17, 2013, 11:09:40 am »
Ther IS one for vs 2012? I havent seen one...

EDIT: IM AN IDIOT!
Nevermind me... Im just gonna go and be ashamed of myself now...

2
Graphics / Re: Fonts, don't we all love fonts...
« on: October 17, 2013, 11:00:37 am »
yeah... I'm really REALLY sorry for wasting so much time... Not used to working with librariest I didnt write myself.

Ok, here goes:
I'm using MS Visual Studio Express 2012

This is my project file:
https://www.dropbox.com/s/40mkcnxyee0vhe4/GraphClass.vcxproj

And I downloaded the vc10 package. I did this because I'm uncomfortable working with other people libraries (and in my profession I work with entirerly different types of environments, often entierly preconstructed environments where I just ahve to write code...)
I'm Fairly certain I'm using the 32-bit library, for various reasons.

3
Graphics / Re: Fonts, don't we all love fonts...
« on: October 17, 2013, 10:41:52 am »
Ok, so I have been coming at you guys from the wrong angle (i have been annoyed as ***)
Here is the most minimal code I could produce that would yield the buffer overrun issue!
I'm building in both release and debug!

In debug it says the stack around graph gets corrupted, and in release I get a buffer overrun error!
They both happen after system("pause");

This is the code:

Graph.h:

#ifndef GRAPH_INCLUDE
#define GRAPH_INCLUDE
#include <SFML\Graphics.hpp>


class Graph{
        private:
                sf::Font font;
                sf::Text tempTxt;
};

#endif
 

Source.cpp
#include "Graph.h"

int main(int argc, char** argv){
        Graph graph;
        system("pause");
        return 0;
}
 

This code causes the buffer overrun on destruction of the Graph graph; I.E it happens after system("pause");

It is not my memeory management, its proboably my setup... But I don't understand what aspect of it! I have linked correctly etc. etc.... /cry!

4
Graphics / Re: Fonts, don't we all love fonts...
« on: October 17, 2013, 09:47:50 am »
Ok, so after having 1. Fixed the uninitialized variables (which, as I will stick to, was not an issue in the first place) 2. Gone through the code from start to finish several times without finding any possibility for memory leaks. I'm forced to assume that is not the cause of the problem. Please trust me when I say this: My code runs a simple graph datastructure. I have spent alot of time on projects like this one before and my errors are not related to missmanagedment of memory on my part. Yet the problem persists.

5
Graphics / Re: Fonts, don't we all love fonts...
« on: October 17, 2013, 12:56:16 am »
Absolutely! Stranges thing is: The error is now, after fixing the dequeu (which was my fault), a buffer overrun error. This confuses me, as I have written several projects in SFML before and never had this issue. And before you ask, yes the debug/release .lib files linked are correct, I spent an hour checking that over and over again it feels like.

6
Graphics / Re: Fonts, don't we all love fonts...
« on: October 16, 2013, 10:14:54 pm »
I understand your concerns perfectly well. However, these qarnings are in fact NOT the cause of the problem, trust me on this one, as they are in fact never a real issue. I know about the way c++ handles this and I would not have written my code without baring this in mind. Furthermore, the issue can be narrowed down the use of sf::Font. The errors do not occur if I do not open a font file from memory.

I know it is easy to dismiss it as being yielded by the lazy shortcuts. But I assure you that the way I have used them shuld not yield any significant errors. Furthermore, I have tested the code, it runs fine under all circumstances. One third thing, the errors do not occur in the same scope as the warnings.

This is most surely an issue related to sf::Font, I just don't understand why... :/

7
Graphics / Re: Fonts, don't we all love fonts...
« on: October 16, 2013, 09:25:27 pm »
1. yes, It shuld be less than 1000 lines. 2. The error has now changed (funny enough xd)
The way I read the nodes into the graph don't matter anymore, now all that matters is if I load the font or not... If I dont load the font I dont get errors, If I do, then voila! (also, the error now seems to be a dequeue an empty queue error, which I'm not causing myself for sure!).

Anyway, submitting my code below:

Source.cpp
#include "Graph.h"
#include <SFML\Window.hpp>
#include <fstream>


int main(){
        Graph graph;
        std::ifstream graphFile;
        std::string nodeFile="C:\\nodes.txt", edgeFile="C:\\edges.txt";
        graphFile.open(nodeFile);
        if(!graphFile.is_open()){
                std::cout<<"failed to open file: "<<nodeFile<<"\n";
                system("pause");
                return 0;
        }
        while(!graphFile.eof()){
                double x, y;
                std::string name;
                graphFile>>name;
                graphFile>>x;
                graphFile>>y;
                graph.addNode(name, x, y);
        }
        graphFile.close();
        graphFile.open(edgeFile);
        if(!graphFile.is_open()){
                std::cout<<"failed to open file: "<<edgeFile<<"\n";
                system("pause");
                return 0;
        }
        while(!graphFile.eof()){
                int start, stop;
                double cost;
                graphFile>>start;
                graphFile>>stop;
                graphFile>>cost;
                graph.addEdge(start, stop, cost);
        }
        graphFile.close();
        std::string from="Dublin", to="London";
        if(graph.pathFrom(from, to))
                std::cout<<"There is a path from "<<from<<" to "<<to<<"!";
        else
                std::cout<<"There is no path from "<<from<<" to "<<to<<"!";
        int num=graph.sPathFrom(from, to);
        if(num>0){
                std::cout<<"\nThe shortest path from "<<from<<" to "<<to<<" is on "<<num<<" flight(s)!\n";
                std::stack<std::string> rout;
                rout=graph.cPath(from, to);
                std::cout<<"This is the cheapest rout:\n";
                int lim=rout.size();
                for(int n=0; n<lim; n++){
                        std::cout<<rout.top();
                        rout.pop();
                        if(rout.size()>0)
                                std::cout<<"->";
                }
        }
        sf::RenderWindow window(sf::VideoMode(1000, 800), "Plot!");
        window.setPosition(sf::Vector2i(500, 100));
        window.setFramerateLimit(45);
        sf::View view(sf::Vector2f(400, 400), sf::Vector2f(1000, 1000));
        sf::Vector2i mousePos;
        float dx=1, dy=1;
        window.setView(view);
        bool clicked=false;
        while(window.isOpen()){
                sf::Event event;
                while(window.pollEvent(event))
                {
                        if(event.type==sf::Event::MouseButtonPressed){
                                if(event.mouseButton.button==sf::Mouse::Left)
                                        clicked=true;
                        }
                        if(event.type==sf::Event::MouseButtonReleased){
                                if(event.mouseButton.button==sf::Mouse::Left)
                                        clicked=false;
                        }
                        if(event.type==sf::Event::MouseMoved&&clicked){
                                view.move(-dx*(event.mouseMove.x-mousePos.x), -dy*(event.mouseMove.y-mousePos.y));
                        }
                        if(event.type == sf::Event::MouseWheelMoved)
                                view.zoom(1.f+event.mouseWheel.delta*0.1f);
                        if(event.type==sf::Event::Closed)
                                window.close();
                }
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::Q))
                        view.zoom(1.0309);
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::E))
                        view.zoom(0.97);
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
                        view.move(0, -5);
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
                        view.move(0, 5);
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
                        view.move(-5, 0);
                if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
                        view.move(5, 0);
                mousePos=sf::Mouse::getPosition(window);
                window.setView(view);
                window.clear();
                graph.draw(window);
                window.display();
        }
        return 0;
}
 

Graph.h
#ifndef GRAPH_INCLUDE
#define GRAPH_INCLUDE
#include <vector>
#include <string>
#include <iostream>
#include <cstdlib>
#include <string>
#include <sstream>
#include <SFML\Window.hpp>
#include <SFML\Graphics.hpp>
#include <SFML\Graphics\Shape.hpp>
#include <cmath>
#include <queue>
#include <stack>

struct Node;

struct Edge{
        double size;
        Node *start, *end;
};

struct Node{
        std::string name;
        double x, y;
        std::vector<Edge*> edges;
        int num;
};

class Graph{
        public:
                Graph();
                ~Graph();
                int numNodes();
                void addNode(std::string name, double x, double y);
                void addEdge(int start, int end, double size);
                void draw(sf::RenderWindow& window);
                bool pathFrom(std::string from, std::string target);
                int     sPathFrom(std::string from, std::string target);
                std::stack<std::string> cPath(std::string from, std::string target);
        private:
                std::vector<Node*> nodes;
                sf::Font font;
                sf::Text tempTxt;
                bool dFirst(int num, std::string target, std::vector<int>& visited);
                int bFirst(std::queue<int>& q, std::string target, std::vector<int>& visited, int num, int steps, int addedThisLevel, int addedNextLevel, int level);
                bool contains(int num, std::vector<int> visited);
                int* heu(int end);
                void aStar(std::vector<int>& open, std::vector<int>& closed, int* heuristic, double* fValue, int* pointers, double* gScore, int target, int start);
};

Graph::Graph(){
        font.loadFromFile("C:\\Windows\\Fonts\\Calibri.ttf");
        ;
}

std::stack<std::string> Graph::cPath(std::string from, std::string target){
        bool test1=true, test2=true;
        int num1, num2;
        std::stack<std::string> ret;
        for(int n=0; n<nodes.size(); n++){
                if(nodes.at(n)->name==from){
                        test1=false;
                        num1=n;
                }
                if(nodes.at(n)->name==target){
                        test2=false;
                        num2=n;
                }
        }
        int* heuristic;
        int* pointers = new int [nodes.size()];
        double* gScore = new double[nodes.size()];
        double* fValue = new double [nodes.size()];
        std::vector<int> open;
        std::vector<int> closed;
        for(int n=0; n<nodes.size(); n++){
                pointers[n]=-1;
                fValue[n]=100000000;
                gScore[n]=0;
        }
        heuristic=heu(num2);
        open.push_back(num1);
        aStar(open, closed, heuristic, fValue, pointers, gScore, num2, num1);
        int n=num2;
        while(n!=num1){
                ret.push(nodes.at(n)->name);
                n=pointers[n];
        }
        ret.push(nodes.at(n)->name);
        delete [] gScore;
        delete [] heuristic;
        delete [] pointers;
        delete [] fValue;
        return ret;
}


void Graph::aStar(std::vector<int>& open, std::vector<int>& closed, int* heuristic, double* fValue, int* pointers, double* gScore, int target, int start){
        fValue[start]=heuristic[start];
        while(!open.empty()){
                double checkF=fValue[open.at(0)];
                int current, nCur;
                for(int n=0; n<open.size(); n++){
                        if(fValue[open.at(n)]<=checkF){
                                checkF=fValue[open.at(n)];
                                current=open.at(n);
                                nCur=n;
                        }
                }
                if(current==target)
                        return;
                open.erase(open.begin()+nCur);
                closed.push_back(current);
                for(int n=0; n<nodes.at(current)->edges.size(); n++){
                        double tentGScore=gScore[current]+nodes.at(current)->edges.at(n)->size;
                        double tentFScore=tentGScore+heuristic[nodes.at(current)->edges.at(n)->end->num];
                        if(contains(nodes.at(current)->edges.at(n)->end->num, closed)&&tentFScore>=fValue[nodes.at(current)->edges.at(n)->end->num])
                                continue;
                        else if(!contains(nodes.at(current)->edges.at(n)->end->num, open) || tentFScore<fValue[nodes.at(current)->edges.at(n)->end->num]){
                                pointers[nodes.at(current)->edges.at(n)->end->num]=current;
                                gScore[nodes.at(current)->edges.at(n)->end->num]=tentGScore;
                                fValue[nodes.at(current)->edges.at(n)->end->num]=tentFScore;
                                if(!contains(nodes.at(current)->edges.at(n)->end->num, open))
                                        open.push_back(nodes.at(current)->edges.at(n)->end->num);
                        }
                }
        }
}

int* Graph::heu(int end){
        int* a = new int [nodes.size()];
        for(int n=0; n<nodes.size(); n++)
                a[n]=sPathFrom(nodes.at(n)->name, nodes.at(end)->name);
        return a;
}


int Graph::sPathFrom(std::string from, std::string target){
        bool test1=true, test2=true;
        int num;
        std::vector<int> visited;
        std::queue<int> q;
        for(int n=0; n<nodes.size(); n++){
                if(nodes.at(n)->name==from){
                        test1=false;
                        num=n;
                }
                if(nodes.at(n)->name==target)
                        test2=false;
        }
        if(test1||test2)
                return -1;
        return bFirst(q, target, visited, num, 0, 0, 0, 0);
}

int Graph::bFirst(std::queue<int>& q, std::string target, std::vector<int>& visited, int num, int steps, int addedThisLevel, int addedNextLevel, int level){
        q.pop();
        Node node=*nodes.at(num);
        if(node.name==target)
                return level;
        if(node.edges.empty()&&q.empty())
                return -1;
        for(int n=0; n<node.edges.size(); n++){
                if(!contains(node.edges.at(n)->end->num, visited)){
                        q.push(node.edges.at(n)->end->num);
                        visited.push_back(node.edges.at(n)->end->num);
                        addedNextLevel++;
                }
        }
        if(steps==addedThisLevel){
                level++;
                addedThisLevel=addedNextLevel;
                addedNextLevel=0;
                steps=0;
        }
        return bFirst(q, target, visited, q.front(), steps+1, addedThisLevel, addedNextLevel, level);
}

bool Graph::pathFrom(std::string from, std::string target){
        bool test1=true, test2=true;
        int num;
        std::vector<int> visited;
        for(int n=0; n<nodes.size(); n++){
                if(nodes.at(n)->name==from){
                        test1=false;
                        num=n;
                }
                if(nodes.at(n)->name==target)
                        test2=false;
        }
        if(test1||test2)
                return false;
        return dFirst(num, target, visited);
}

bool Graph::dFirst(int num, std::string target, std::vector<int>& visited){
        Node node=*nodes.at(num);
        if(node.name==target)
                return true;
        if(node.edges.empty())
                return false;
        for(int n=0; n<node.edges.size(); n++){
                if(!contains(node.edges.at(n)->end->num, visited)){
                        visited.push_back(node.edges.at(n)->end->num);
                        if(dFirst(node.edges.at(n)->end->num, target, visited))
                                return true;
                }
        }
        return false;
}

bool Graph::contains(int num, std::vector<int> visited){
        for(int n=0; n<visited.size(); n++){
                if(visited.at(n)==num)
                        return true;
        }
        return false;
}

Graph::~Graph(){
        for(int n=0; n<nodes.size(); n++){
                for(int i=0; i<nodes.at(n)->edges.size(); i++)
                        delete nodes.at(n)->edges.at(i);
                delete nodes.at(n);
        }
}

int Graph::numNodes(){
        return nodes.size();
}

void Graph::addNode(std::string name, double x, double y){
        Node* temp = new Node;
        temp->name=name;
        temp->x=x;
        temp->y=y;
        temp->num=nodes.size();
        nodes.push_back(temp);
}

void Graph::addEdge(int start, int end, double size){
        if(!(end<nodes.size()&&start<nodes.size()))
                return;
        Edge* temp = new Edge;
        temp->size=size;
        temp->start=nodes.at(start);
        temp->end=nodes.at(end);
        nodes.at(start)->edges.push_back(temp);
}


void Graph::draw(sf::RenderWindow& window){
        for(int j=0; j<nodes.size(); j++){
                for(int i=0; i<nodes.at(j)->edges.size(); i++){
                        double startX=nodes.at(j)->edges.at(i)->start->x;
                        double startY=nodes.at(j)->edges.at(i)->start->y;
                        double endX=nodes.at(j)->edges.at(i)->end->x;
                        double endY=nodes.at(j)->edges.at(i)->end->y;
                        sf::Vertex line[2]={
                                sf::Vertex(sf::Vector2f(startX, startY)),
                                sf::Vertex(sf::Vector2f(endX, endY))
                        };
                        window.draw(line, 2, sf::Lines);
                        sf::CircleShape temp(5, 3);
                        temp.setOrigin(5, 5);
                        temp.setPosition(endX, endY);
                        double theta;
                        if(endX==startX&&startY<endY)
                                theta=3.1415/2;
                        else if(endX==startX&&endY<startY)
                                theta=3*3.1415/2;
                        else{
                                theta=atan((endY-startY)/(startX-endX));
                                if(endX>startX)
                                        theta=3.1415-theta;
                                if(endY>startY)
                                        theta=-theta;
                                if(endX>startX&&endY<startY)
                                        theta=-theta;
                                if(endX<startX&&endY>startY)
                                        theta=atan((endY-startY)/(startX-endX));
                        }
                        temp.rotate(30);
                        temp.rotate(-180/3.1415*theta);
                        temp.move(10*cos(theta), -10*sin(theta));
                        window.draw(temp);
                        std::ostringstream strs;
                        strs << nodes.at(j)->edges.at(i)->size;
                        std::string str = strs.str();
                        tempTxt.setFont(font);
                        tempTxt.setString(str);
                        tempTxt.setPosition((startX+endX)/2+(startX-endX)/5, (startY+endY)/2+(startY-endY)/5);
                        tempTxt.setCharacterSize(30);
                        tempTxt.setColor(sf::Color(0, 255, 255, 255));
                        window.draw(tempTxt);
                }
        }
        for(int j=0; j<nodes.size(); j++){
                sf::CircleShape temp(5, 60);
                temp.setOrigin(5, 5);
                temp.setPosition(sf::Vector2f(nodes.at(j)->x, nodes.at(j)->y));
                temp.setFillColor(sf::Color(255, 0, 0, 255));
                window.draw(temp);
                tempTxt.setFont(font);
                tempTxt.setString(nodes.at(j)->name);
                tempTxt.setPosition(sf::Vector2f(nodes.at(j)->x, nodes.at(j)->y-20));
                tempTxt.setCharacterSize(30);
                tempTxt.setColor(sf::Color(255, 255, 0, 255));
                window.draw(tempTxt);
               
        }
}

#endif
 

EDIT:
Also, the nodes.txt is on the form:

"nodeName" xPosition yPosition
"nodeName" xPosition yPosition

and the edges.txt is on the form:

startNode endNode size
startNode endNode size

where I'm pretty sure my bad practise of sometimes calling the cost of an edge it's "size", which is a dumb thing to do...

8
Graphics / Re: Fonts, don't we all love fonts...
« on: October 16, 2013, 08:56:58 pm »
Well, quite frankly I have not been idle the last few days! The debugger information is minimal at best. It is simply saying that the stack around various different variables is getting corrupted (to confirm, yes these are all around the sf::Text variable). Second, the problem is nigh on impossible to reproduce in minimal code, as this is an example of ONE of the issues I have been having ewith this. It seems completely arbitrairy, sometimes a small change in my code renders the same issue. I wish I could provide minimalized code. But quite frankly: I don't think the problem is in my code, I think it is in my setup of visual studio 2012. I'm throwing it out here because I have already done everything I can to try and find the actual issue.

9
Graphics / Fonts, don't we all love fonts...
« on: October 16, 2013, 08:42:50 pm »
So, I've been working with sf::Text and mainly sf::Font a little bit lately.
Sf::Font has been randomaly throwing errors at me whenever I edit my code. To Give you an example I need to show you two iterations of the same things, except that one will cause a crash and the other wont.

First of:

This won't cause a crash:
IN MAIN:

        graph.addNode("Dublin", 0, 500);
        graph.addNode("Edinburough", 150, 450);
        graph.addNode("Cambridge", 250, 650);
        graph.addNode("London", 250, 730);
        graph.addNode("Oslo", 700, 340);
        graph.addNode("Reyjkavik", 530, 120);
        graph.addNode("Narvik", 740, 100);
        graph.addNode("Gothenburg", 760, 490);
        graph.addNode("Stockholm", 890, 440);
        graph.addEdge(5, 4, 2000);
        graph.addEdge(7, 3, 140);
        graph.addEdge(0, 1, 245);
        graph.addEdge(1, 0, 199);
        graph.addEdge(2, 1, 99);
        graph.addEdge(0, 2, 180);
        graph.addEdge(2, 0, 30);
        graph.addEdge(0, 4, 55);
        graph.addEdge(2, 3, 68);
        graph.addEdge(4, 0, 70);
        graph.addEdge(4, 3, 102);
        graph.addEdge(3, 2, 200);
 

Where I'm using the font in text;¨
                sf::Text tempTxt;
                tempTxt.setFont(font);
                tempTxt.setString(nodes.at(j)->name);
                tempTxt.setPosition(sf::Vector2f(nodes.at(j)->x, nodes.at(j)->y-20));
                tempTxt.setCharacterSize(30);
                tempTxt.setColor(sf::Color(255, 255, 0, 255));
                window.draw(tempTxt);
 

Yes, there are a bunch of other things in there. But they seem to be irrelevant to my issue. Also, the
sf::Font font; line is a private variable in my class and the font is loaded with the normal font.loadFromFile("string");

Now to the interesting part:
if the part of main that builds my graph looks like this:
std::ifstream graphFile;
        std::string nodeFile="C:\\nodes.txt", edgeFile="C:\\edges.txt";
        graphFile.open(nodeFile);
        if(!graphFile.is_open()){
                std::cout<<"failed to open file: "<<nodeFile<<"\n";
                system("pause");
                return 0;
        }
        while(!graphFile.eof()){
                double x, y;
                std::string name;
                graphFile>>name;
                graphFile>>x;
                graphFile>>y;
                graph.addNode(name, x, y);
        }
        graphFile.close();
        graphFile.open(edgeFile);
        if(!graphFile.is_open()){
                std::cout<<"failed to open file: "<<edgeFile<<"\n";
                system("pause");
                return 0;
        }
        while(!graphFile.eof()){
                int start, stop;
                double cost;
                graphFile>>start;
                graphFile>>stop;
                graphFile>>cost;
                graph.addEdge(start, stop, cost);
        }
        graphFile.close();
 

and the part that uses text stays the same, my code crashes. Now, for accuracy's sake I want to make it clear that yes, the result of the two different pieces of code are both the exact same, I'm using the same input just from a file instead.

Sure, there are other things related to this I'm sure. But iuf anyone has any clue about what I have done wrong so that I can hopew to find it, please tell me!!!

10
Graphics / Re: %&#¤%&¤#&¤ FONTS!
« on: October 14, 2013, 09:18:30 pm »
well... That did get it loaded... now its throwing exceptions in release mode and randomly corruption the stack in debug mode... I dont understand. I've been doing this for a long time now, and never before have I ran into something seamlessly corruption my stack -.- anyway... Here is the member function thats having issues:
void Graph::draw(sf::RenderWindow& window){
        for(int j=0; j<nodes.size(); j++){
                for(int i=0; i<nodes.at(j)->edges.size(); i++){
                        double startX=nodes.at(j)->edges.at(i)->start->x;
                        double startY=nodes.at(j)->edges.at(i)->start->y;
                        double endX=nodes.at(j)->edges.at(i)->end->x;
                        double endY=nodes.at(j)->edges.at(i)->end->y;
                        sf::Vertex line[2]={
                                sf::Vertex(sf::Vector2f(startX, startY)),
                                sf::Vertex(sf::Vector2f(endX, endY))
                        };
                        window.draw(line, 2, sf::Lines);
                        sf::CircleShape temp(5, 3);
                        temp.setOrigin(5, 5);
                        temp.setPosition(endX, endY);
                        double theta;
                        if(endX==startX&&startY<endY)
                                theta=3.1415/2;
                        else if(endX==startX&&endY<startY)
                                theta=3*3.1415/2;
                        else{
                                theta=atan((endY-startY)/(startX-endX));
                                if(endX>startX)
                                        theta=3.1415-theta;
                                if(endY>startY)
                                        theta=-theta;
                                if(endX>startX&&endY<startY)
                                        theta=-theta;
                        }
                        temp.rotate(30);
                        temp.rotate(-180/3.1415*theta);
                        temp.move(10*cos(theta), -10*sin(theta));
                        window.draw(temp);
                        std::ostringstream strs;
                        strs << nodes.at(j)->edges.at(i)->size;
                        std::string str = strs.str();
                        sf::Text tempTxt("str", font, 50);
                        tempTxt.setFont(font);
                        tempTxt.setString(str);
                        tempTxt.setPosition((startX+endX)/2+(startX-endX)/5, (startY+endY)/2+(startY-endY)/5);
                        tempTxt.setCharacterSize(12);
                        tempTxt.setColor(sf::Color(0, 255, 255, 255));
                        window.draw(tempTxt);
                }
        }
//From here and onwards the stack gets randomly corrupted...
        for(int j=0; j<nodes.size(); j++){
                sf::Text tempTxt("str", font, 50);
                tempTxt.setFont(font);
                tempTxt.setString(nodes.at(j)->name);
                tempTxt.setPosition(sf::Vector2f(nodes.at(j)->x, nodes.at(j)->y-20));
                tempTxt.setCharacterSize(12);
                tempTxt.setColor(sf::Color(255, 255, 0, 255));
                window.draw(tempTxt);
                sf::CircleShape temp(5, 60);
                temp.setOrigin(5, 5);
                temp.setPosition(sf::Vector2f(nodes.at(j)->x, nodes.at(j)->y));
                temp.setFillColor(sf::Color(255, 0, 0, 255));
                window.draw(temp);
        }
}

Anything not related directly to the font (which is a private member of the Graph class) works just fine. All the drawables work no problem... This is just so confusing -.-

EDIT: What's even better, none of this happens if I don't load the font -.-

11
Graphics / %&#¤%&¤#&¤ FONTS!
« on: October 14, 2013, 09:00:38 pm »
So yeah... Let's talk about ""#¤"&% fonts... I've spent two days trying to make the VERY simple line:
font.loadFromFile("C:\Windows\Fonts\Calibri.ttf");
work. But no matter what I try to to I get the good old "failed to create the font face" error... Is this a bug with Fonts?! I'm going insane... There is no minimal code to be posted, as it is litterally just that one line, in an innocent constructor... :/

12
Graphics / Re: Having strange trouble with texture sizes!
« on: August 24, 2013, 11:18:02 am »
Nvm... I'm a strange strange special kind of stupid... Had misinterpereted how the rectangles worked (I swear, i got it workingyesterday with another program...)

13
Graphics / [SOLVED]Having strange trouble with texture sizes!
« on: August 24, 2013, 11:08:06 am »
Basically, I've never progremmed with SFML before. I have alot of experience with c++ tho. What I'm trying to do is go slightly off course from the tutorial and create my own little texture.


Texture SwordTexture;
Image SwordImage;
float xSword=400, ySword=250;
IntRect SwordRect((int)xSword, (int)ySword, 50, 100);

if(!SwordTexture.create(50, 100))
                std::cout<<"SwordTextureCreateError";
if(!SwordImage.loadFromFile("Sword.png"))
                std::cout<<"SwordImageLoadError";
if(!SwordTexture.loadFromImage(SwordImage, SwordRect))
                std::cout<<"SwordTextueLoadFromFileError";//This part is causing some strange issues

 

The problem I'm having is this: The image is not loaded onto the Texture, and the program sends a really strange message saying the internal size of my texture is some riddiculus number like 4294966946x4294967149 and that the mximum is 16384x16384. Now, what I don't get is why it would do this, my image is only 50x100 pixels... I've had similar problems with other images Ive been trying to load :/ HELP!

Pages: [1]
anything