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.


Topics - drummerp

Pages: [1]
1
General / Failing to make with MinGW
« on: March 02, 2014, 03:20:35 am »
I don't know if there's a better place to put this question, looks like they got rid of the Compiler and IDE-Related forum. I guess if there's a better place it'll be moved.

I've been finding myself unable to compile SFML 2.0 on Windows using MinGW.  I used the CMake GUI to generate a makefile for MinGW. Since there's no mingw32-make in C:\MinGW\bin, I tried building it using the MSYS make command, both from the command line and the MSYS terminal. When I call it from the Windows command line, I simply see:

C:\Data\Programming\SFML\Win64>make.exe
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Data\Programming\SFML\Win64>

Which I recognize as the line printed at the top of the prompt when I first open it. It's worth noting that the title of the console window becomes "Command Prompt - make.exe", as if the output is from make. If I try it from the MSYS terminal, I see the same printout, plus the terminal is converted to a Window cmd prompt:

User@Redacted /c/Data/Programming/SFML\Win64
$ make
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Data\Programming\SFML\Win64>

I'm using the most recent MinGW build (new laptop, so I just downloading the mingw-get installer), on a Windows 8.1 laptop. I have been able to use make (i.e. the same exact executable in the same ways) to build other projects, so it's not just my installation. I've tried regenerating my makefile, to no avail. I'm not particularly good at reading Makefiles, but it looks like there's nothing wrong with the generation.

Any help would be appreciated. If you need more information, I'd be willing to provide it.

2
Graphics / sf::Image destructor causes SIGABRT crash
« on: October 24, 2013, 07:36:35 pm »
Hello all! I'm trying to create a Skybox object, which when loaded loads a single image file and splits it into 5 or 6 (depending on if there's a bottom image) sf::Image objects, represented as a std::vector<sf::Image>. I then pass the image data (from image.getPixelsPtr() ) to glTexImage2D and call a number of other OpenGL functions to set up my textures for rendering.

My issue comes at the end of my function: when the vector is cleared off the stack, it results in a crash dump to stderr and then a SIGABRT crash. If I run it in my debugger, it becomes apparent it's resulting from in the sf::Image destructor. Here's my code (with some irrelevant portions removed):

bool Skybox::loadSkybox() {
    glGenTextures(6, ids);

    //Loads the image file, then splits into 5-6 images using sf::Image::copy, returning vector of images
    //returns a list of skybox images, in order: Top, Bottom?, Left, Right, Front, Back
    const std::vector<sf::Image> images = Image->getAsSkybox();
    if (images.empty() || images.at(0).getSize().x == 0) //Empty list or empty images is an error with loading
        return false;

    for (unsigned int i = 0; i < images.size(); i++) {

        glBindTexture(GL_TEXTURE_2D, ids[i]);

        GLuint width = images.at(i).getSize().x, height = images.at(i).getSize().y;
        unsigned char* image = const_cast<unsigned char*>(images.at(i).getPixelsPtr());
        if (image == NULL || width <= 0 || height <= 0) {
            std::err << "Error loading image file." << std::endl;
            glDeleteTextures(6, ids);
            return false;
        }

        glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);

        GLenum err;
        if ((err = glGetError()) != GL_NO_ERROR) {
            std::err << "OpenGL error in loading image number " << i << ": " << gluErrorString(err) << std::endl;
            glDeleteTextures(6, ids);
            return false;
        }

        //Call other OpenGL functions to set it up

        free(image); //Clear our temporary image data
    }

    return true;
}

I'm using SFML2,  Code::Blocks for my IDE and GCC 4.6 on a 32-bit on an Ubuntu 12.04 LTS environment.

3
Network / Packets getting changed
« on: August 31, 2012, 06:43:59 am »
I have an application which updates itself through a TCP connection to a server application. This works perfectly fine, except for one specific packet transmission, in which the packet is somehow changed. The server sends a packet containing the number 1:

pack << sf::Uint8(1);
ClientSocket.Send(pack);

(Where `pack` is of type sf::Packet and `ClientSocket` is of type sf::SocketTCP)

Stepping through with my debugger does in fact confirm that these lines are executed, and that the next Receive call in my client is the next few lines:

sock.Receive(pack);
sf::Uint8 conf;
pack >> conf;

(Where `pack` is once again an sf::Packet, and `sock` is a SocketTCP)

