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

Pages: [1]
1
Graphics / Re: Can't draw sf::Sprites over modern OpenGL context
« on: November 09, 2012, 06:11:36 pm »
Thank you! I have to unbind all my buffers

        glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind all the buffers
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
        glBindVertexArray(0);

And it works fine! Thanks, G :)

2
Graphics / Can't draw sf::Sprites over modern OpenGL context
« on: November 08, 2012, 07:55:02 pm »
Hi, I'm experiencing an issue with OpenGL and SFML. I'm using SFML 2.0 and OpenGL 3.2.

Basically, I'd like to draw an in game GUI that is drawn over the OpenGL context, when OpenGL is not being drawn, my GUI shows fine. However, as soon as I start drawing something (with glDrawElements, the GUI vanishes. I do draw the GUI after I draw my objects, and I keep UI drawing inside window.pushGLStates() and window.popGLStates();. Here is my game loop:

    while (window.isOpen())
    {
        window.setActive();
        sf::Event event;

        while (window.pollEvent(event)) // Event loop
        {
            switch (event.type)
            {
                // Will send most input to the InputHandler to be processed there after the event has ended
                case sf::Event::MouseButtonPressed:
                    inputHandler.mouseClicked();
                    break;

                case sf::Event::KeyPressed:
                    inputHandler.keyPressed(event.key.code);
                    break;

                case sf::Event::Closed:
                    closeGame();
                    break;

                case sf::Event::GainedFocus:
                    inputHandler.gainedFocus();
                    break;

                case sf::Event::LostFocus:
                    inputHandler.lostFocus();
                    break;

                case sf::Event::Resized:
                    inputHandler.windowWasResized = true;
                    break;

                case sf::Event::MouseMoved:
                    inputHandler.mouseMoved = true;
                    break;

                default:
                    break;
            }
        }

        if (!closing)
            inputHandler.onFrame();

        if (renderingGL && !closing)
        {
            currentCamera->onTick(); // Refresh camera
            renderer->render(); // This draws the OpenGL stuff with glDrawElements!
        }

        window.pushGLStates();
        fontRenderer.drawString("Hello World!", 50, 50, 30, 0, 0, 0, &window); // This draws a nice "Hello World" in the corner when OpenGL is not being drawn to. Otherwise, it dissapears.
        window.popGLStates();


        window.display();
    }
 

I suspect my issue might be because I'm defining the matrices myself and passing to my shaders instead of using glPush/PopMatrix.

If you need more code, just ask.
Thanks,

Jishaxe

3
Network / Re: [SOLVED] [2.0] Simple issues with sf::TcpSocket
« on: September 04, 2012, 09:44:13 am »
Solved. Thanks for the help :)

4
Network / Re: [2.0] Simple issues with sf::TcpSocket
« on: September 03, 2012, 11:59:14 pm »
I only did this for a moment for testing, and it didn't make a difference. And you've just made me realise I did it wrong. I did Buffer[99] = '\0' but of course the buffer might not be filled up to that extent.

But the \0 should have already be added right?

I will try and add it like this, Buffer[received] = '\0'

UPDATE:
Wow. That fixed it. Can't believe it actually worked. My data appears to be arriving correctly now. Thanks for the help, Laurent! I will do more testing then if it works completely, I will mark the topic as solved. :)

5
Network / Re: [2.0] Simple issues with sf::TcpSocket
« on: September 03, 2012, 11:52:19 pm »
Right now, I am connecting the client to netcat and sending data through that, so there is no code for that.

I redid the test and it now prints the received var with this line:
std::cout << "Received: " << received << std::endl;

Here are the results of the test:

What was sent from the server (netcat):

123
1234
12345
123456
1234567
12345678
123456789
1234567890
12345678901
123456789012
1234567890123
12345678901234
123456789012345
1234567890123456
12345678901234567
123456789012345678
1234567890123456789
12345678901234567890
 

