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

Pages: 1 2 [3]
31
Graphics / Re: Thread causes a crash in SFML/wxWidgets app
« on: January 05, 2014, 02:26:04 am »
Exellent

32
Graphics / Thread causes a crash in SFML/wxWidgets app *solved*
« on: January 05, 2014, 01:52:43 am »
Hi

I'm making an application using SFML 2.0 and wxWidgets together. A level editor that opens a new window when the level is to be tested. Causing a crash why I'm unsure.

Main.cpp  - -  http://pastebin.com/WHJuCM13
application.cpp  - - http://pastebin.com/GtEwB2ji
application.h  - - http://pastebin.com/TAyBFfGg

Help much appreciated

33
General discussions / Re: SFML Game Jam Theme Announcement!
« on: August 02, 2013, 04:07:39 pm »
Exellent,  I'll have a go at this :)

34
Graphics / pushGLStates/popGLStates? (Fixed)
« on: May 05, 2013, 11:06:07 pm »
EDIT: Nevermind it was culling that caused this ._.

Hi...

I need a bit of help figuring out how to use the graphics module with OpenGL.

My attempt:

#include "application.h"


Application::Application(Configuration c) :
    vmode(c.width, c.height, c.depth),
    win(vmode, c.title, sf::Style::Default, c.gfx),
    fpsTimer(),
    deltaTimer() {

    // INITIALIZE
    win.setVerticalSyncEnabled(true); // call it once, after creating the window
    // OR win.setFramerateLimit(60);  // --||--

    Input::init();

    is_running = true;

    // SETUP

    game = new Game(c.width, c.height);

    //OPENGL

     // Create a sprite for the background


    texture = 0;
    {
        sf::Image image;
        if (!image.loadFromFile("data/gfx/crate.bmp"))
            is_running = false;
        glGenTextures(1, &texture);
        glBindTexture(GL_TEXTURE_2D, texture);
        gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.getSize().x, image.getSize().y, GL_RGBA, GL_UNSIGNED_BYTE, image.getPixelsPtr());
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    }

     // Setup an ortographic projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
   
    glOrtho(0.0, c.width, 0.0, c.height, -1.0, 1.0);
    glViewport(0, 0, c.width, c.height);

    //Culling
    glEnable(GL_CULL_FACE);
    glFrontFace(GL_CCW);
    glCullFace(GL_BACK);

    glColor4f(1.f, 1.f, 1.f, 1.f);

    // MISC

        //ALpha
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    config = c;

}

Application::~Application() {

    // Don't forget to destroy the texture
    glDeleteTextures(1, &texture);

    //oss.str(""); //DO THIS IF DRAWING TEXT

    delete game;
}


void Application::run() {

    while (is_running)
    {

                // E V E N T S
       
        // Handle inp presses or releases
        Input::frame();

        sf::Event event;
        while (win.pollEvent(event))
        {

            Input::sync(event);

            switch(event.type) {
                case sf::Event::Closed:
                    // Window closed
                    is_running = false;
                break;
                case sf::Event::Resized:
                    // adjust the viewport when the window is resized
                    glViewport(0, 0, event.size.width, event.size.height);
                break;
                case sf::Event::KeyReleased:
                    // ESC released
                    if(event.key.code==sf::Keyboard::Escape) is_running = false;
                break;
                default:
                break;

            }
        }

                // L O G I C
               
        double fps = 0;
        double framerate = fpsTimer.getElapsedTime().asSeconds();
        if(framerate>0.0) fps = 1.0/framerate;
        else fps = config.fps;
        fpsTimer.restart();

        game->update(deltaTimer.getElapsedTime().asMilliseconds());

               
                // G F X
               
                // Activate the first window
        win.setActive(true);
               
               
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        game->drawGL(win);
        win.pushGLStates();
        game->drawSFML(win);
        win.popGLStates();
        win.display();

    }

}
 

It draw the OpenGL graphics but seemingly the OpenGL graphics is either the only thing drawn or is drawn after the SFML graphics.

Any hints?

Also it would be nice with a page about it on the wiki .

EDIT: Nevermind it was culling that caused this ._.

35
SFML website / Re: New website
« on: April 29, 2013, 08:17:34 pm »
Bug:
Inheritance diagram for (...) doesn't seem to work. I'm using Chrome version 26.0.1410.64 m on Windows 7

JS Error: "toggleVisibility is not defined "

36
General discussions / Re: SFML 2 and its new website released
« on: April 29, 2013, 08:01:11 pm »
What a wonderful surprise to find the site suddenly refreshing itself ^^ Beautiful job.

...and yay for 2.0 being officially completed!

37
Fixed it.

It was due to sorting not being updated.

38
General / std::sort using class cmp function due to private member? yikes
« on: February 26, 2013, 05:20:36 am »
G'day

This is not directly relevant to SFML by the way but I thought I might receive assistance nevertheless :)

So what I'm trying to do is sort the tiles in my level editor for drawing. For that purpose I use std::sort(). Problem is that it's not working. I pass in a static class function declared like so:

//  Canvas Cell Painter
class Painter {

    private:
       
        ...

    // Place in "grid" that stores Tiles and collision "shapes"
    struct Cell {
        ...
                int    order;         // Drawing order
        ...

        Cell(int ind[], Area* par, sf::Texture* tex) {
            ...
            order = pos[1]-pos[2]; //For draw sorting

            // Add this to parent
            parent = par;
            parent->cells.push_back(this);
                        ...
       }

    }

    ...


    public:

    ...
    static bool cmp_cells(Cell* a, Cell* b);

    ...

};

...and defined like this:

bool Painter::cmp_cells(Painter::Cell* a, Painter::Cell* b) {
    return (a->order<b->order);
}

...and expect it to work when I do:

void Painter::paintbrush(double px, double py, double pz, sf::Texture* texture) {
        ...
        Area* a = new Area(pos, dim);

    // Put a cell in Area
    int zero[3] = { 0,0,0 };
    Cell* c = new Cell(zero, a, texture);

    std::sort(a->cells.begin(), a->cells.end(), Painter::cmp_cells);
        ...

}

But it doesn't =(
Any ideas people?

I'm clueless... thanks for your time anyway

[attachment deleted by admin]

39
General / Undesired texture stretching (wxWidgets+SFML 2.0)
« on: November 05, 2012, 01:37:36 pm »
Hi,

I'm somewhat of a beginner in both wxWidgets and SFML but here goes:

I'm making a level editor and have made a small part of it that scans a directory for tilesets and then shows one of them in a wxWindow. Problem is, whenever I change the tile graphics it gets stretched (see attachment).

The tiles are supposed to be 32x24 pixels. The stretch happen after calling SetClientSize in this function:

void MyPalette::pickTileset(int num) {

    if(num<tileset_max && num>=0) {
        tileset_n = num;

        int w, h;
            w = myTilesets[num].getSize().x;
            h = myTilesets[num].getSize().y;

        cols = (w+width-1)/width;
        rows = (h+height-1)/height;
        cells = cols*rows;

        wxWindow::SetClientSize(wxSize(w, h));

        wxScrolledWindow* par = (wxScrolledWindow*) GetParent();
        //if(par!=0) par->SetScrollbars(1, 1, event.GetSize().x, event.GetSize().y);
    }
}

(initial size is 800x600 which looks fine)

[attachment deleted by admin]

Pages: 1 2 [3]
anything