However, somehow in my client, conf is showing up as having a value of zero (my debugger confirms this) and it acts as so (the next line switches depending on the value). I am running both applications on the same machine, and they are both reading each other as "127.0.0.1", so the packets (if I understand correctly) aren't going through my router, or really ever leaving my machine. Any ideas on why my packets are being corrupted?

4
Window / OpenGL not rendering
« on: May 31, 2011, 06:31:05 am »
My SFML window, rather than rendering a picture, appears as just a black box. Here's the relevant code:

Code: [Select]
BEGIN_EVENT_TABLE(wxSFMLCanvas, wxControl)
    EVT_IDLE(wxSFMLCanvas::OnIdle)
    EVT_PAINT(wxSFMLCanvas::OnPaint)
    EVT_SIZE(wxSFMLCanvas::OnSize)
    EVT_MOUSE_EVENTS(wxSFMLCanvas::OnClick)
    EVT_ERASE_BACKGROUND(wxSFMLCanvas::OnEraseBackground)
END_EVENT_TABLE()

void wxSFMLCanvas::OnUpdate() {
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glTranslatef(0.0f, 0.0f, 200.0f);

    //Sample model...
    glBegin(GL_QUADS);
        glColor3f(0.1f, 1.0f, 0.1f);

        glVertex3f(100.0f, 0.0f, 100.0f);
        glNormal3f(100.0f, 1.0f, 100.0f);

        glVertex3f(100.0f, 0.0f, -100.0f);
        glNormal3f(100.0f, 1.0f, -100.0f);

        glVertex3f(-100.0f, 0.0f, -100.0f);
        glNormal3f(-100.0f, 1.0f, -100.0f);

        glVertex3f(-100.0f, 0.0f, 100.0f);
        glNormal3f(-100.0f, 1.0f, 100.0f);

        glVertex3f(-100.0f, 100.0f, 100.0f);
        glNormal3f(-100.0f, 101.0f, 100.0f);

        glVertex3f(-100.0f, 100.0f, -100.0f);
        glNormal3f(-100.0f, 101.0f, -100.0f);

        glVertex3f(100.0f, 100.0f, -100.0f);
        glNormal3f(100.0f, 101.0f, -100.0f);

        glVertex3f(100.0f, 100.0f, 100.0f);
        glNormal3f(100.0f, 101.0f, 100.0f);
    glEnd();

    glFlush();
}


void wxSFMLCanvas::OnIdle(wxIdleEvent& event) {
    //Send a paint message when the display is idle, for maximum framerate
    Refresh();
}

void wxSFMLCanvas::OnPaint(wxPaintEvent& event) {
    //Prepare the control to be repainted
    wxPaintDC dc(this);

    //Create the actual image
    OnUpdate();

    //Display the image on-screen
    Display();
}

void wxSFMLCanvas::OnEraseBackground(wxEraseEvent& event){
}

void wxSFMLCanvas::OnClick(wxMouseEvent& event) {
    ((wxFrame*)GetParent())->SetStatusText(wxT("Clicked the edit window."));
}

void wxSFMLCanvas::OnSize(wxSizeEvent& event) {
    if (initialised)
        ChangeSize(event.GetSize().GetWidth(), event.GetSize().GetHeight());
}

void wxSFMLCanvas::Setup() {
    std::cout << "Setting up rendering context." << std::endl;
    std::cout << "OpenGL vendor: " << glGetString(GL_VENDOR) << std::endl;
    std::cout << "OpenGL renderer: " << glGetString(GL_RENDERER) << std::endl;
    std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
    this->PreserveOpenGLStates(true);
    glEnable(GL_MULTISAMPLE);
    glEnable(GL_LIGHTING);
    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
    glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
    GLfloat ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
    this->SetActive(true);
    initialised = true;
}

void wxSFMLCanvas::ChangeSize(GLfloat w, GLfloat h) {
    GLfloat fAspect;

    // Prevent a divide by zero, when window is too short
    // (you cant make a window of zero width).
    if(h == 0)
        h = 1;

    glViewport(0, 0, w, h);

    fAspect = (GLfloat)w / (GLfloat)h;

    // Reset the coordinate system before modifying
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    // Set the clipping volume
    gluPerspective(35.0f, fAspect, 1.0f, 50.0f);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}