And this is how the client displayed it: (It's pretty mangled so I had to display it without the code tags so the actual symbols are there)

123
■   h♥×w‗☺×wReceived: 4
1234
   h♥×w‗☺×wReceived: 5
12345
  h♥×w‗☺×wReceived: 6
123456
 h♥×w‗☺×wReceived: 7
1234567
h♥×w‗☺×wReceived: 8
12345678
♥×w‗☺×wReceived: 9
123456789
×w‗☺×wReceived: 10
1234567890
w‗☺×wReceived: 11
12345678901
‗☺×wReceived: 12
123456789012
☺×wReceived: 13
1234567890123
×wReceived: 14
12345678901234
wReceived: 15
123456789012345
Received: 16
1234567890123456
Received: 17
12345678901234567
UvH¹═☻Received: 18
123456789012345678
vH¹═☻Received: 19
1234567890123456789
H¹═☻Received: 20
12345678901234567890
¹═☻Received: 21


With some other tests I did, I noticed a pattern.

I will illustrate it.

Server: 12356
Client: 123456

Server: 123
Client: 123<linebreak>56

Server: 12
Client: 12<linebreak>56

Server: 123456
Client: 123456

Server: 1234567
Client: 1234567

Server: 123
Client: 123<linebreak>567

It's like, a "shadow" of the largest amount of characters so far is kept in the buffer and it will print out the amount of characters in the shadow minus the amount of characters actually sent, after a linebreak.

Also, before the the number before the linebreak is sent, there is a bunch of garbled characters, IE
 h♥×w‗☺×w123

6
Network / Re: [2.0] Simple issues with sf::TcpSocket
« on: September 03, 2012, 11:10:03 pm »
I've looked through the example but couldn't find any differences in the receiving code.

But there is a difference in where the receiving code is. First of all, in the main thread, the connection is established, and then it spawns a thread with that while loop to receive and process data. Could this be where my problem is? Does it not work with multithreading, or using it in a while loop?

EDIT:
There is also another difference from the example. In the example, receive is called once and only once. On mine, it's put in an infinite loop. It appears the first receive() is correct, but the next ones are garbled/have text remaining in it. It can't be because of the buffer because the buffer is recreated every loop. Maybe it's something internal? Do I need to "flush" the socket or something? Has anyone had experience with using receive multiple times?

7
Network / Re: [2.0] Simple issues with sf::TcpSocket
« on: September 03, 2012, 10:53:09 pm »
Alright, will do, thanks :)

8
Network / Re: [2.0] Simple issues with sf::TcpSocket
« on: September 03, 2012, 10:44:17 pm »
I've added a check for the status and I'm still getting garbage.

Also, in the test, the data coming from the server is being sent with netcat, and I'm sure that does add a terminating '\0' (I tried adding it on client-side and still garbage). Also, this will be an IRC bot, so I won't have control of the data coming from the other side.
My new code:

    while (true)
    {
        char Buffer[100];
        std::size_t received = 0;

        if (ircConnection.receive(Buffer,sizeof(Buffer) == sf::Socket::Done)
        {
            std::cout << Buffer;
        }

        delete Buffer;
    }
 

9
Network / [SOLVED] [2.0] Simple issues with sf::TcpSocket
« on: September 03, 2012, 09:54:31 pm »
It appears that the buffer I am receiving with is self accumulative or something. However it is, I'm not doing it right. I just want to output all data received correctly to the console, if someone can point me in the right direction that would be great.

Source code relating to the issue:
(This loop is run in another thread)
while (true)
{
    char Buffer[100];
    std::size_t received;
    tcpSock.receive(Buffer,sizeof(Buffer),received);
    std::cout << Buffer;
}
 

Describing the results and problem:

--- SENT FROM SERVER

1234567890
1234567890
1
2
3
4
5
6
7
8
9
0

--- DISPLAYED ON CLIENT

1234567890
00000000000000000
1234567890
00000000000000000
1
34567890
00000000000000000
2
34567890
00000000000000000
3
34567890
00000000000000000
4
34567890
00000000000000000
5
34567890
00000000000000000
6
34567890
00000000000000000
7
34567890
00000000000000000
8
34567890
00000000000000000
9
34567890
00000000000000000
0
34567890
00000000000000000
 

Thanks in advance.

Pages: [1]