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

Pages: 1 2 3 [4]
46
Graphics / Re: Clear or reset a texture?
« on: March 27, 2014, 10:10:17 pm »
Oh, I may have misunderstood your question :-[
Hmm. So when you update a texture with a smaller image, the old content to get cleared? Maybe leave some wierd "garbage" pixels?

If thats the case. Well I've had a similar problem with WebGL/OpenGL a year ago. Can't remember what my solution ended up beeing, but if I remember right I just created another thread and added the image to that.

Maybe the other guys have a better solution for problem :-)

47
Graphics / Re: Clear or reset a texture?
« on: March 27, 2014, 09:32:51 pm »
My suggestion would be to use pointers to the textures instead.
This way you wont have these problems. You simple make the pointer, point to another texture.

Correct me if im wrong. But are you loading the image everytime you need a texture for a sprite? Thats a bad way of handling assets in general. Load all the textures/assets you need for the current scene into a array of some kind, maybe a map. When the scene is done, delete those textures/assets you dont need further to free up some memory and don't get alot of garbage.

48
General / Re: Displaying Text using .txt files
« on: March 27, 2014, 05:03:28 pm »
What you want is called wordwrapping.
But here some code I made for you, that hopefully may help you get going

#include <fstream>
#include <sstream>
#include <list>
#include <SFML\Graphics\Text.hpp>
#include <SFML\Graphics\Rect.hpp>

int main()
{
        std::string line;
        std::ifstream file;
        std::list<sf::Text> textList;
        sf::Text text("", font, 50); //Load your font and replace 'font'


        file.open("text.txt"); //Set your path here
        if(file.is_open())
        {
                while(std::getline(file, line))
                {
                        //Getting every line of the .txt file and putting it in the 'line' string
                        text.setString(line);
                        textList.push_back(text);
                }
        }

        float i = 0;
        for(std::list<sf::Text>::iterator it = textList.begin(); it != textList.end(); ++it)
        {
                sf::Text& text = *it;
                sf::FloatRect boundings = text.getLocalBounds();
                text.setPosition(0.f, i * (boundings.height + 5));
                ++i;

                //draw or something here
        }
}

49
General / Re: Problem with FPS-free space physics
« on: March 27, 2014, 04:00:59 pm »
Quote
(craft.ThrustActive - craft.ReverseActive * 0.5)

Maybe you have to mulitiply with delta here somehow.

50
General / Re: Displaying Text using .txt files
« on: March 27, 2014, 03:34:09 pm »
Can you please provide some code?
Because it should be easy to implement with a simple stream.

51
Graphics / Re: Font loading problem (Crash)
« on: March 19, 2014, 04:57:06 pm »
First: You should NOT initialize your class members in the header file.

Second: Did some testing after some modification for making it working with visual c++. So it making me wonder, does your code compile at all? After I did get your the code compiled, I got no crash. hmmm...

52
Please don't link this way, it is not cross platform and writing non cross platform code is a very bad habit once started.

I know that it is non-cross platform and I noramlly don't link that way. But thanks for reminding me.

53
General / Re: Problem With Text
« on: March 18, 2014, 11:54:27 pm »
Like Jesper said, use the std::to_string.

sf::Text text;
sf::String str = std::to_string(123);

//add font and stuff

text.setString(str);

54
Oooh, I just missed a library ... stupid me!

#pragma comment(lib, "ws2_32.lib")

and now its working :-)

55
Network / Unresolved external from static library Visual Studio 2013
« on: March 18, 2014, 10:28:28 pm »
Hi!