wxSFMLCanvas::wxSFMLCanvas(wxWindow* Parent, wxWindowID Id, const wxPoint& Position, const wxSize& Size, long Style) :
wxControl(Parent, Id, Position, Size, Style)
{
    std::cout << "wxSFMLCanvas constructor entered." << std::endl;
    #ifdef __WXGTK__

        // GTK implementation requires to go deeper to find the
        // low-level X11 identifier of the widget
        std::cout << "Realizing wxWidget window." << std::endl;
        gtk_widget_realize(m_wxwindow);
        std::cout << "Removing double-buffering from GTK." << std::endl;
        gtk_widget_set_double_buffered(m_wxwindow, false);
        std::cout << "Getting X11 handle." << std::endl;
        GdkWindow* Win = GTK_PIZZA(m_wxwindow)->bin_window;
        std::cout << "Flushing buffer." << std::endl;
        XFlush(GDK_WINDOW_XDISPLAY(Win));
        std::cout << "Creating RenderWindow." << std::endl;
        sf::RenderWindow::Create(GDK_WINDOW_XWINDOW(Win));

    #else

        // Tested under Windows XP only (should work with X11
        // and other Windows versions - no idea about MacOS)
        sf::RenderWindow::Create(GetHandle());

    #endif
    Setup();
}

wxSFMLCanvas::~wxSFMLCanvas() {
}


In theory, this should be drawing a green box in the centre of the screen, yes? But it's not working... If anyone could provide any help, I'd really appreciate it. If there's any more information you need, I'd be glad to supply.

5
Window / wxWidgets sample segfault
« on: March 18, 2011, 04:53:31 am »
I am currently designing a program which uses the wxWidgets windowing library. I have a need for a 3D renderer in my program, and so I decided to use SFML for this as I had had prior experience with SFML and found it very useful and simple. I found the tutorial on integration with wxWidgets, and, erm...based my code off of it, shall we say? I have changed it and made it significantly different. However, it is still a class called wxSFMLCanvas, and the constructor is the same (aside from the debug calls to cout and the call to my function Setup() at the end):

Code: [Select]
wxSFMLCanvas::wxSFMLCanvas(wxWindow* Parent, wxWindowID Id, const wxPoint& Position, const wxSize& Size, long Style) :
wxControl(Parent, Id, Position, Size, Style)
{
    std::cout << "wxSFMLCanvas constructor entered." << std::endl;
    #ifdef __WXGTK__

        // GTK implementation requires to go deeper to find the
        // low-level X11 identifier of the widget
        std::cout << "Realizing wxWidget window." << std::endl;
        gtk_widget_realize(m_wxwindow);
        std::cout << "Removing double-buffering from GTK." << std::endl;
        gtk_widget_set_double_buffered(m_wxwindow, false);
        std::cout << "Getting X11 handle." << std::endl;
        GdkWindow* Win = GTK_PIZZA(m_wxwindow)->bin_window;
        std::cout << "Flushing buffer." << std::endl;
        XFlush(GDK_WINDOW_XDISPLAY(Win));
        std::cout << "Creating RenderWindow." << std::endl;
        sf::RenderWindow::Create(GDK_WINDOW_XWINDOW(Win));
        std::cout << "Created RenderWindow from X11 widget." << std::endl;

    #else

        // Tested under Windows XP only (should work with X11
        // and other Windows versions - no idea about MacOS)
        sf::RenderWindow::Create(GetHandle());
        std::cout << "Created RenderWindow from handle." << std::endl;

    #endif
    Setup();
}


I am currently using wxGTK on a Linux system for this. I added the calls to cout after I discovered this problem. When the constructor is called, "wxSFMLCanvas constructor entered." and "Realizing wxWidget window." are printed, but then I get a segfault on the line gtk_widgets_realize(m_wxwindow); I am not familiar with the GTK+ libraries, or that function at all. I assume it's a problem with my m_wxwindow being a NULL pointer.

If this is something I should rather be asking in the wxWidgets forums than here, please let me know. I'm not really aware of how that code works at all or what it does, and would really appreciate any help that can be given. If anyone has come across this before, or can tell why it would occur from the code, I am willing to try just about anything. I've been working on this project for several months now and would like to see it running.

EDIT: Never mind, I appear to have solved it. It was a problem with my code. gtk_widgets_realize() was, at some point, telling it the size had changed, and so it was calling my OnSize function. The OnSize function has a few OpenGL calls, but since my RenderWindow was never initialise,d, there was no rendering context on which OpenGL could operate, leading to the segfault.

Pages: [1]