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

Pages: [1]
1
I have adapted this class from the given tutorials for SFML 1.6 and tried my best to update it for new APIs on both sides.

Code: [Select]
// .h FILE
#pragma once

#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

#include "SFML/Graphics.hpp"

class wxSFMLCanvas : public wxControl, public sf::RenderWindow
{
public:

wxSFMLCanvas(wxWindow* Parent = NULL, wxWindowID Id = -1, const wxPoint& Position = wxDefaultPosition,
const wxSize& Size = wxDefaultSize, long Style = 0);

virtual ~wxSFMLCanvas() {};

void setDrawMode(bool onOrOff);

private:

DECLARE_EVENT_TABLE()

virtual void OnUpdate() {};

void OnIdle(wxIdleEvent&);

void OnEraseBackground(wxEraseEvent&);

wxPaintDC* drawLock;
};

// .cpp FILE
#include "wxSFMLCanvas.h"

// some extras needed for gtk
#ifdef __WXGTK__
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#endif

BEGIN_EVENT_TABLE(wxSFMLCanvas, wxControl)
EVT_IDLE(wxSFMLCanvas::OnIdle)
EVT_ERASE_BACKGROUND(wxSFMLCanvas::OnEraseBackground)
END_EVENT_TABLE()

wxSFMLCanvas::wxSFMLCanvas(wxWindow* Parent, wxWindowID Id, const wxPoint& Position, const wxSize& Size, long Style) :
wxControl(Parent, Id, Position, Size, Style)
{
#ifdef __WXGTK__
GtkWidget* widget = GetHandle();

gtk_widget_realize(widget);
gtk_widget_set_double_buffered(widget, false);

GdkWindow* Win = gtk_widget_get_window( widget );

XFlush(GDK_WINDOW_XDISPLAY(Win));

sf::RenderWindow::create((sf::WindowHandle)GDK_WINDOW_XID(Win));
#else
// Tested under Windows XP only (should work with X11 and other Windows versions - no idea about MacOS)
sf::RenderWindow::create((sf::WindowHandle)GetHandle());
#endif

drawLock = nullptr;
}

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

void wxSFMLCanvas::OnEraseBackground(wxEraseEvent&)
{
}

void wxSFMLCanvas::setDrawMode(bool onOrOff)
{
if (onOrOff && !drawLock) {
drawLock = new wxPaintDC(this);
}
else if (!onOrOff && drawLock) {
delete drawLock;
drawLock = nullptr;
}
}

However, I'm having no luck on Linux. On Windows this works fine but on Linux I get the following in stderr:
Quote
The program 'MAGEditor' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadAccess (attempt to access private resource denied)'.
  (Details: serial 54 error_code 10 request_code 2 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
AL lib: ReleaseALC: 1 device not closed

If you wish to try the class for yourself it is trivial from this point to write a wxApp that uses a frame and reproduce the crash. Normally I would do this for you guys but I'm not too well so I'm going back to bed now /;

Any help would be appreciated.

2
General / Re: Undefined reference errors when compiling the android example
« on: November 09, 2015, 11:31:48 pm »
How did you compile with MSVC? Last time I tried, it didn't get things right when compiling SFML itself, so my best bet would be using "MinGW Makefiles" and compile it with make as well.
Alright, I'll try that.

EDIT: Success! Worked with MinGW_make.

3
General / Undefined reference errors when compiling the android example
« on: November 08, 2015, 11:32:36 pm »
So I compiled the SFML android libs, in visual studio 2015. I'm not sure if this is the way you're supposed to do it, but this way has lead me furthest so far. If it's obviously the wrong way, please tell me how I could have done it differently. Anyway, I then cmake installed it.

When trying to make (via the make file) the example project, I get this output:
Quote
1>------ Build started: Project: Cumulus, Configuration: Debug Tegra-Android ------
1>  [armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
1>  [armeabi-v7a] Gdbserver      : [arm-linux-androideabi-4.8] Tegra-Android/Debug//libs/armeabi-v7a/gdbserver
1>  [armeabi-v7a] Gdbsetup       : Tegra-Android/Debug//libs/armeabi-v7a/gdb.setup
1>  [armeabi-v7a] Install        : libsfml-activity.so => Tegra-Android/Debug//libs/armeabi-v7a/libsfml-activity.so
1>  [armeabi-v7a] Install        : libsfml-system.so => Tegra-Android/Debug//libs/armeabi-v7a/libsfml-system.so
1>  [armeabi-v7a] Install        : libsfml-window.so => Tegra-Android/Debug//libs/armeabi-v7a/libsfml-window.so
1>  [armeabi-v7a] Install        : libsfml-graphics.so => Tegra-Android/Debug//libs/armeabi-v7a/libsfml-graphics.so
1>  [armeabi-v7a] Install        : libsfml-audio.so => Tegra-Android/Debug//libs/armeabi-v7a/libsfml-audio.so
1>  [armeabi-v7a] Install        : libsfml-network.so => Tegra-Android/Debug//libs/armeabi-v7a/libsfml-network.so
1>  [armeabi-v7a] Install        : libc++_shared.so => Tegra-Android/Debug//libs/armeabi-v7a/libc++_shared.so
1>  [armeabi-v7a] Install        : libopenal.so => Tegra-Android/Debug//libs/armeabi-v7a/libopenal.so
1>  [armeabi-v7a] SharedLibrary  : libsfml-example.so
1>D:\Repos\Cumulus\jni\main.cpp(10): error :  error: undefined reference to 'sf::String::String(char const*, std::__1::locale const&)'
1>D:\Repos\Cumulus\jni\main.cpp(13): error :  error: undefined reference to 'sf::Texture::loadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sf::Rect<int> const&)'
1>D:\Repos\Cumulus\jni\main.cpp(21): error :  error: undefined reference to 'sf::Music::openFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
1>  D:/AndroidNDK/sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function ANativeActivity_onCreate: error: undefined reference to 'std::basic_ios<char, std::char_traits<char> >::rdbuf(std::basic_streambuf<char, std::char_traits<char> >*)'
1>  D:/AndroidNDK/sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::locale::~locale()'
1>  D:/AndroidNDK/sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
1>  D:/AndroidNDK/sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
1>  D:/AndroidNDK/sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'vtable for std::basic_streambuf<char, std::char_traits<char> >'
1>  D:/AndroidNDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: the vtable symbol may be undefined because the class is missing its key function
1>  collect2.exe: error: ld returned 1 exit status
1>  make.exe: *** [Tegra-Android/Debug//local/armeabi-v7a/libsfml-example.so] Error 1
I have no idea what most of this means but I assume it's a problem involving the standard libaries.

I've tried recompiling sfml's android bindings with the STL Types "GNU libstdc++ Shared" and "GNU libstdc++ Static". No difference.

I've tried moving things around in Application.mk. This makes errors bigger, not smaller.

I've tried redownloading sfml and starting the whole process again. No difference.

I'm kind of tired of guessing and can't find any tutorials that don't either gloss over the part of the process I'm struggling with or leave out major details entirely. I'm very keen to develop for android with SFML. If anyone could help, it would really be appreciated.

Pages: [1]
anything