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

Pages: [1]
1
SFML projects / Premake Build System for SFML
« on: December 25, 2011, 11:46:53 pm »
It seems your code has 404'ed. Would you mind reposting it?

2
Graphics / FIXED undefined reference to sf::RenderWindow::RenderWindow
« on: December 21, 2011, 06:35:45 am »
Im pretty sure when you link the lib files you have to do them in reverse order of dependency.

So it would be: -lsfml-network -lsfml-graphics -lsfml-window -lsfml-system

3
Window / window.SetView() Problem
« on: December 19, 2011, 02:56:08 am »
Makes sense now. Thanks a bunch Laurent

4
Window / window.SetView() Problem
« on: December 18, 2011, 11:08:21 pm »
Im using SFML 1.6 and whenever I call the set view function the window only displays a blank screen, drawing none of my objects.

Im using this when the window is resized so the view matches the dimensions of the window. My code looks like this:
Code: [Select]

if(events.Type == sf::Event::Resized)
{
    sf::View v(sf::FloatRect(0, 0, events.Size.Width, events.Size.Height));
    window.SetView(v);
}


even when I set the view to the current view the screen is drawn blank:
Code: [Select]

if(events.Type == sf::Event::Resized)
{
    sf::View v = window.GetView();
    window.SetView(v);
}


The only way I have managed to resize my view is by directly referencing the default view (it wont let my directly reference the current view).
Code: [Select]

if(events.Type == sf::Event::Resized)
{
    sf::View &v = window.GetDefaultView();
    v.SetFromRect(sf::FloatRect(0, 0, events.Size.Width, events.Size.Height);
}


Any ideas? Its probably something obvious Im over looking, and I appreciate the help.

Edit:
In my first code example I had declared my view initialization wrong. Regardless I still cant figure out whats wrong.

5
Graphics / Problem loading fonts
« on: July 22, 2011, 05:09:30 am »
Whenever I try to load a font I always get the same error saying <cannot open resource>.  I have tried this with several different fonts, all returning the same error. Ive also tried specifying the full path to the font, and even putting it in the same folder with my program all to no avail.

Any ideas whats causing this?
Thanks -James

6
Network / Help with instant messenger
« on: July 18, 2011, 09:46:39 pm »
Im new to networking and Im trying to create a simple instant messenger to better understand it.

My code is:
Code: [Select]

#include <iostream>
#include <string>
#include <sstream>
#include <SFML\System.hpp>
#include <SFML\Network.hpp>

void SendData(void*);
void RecieveData(void*);

int main()
{
sf::Thread RecieveData(&RecieveData);
RecieveData.Launch();

std::cout << "Type the IP address you wish to connect to, then press enter." << std::endl;
std::cout << "Example: 192.168.0.1" << std::endl;

std::string FriendIP;
std::cin >> FriendIP;

sf::Thread SendData(&SendData, &FriendIP);
SendData.Launch();

RecieveData.Wait();
SendData.Wait();

return EXIT_SUCCESS;
}

void SendData(void* UserData)
{
std::string* FriendIP = static_cast<std::string*>(UserData);
sf::SocketTCP Client;
if(Client.Connect(5000, *FriendIP) == sf::Socket::Done) // insert message loop here
{
std::cout << "Message to send:" << std::endl;
std::string Message;
std::getline(std::cin, Message);
sf::Packet Send;
Send << Message;
if(Client.Send(Send) == sf::Socket::Done)
{
std::cout << "Message sent" << std::endl;
}
else
{
std::cout << "Error: Could not send message" << std::endl;
}
}
else
{
std::cout << "Error: Could not connect to " << *FriendIP << std::endl;
}
}

void RecieveData(void* UserData)
{
sf::SocketTCP Listener;
if(!Listener.Listen(5000))
{
std::cout << "Error: Could not listen for connections on port 5000" << std::endl;
}
else
{
sf::IPAddress ClientAddress;
sf::SocketTCP Client;
if(Listener.Accept(Client, &ClientAddress) == sf::Socket::Done)
{
sf::Packet Recieved;
std::string Message;
if(Client.Receive(Recieved) == sf::Socket::Done)
{
if(Recieved >> Message)
{
std::cout << Message << std::endl;
}
else
{
std::cout << "Error: Could not read data from packet" << std::endl;
}
}
else
{
std::cout << "Error: Could not recieve packet" << std::endl;
}
}
else
{
std::cout << "Error: Could not accept connection from " << ClientAddress << std::endl;
}
}
}


Iv tried it several different ways and have become stuck. I always get the same error, where my socket wont connect. Iv tried it with both my IP address (local and public) as well as with my friend who was also running this program on his computer.

Any thoughts or suggestions, Im fairly new at programming so anything would help. Thanks

Pages: [1]