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

Pages: [1] 2
1
Window / Window.display()
« on: April 12, 2012, 08:34:14 pm »
What does the window.display() function actually do? Does it call glFlush()? Does it swap buffers? (Does SFML window use doube buffering?)

2
Window / Re: Having trouble with threaded opengl calls
« on: March 31, 2012, 07:20:10 pm »
Worked like a charm, thanks Laurent

3
Window / Re: Having trouble with threaded opengl calls
« on: March 31, 2012, 02:07:01 am »
#include <SFML/Window.hpp>
#include "gl/glew.h"

class Renderer
{
    sf::Window*     m_window;
    sf::Thread      m_drawThread;

    public:
        Renderer(sf::Window* window);
        virtual ~Renderer(){};

        void onThink();
        void onDrawFrame();
        void onInitialize();
        void event_resized(sf::Event& evt);
        void setViewport();
};

Renderer::Renderer(sf::Window* window)
:   m_drawThread(&Renderer::onDrawFrame, this)
{
    m_window = window;
}

void Renderer::onInitialize()
{
    sf::Context gl;
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    setViewport();
}

void Renderer::onDrawFrame(){
    m_window->setActive(true);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    m_window->display();
}

void Renderer::onThink()
{
    m_window->setActive(false);
    m_drawThread.launch();
}

void Renderer::event_resized(sf::Event& evt)
{
    setViewport();
}

void Renderer::setViewport()
{
    int width  =   m_window->getSize().x;
    int height =   m_window->getSize().y;

    glViewport(0, 0, (GLsizei)width, (GLsizei)height); // Set our viewport to the size of our window
    glMatrixMode(GL_PROJECTION); // Switch to the projection matrix so that we can manipulate how our scene is viewed
    glLoadIdentity(); // Reset the projection matrix to the identity matrix so that we don't get any artifacts (cleaning up)
    gluPerspective(60, (GLfloat)width / (GLfloat)height, 1.0, 100.0); // Set the Field of view angle (in degrees), the aspect ratio of our window, and the new and far planes
    glMatrixMode(GL_MODELVIEW);
}


int main()
{
    sf::Window window(sf::VideoMode(500, 500), "Test");
    Renderer myrenderer(&window);
    myrenderer.onInitialize();
    sf::Event evt;
    while(window.isOpen()){
        while(window.pollEvent(evt)){
            if(evt.type == sf::Event::KeyPressed){
                window.close();
            }
        }
        myrenderer.onThink();
    }
}

4
Window / Having trouble with threaded opengl calls
« on: March 30, 2012, 07:23:34 pm »
I am trying to make opengl calls to a window from a separate thread than the window is created in. Before calling the thread I call setActive(false) and in the thread I call setActive(true) but the clear color is not applied.

I didn't include my viewport or projection setup, but the code works when I replace drawThread.launch() with the contents of onDraw().

Code: [Select]
Renderer::Renderer()
:    drawThread(&Renderer::onDraw, this)
{}

Renderer::onDraw()
{
    sf::Context glContext; //I have included, excluded, and moved this around but it makes no difference
    m_window->setActive(true);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    m_window->display();
}

Renderer::startDraw()
{
    m_window->setActive(false);
    drawThread.launch();

   
    //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //This works when uncommented
   // m_window->display();
}

int main()
{
    while(window->isOpen()){
        startDraw();
    }
}

This results in "Failed to activate window's the context" spam

5
Window / Framerate drops from 1.6 to 2.0
« on: February 18, 2012, 09:16:31 pm »
Sorry to keep bumping, but:

Is it better to call the render thread over and over from the main thread, or to call it once and have a while loop in the render thread?

6
Window / Can i pass a RenderWindow to another class
« on: February 17, 2012, 01:34:37 am »
try an initializing m_window in an initialization list:

Code: [Select]

MyClass::MyClass(sf::RenderWindow& window)
: m_window(window)
{
   this->m_text = sf::Text("Hello World");
}

7
Window / Framerate drops from 1.6 to 2.0
« on: February 16, 2012, 06:52:08 pm »
Also, graphics are not drawn in a a while loop within the graphics thread, the graphics thread is perpetually launched from the main thread.

8
Window / Framerate drops from 1.6 to 2.0
« on: February 15, 2012, 02:59:40 am »
Events are handled in the main thread and graphics are handled in a separate thread.

9
Window / Framerate drops from 1.6 to 2.0
« on: February 14, 2012, 11:22:22 pm »
Right now I am calling the Render thread in the main thread when it is not running, I changed it to call the render thread once and have a while Window->IsOpen() in the render thread. This restores framerate but causes the program to not respond.

10
Window / Framerate drops from 1.6 to 2.0
« on: February 14, 2012, 06:00:57 pm »
debug

EDIT
Just tested, release build has the same framerate

11
General / SFML 2.0 And Eclipse
« on: February 14, 2012, 12:17:18 am »
Yea I agree, eclipse is terrible for C++.

12
Window / Framerate drops from 1.6 to 2.0
« on: February 13, 2012, 11:59:35 pm »
I recently updated my game engine with SFML 2.0 and after updating for all the API changes and compiling, I noticed a drastic drop in framerate (Before it was capped at 30fps, not I get 7-9 fps). I've tried commenting large sections of code just to see if it may be causing the framerate drop, but the only thing that makes a difference is if comment my Window.Clear(), Window.Draw() loop, and Window.Display() all together. Just commenting one (I.E. just the Draw loop) doesn't make any change.

The Frame is drawn in a separate thread.

Compiling on Windows 7 64bit (32bit exe)  Intel Core i7-2600k

Any reason why this may be happening?

13
General / SFML 2.0 And Eclipse
« on: February 10, 2012, 01:41:22 am »
Hey guys, so i'm trying to include SFML 2.0 in eclipse and i'm having difficulties. i tired following this forum post  http://www.sfml-dev.org/forum/viewtopic.php?t=2246&sid=d66bad4f51a9782b7cf490e372b46b93  , but with the appropriate filenames and paths, but no luck. i'm getting the issue
Code: [Select]
ld.exe: cannot find -llibsfml-window but it's not just for window, it's for all of them. i've triple checked that my filenames are correct, and my paths, and i've made everything match the forum post.

If you have any idea, please help me out!

Thanks.

14
System / sf::Thread and cin
« on: December 12, 2011, 06:40:50 pm »
That is odd, it seems as though cin is pausing the thread, but it shouldn't

15
Graphics / Sprites only drawn once
« on: December 07, 2011, 09:24:04 am »
Quote from: "Groogy"
Hmmm it almost sounds like if the sf::Image is destroyed somehow. But that wouldn't make sense.

I rewrote much of the Renderer. I know have a LinkableObject that inherits from sf::Sprite to add layer and depth data to the sprite. The sf::Sprite.GetImage() always returns a valid memory location, but the same drawing problem is still occurring.

I am using a reinterpret_cast to cast a sf::Sprite to a LinkableObject

Here are the relevant files and locations:
Renderer.cpp line 30
https://github.com/b3ngr33ni3r/Magnet/blob/master/OurGame/Renderer.cpp
LinkableObject.h
https://github.com/b3ngr33ni3r/Magnet/blob/master/OurGame/Handler/Renderer/LinkableObject.h
Quote from: "Groogy"

One last thing, can you just give a quick try without the renderer at all? Just plain old draw calls.

Pages: [1] 2