I've upgraded my visual studio to 2013 lately and have been recompiling the libraries.
Everything have been working like a charm, untill i tried to use a class from the network library ...  :(

I'm linking it correctly with "sfml-network-s-d.lib", "SFML_STATIC" and so on..

I get no error compiling SFML in Visual Studio 2013.

I dont have a log on this computer, but i it's just ALOT of unresolved externals. Nothing about "__declspec(dllimport". Its like the whole static library is broken, but the library is being compiled without any error.

Anyone who have a idea whats wrong? The only idea I have right now is going back to Visual Studio 2012 and use the precompiled libraries.

UPDATE:

Here is a simple test code
#include <SFML\Network.hpp>

int main()
{
        sf::TcpSocket socket;
        return 0;
}

Here is my log
Error   1       error LNK2019: unresolved external symbol __imp__setsockopt@20 referenced in function "protected: void __thiscall sf::Socket::create(unsigned int)" (?create@Socket@sf@@IAEXI@Z)        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(Socket.obj)      Testing
Error   2       error LNK2019: unresolved external symbol __imp__socket@12 referenced in function "protected: void __thiscall sf::Socket::create(void)" (?create@Socket@sf@@IAEXXZ)     C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(Socket.obj)      Testing
Error   3       error LNK2001: unresolved external symbol __imp__socket@12      C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(IpAddress.obj)   Testing
Error   4       error LNK2019: unresolved external symbol __imp__connect@12 referenced in function "public: enum sf::Socket::Status __thiscall sf::TcpSocket::connect(class sf::IpAddress const &,unsigned short,class sf::Time)" (?connect@TcpSocket@sf@@QAE?AW4Status@Socket@2@ABVIpAddress@2@GVTime@2@@Z)    C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(TcpSocket.obj)   Testing
Error   5       error LNK2001: unresolved external symbol __imp__connect@12     C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(IpAddress.obj)   Testing
Error   6       error LNK2019: unresolved external symbol __imp__getpeername@12 referenced in function "public: class sf::IpAddress __thiscall sf::TcpSocket::getRemoteAddress(void)const " (?getRemoteAddress@TcpSocket@sf@@QBE?AVIpAddress@2@XZ)      C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(TcpSocket.obj)   Testing
Error   7       error LNK2019: unresolved external symbol __imp__getsockname@12 referenced in function "public: unsigned short __thiscall sf::TcpSocket::getLocalPort(void)const " (?getLocalPort@TcpSocket@sf@@QBEGXZ) C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(TcpSocket.obj)   Testing
Error   8       error LNK2001: unresolved external symbol __imp__getsockname@12 C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(IpAddress.obj)   Testing
Error   9       error LNK2019: unresolved external symbol __imp__htonl@4 referenced in function "public: enum sf::Socket::Status __thiscall sf::TcpSocket::send(class sf::Packet &)" (?send@TcpSocket@sf@@QAE?AW4Status@Socket@2@AAVPacket@2@@Z)        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(TcpSocket.obj)   Testing
Error   10      error LNK2001: unresolved external symbol __imp__htonl@4        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(SocketImpl.obj)  Testing
Error   11      error LNK2001: unresolved external symbol __imp__htonl@4        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(IpAddress.obj)   Testing
Error   12      error LNK2001: unresolved external symbol __imp__htonl@4        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(Packet.obj)      Testing
Error   13      error LNK2019: unresolved external symbol __imp__ntohl@4 referenced in function "public: class sf::IpAddress __thiscall sf::TcpSocket::getRemoteAddress(void)const " (?getRemoteAddress@TcpSocket@sf@@QBE?AVIpAddress@2@XZ)     C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(TcpSocket.obj)   Testing
Error   14      error LNK2001: unresolved external symbol __imp__ntohl@4        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(IpAddress.obj)   Testing
Error   15      error LNK2001: unresolved external symbol __imp__ntohl@4        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(Packet.obj)      Testing
Error   16      error LNK2019: unresolved external symbol __imp__ntohs@4 referenced in function "public: unsigned short __thiscall sf::TcpSocket::getLocalPort(void)const " (?getLocalPort@TcpSocket@sf@@QBEGXZ)        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(TcpSocket.obj)   Testing
Error   17      error LNK2001: unresolved external symbol __imp__ntohs@4        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(Packet.obj)      Testing
Error   18      error LNK2019: unresolved external symbol __imp__recv@16 referenced in function "public: enum sf::Socket::Status __thiscall sf::TcpSocket::receive(void *,unsigned int,unsigned int &)" (?receive@TcpSocket@sf@@QAE?AW4Status@Socket@2@PAXIAAI@Z)       C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(TcpSocket.obj)   Testing
Error   19      error LNK2019: unresolved external symbol __imp__select@20 referenced in function "public: enum sf::Socket::Status __thiscall sf::TcpSocket::connect(class sf::IpAddress const &,unsigned short,class sf::Time)" (?connect@TcpSocket@sf@@QAE?AW4Status@Socket@2@ABVIpAddress@2@GVTime@2@@Z)     C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(TcpSocket.obj)   Testing
Error   20      error LNK2019: unresolved external symbol __imp__send@16 referenced in function "public: enum sf::Socket::Status __thiscall sf::TcpSocket::send(void const *,unsigned int)" (?send@TcpSocket@sf@@QAE?AW4Status@Socket@2@PBXI@Z) C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(TcpSocket.obj)   Testing
Error   21      error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function "public: static void __cdecl sf::priv::SocketImpl::close(unsigned int)" (?close@SocketImpl@priv@sf@@SAXI@Z)       C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(SocketImpl.obj)  Testing
Error   22      error LNK2019: unresolved external symbol __imp__ioctlsocket@12 referenced in function "public: static void __cdecl sf::priv::SocketImpl::setBlocking(unsigned int,bool)" (?setBlocking@SocketImpl@priv@sf@@SAXI_N@Z)   C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(SocketImpl.obj)  Testing
Error   23      error LNK2019: unresolved external symbol __imp__htons@4 referenced in function "public: static struct sockaddr_in __cdecl sf::priv::SocketImpl::createAddress(unsigned int,unsigned short)" (?createAddress@SocketImpl@priv@sf@@SA?AUsockaddr_in@@IG@Z)        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(SocketImpl.obj)  Testing
Error   24      error LNK2001: unresolved external symbol __imp__htons@4        C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(Packet.obj)      Testing
Error   25      error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function "public: __thiscall sf::priv::SocketInitializer::SocketInitializer(void)" (??0SocketInitializer@priv@sf@@QAE@XZ)   C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(SocketImpl.obj)  Testing
Error   26      error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function "public: __thiscall sf::priv::SocketInitializer::~SocketInitializer(void)" (??1SocketInitializer@priv@sf@@QAE@XZ)  C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(SocketImpl.obj)  Testing
Error   27      error LNK2019: unresolved external symbol __imp__WSAGetLastError@0 referenced in function "public: static enum sf::Socket::Status __cdecl sf::priv::SocketImpl::getErrorStatus(void)" (?getErrorStatus@SocketImpl@priv@sf@@SA?AW4Status@Socket@3@XZ)    C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(SocketImpl.obj)  Testing
Error   28      error LNK2019: unresolved external symbol __imp__inet_addr@4 referenced in function "unsigned int __cdecl `anonymous namespace'::resolve(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?resolve@?A0xffb3341e@@YAIABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)       C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(IpAddress.obj)   Testing
Error   29      error LNK2019: unresolved external symbol __imp__inet_ntoa@4 referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall sf::IpAddress::toString(void)const " (?toString@IpAddress@sf@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)    C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(IpAddress.obj)   Testing
Error   30      error LNK2019: unresolved external symbol __imp__getaddrinfo@16 referenced in function "unsigned int __cdecl `anonymous namespace'::resolve(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?resolve@?A0xffb3341e@@YAIABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)    C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(IpAddress.obj)   Testing
Error   31      error LNK2019: unresolved external symbol __imp__freeaddrinfo@4 referenced in function "unsigned int __cdecl `anonymous namespace'::resolve(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?resolve@?A0xffb3341e@@YAIABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)    C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Testing\sfml-network-s-d.lib(IpAddress.obj)   Testing
Error   32      error LNK1120: 21 unresolved externals  C:\Users\Peter Bech\documents\visual studio 2013\Projects\Testing\Debug\Testing.exe     Testing
 

Pages: 1 2 3 [4]