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

Pages: 1 ... 3 4 [5]
61
Window / mouse coord out until resize by any amount
« on: June 27, 2008, 05:55:53 am »
Yeap you're right, it shouldn't =p

e.g. i use 1280x1024, with getDesktopMode VideoMode is at 1280x1024, and Rect from AdjustRect is at 1288x1058 (window area) but the final window size (include border and title) is 1288x1036. That's why your final client area is shrinked (requested : 1280x1024 real : 1280x1002).

Some tests with differents window size :

Code: [Select]
   // Create the window
    if (HasUnicodeSupport())
    {
        wchar_t WTitle[256];
        int NbChars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, Title.c_str(), static_cast<int>(Title.size()), WTitle, sizeof(WTitle) / sizeof(*WTitle));
        WTitle[NbChars] = L'\0';
        myHandle = CreateWindowW(ourClassNameW, WTitle, Win32Style, Left, Top, Width, Height, NULL, NULL, GetModuleHandle(NULL), this);
    }
    else
    {
        myHandle = CreateWindowA(ourClassNameA, Title.c_str(), Win32Style, Left, Top, Width, Height, NULL, NULL, GetModuleHandle(NULL), this);
    }

    {
        if (!Fullscreen)
        {
            RECT clientRect , windowRect = {0, 0, 0, 0};
            GetClientRect(myHandle, &clientRect);
            GetWindowRect(myHandle, &windowRect);
            myWidth = clientRect.right - clientRect.left;
            myHeight = clientRect.bottom - clientRect.top;
            int realWidth = windowRect.right - windowRect.left;
            int realHeight = windowRect.bottom - windowRect.top;
            std::cout << "Requested client : " << Mode.Width << "x" << Mode.Height << " Real client : " << myWidth << "x" << myHeight << std::endl;
            std::cout << "Requested window : " << Width << "x" << Height << " Real client : " << realWidth << "x" << realHeight << std::endl;

        }
    }


800x600 (OK) :
Quote
Requested client : 800x600 Real client : 800x600
Requested window : 808x634 Real client : 808x634


1024x768 (OK) :
Quote
Requested client : 1024x768 Real client : 1024x768
Requested window : 1032x802 Real client : 1032x802


1280x1024 (desktop resolution) :
Quote
Requested client : 1280x1024 Real client : 1280x1002
Requested window : 1288x1058 Real client : 1288x1036


1280x1024 (with sfNone instead of sfResize | sfClose)
Quote
Requested client : 1280x1024 Real client : 1280x1024
Requested window : 1280x1024 Real client : 1280x1024

I don't know why CreateWindow reduce your window size (maybe there is a maximum window size ?) but it does. =)

62
Window / mouse coord out until resize by any amount
« on: June 27, 2008, 04:18:23 am »
Hi,

I think i found the problem.

When SFML trying to create a window with a client area egal to screen resolution (or highest), then, resulting client area is smallest than the requested VideoMode (maybe title bar size). ATM, SFML width and height are initialized before any window creation, and not updated after that :

Code: [Select]
// LoC 145 (WindowImplWin32.cpp)
    int Width  = myWidth  = Mode.Width;
    int Height = myHeight = Mode.Height;


If the client area of the windows is smaller than the requested video mode (if you pass GetDesktopMode(), it will be) window GetHeigth and GetWidth will be false until a WM_SIZE notif (which will call GetClientRect).

This could be fix with a GetClientRect call after the window creation :

Code: [Select]
LoC 171 WindowImplWin32.cpp
    // Create the window
    if (HasUnicodeSupport())
    {
        wchar_t WTitle[256];
        int NbChars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, Title.c_str(), static_cast<int>(Title.size()), WTitle, sizeof(WTitle) / sizeof(*WTitle));
        WTitle[NbChars] = L'\0';
        myHandle = CreateWindowW(ourClassNameW, WTitle, Win32Style, Left, Top, Width, Height, NULL, NULL, GetModuleHandle(NULL), this);
    }
    else
    {
        myHandle = CreateWindowA(ourClassNameA, Title.c_str(), Win32Style, Left, Top, Width, Height, NULL, NULL, GetModuleHandle(NULL), this);
    }

// ==== NEW ====
    if (!Fullscreen)
    {
        RECT clientRect = {0, 0, 0, 0};
        if (!GetClientRect(myHandle, &clientRect))
        {
            // ...
        }
        myWidth = clientRect.right - clientRect.left;
        myHeight = clientRect.bottom - clientRect.top;
    }
// ==== /NEW ====


I don't know how openGL context creation is influenced by this modification, but the OP code works perfectly with it (in all resolution, fulscreen etc).

63
Window / [Solved] undefined reference to `_gluPerspective@32'
« on: June 26, 2008, 08:52:32 pm »
Hi,

if you want to use opengl or glu functions, you must link with Opengl and Glu library (opengl32 and glu32 with mingw). =)

64
General / New SVN Version
« on: June 08, 2008, 10:19:56 pm »
Hi,

maybe you could see the done category in roadmap page. For docs, Hiura on the french forum keep an up-to-date doc, here.

65
Feature requests / Support UTF-8 in String? (->GNU/gettext)
« on: June 05, 2008, 08:50:52 pm »
Ok christoph, I understand.

If you have a solution, maybe you could create an entry in the wiki. =)

66
Feature requests / Support UTF-8 in String? (->GNU/gettext)
« on: June 05, 2008, 07:31:23 pm »
Hi Christoph,

I think that String class already handles unicode text (ctor, wstring GetText(), SetText(wstring)), no ?

67
Feature requests / please make a .net binding for sfml
« on: May 25, 2008, 01:39:43 am »
Few days ago, we have discussed about a .Net binding with Laurent on the French board. Maybe, you could mail him to see if he needs helps (he said he has finished the window package and the graphics is almost done).

BTW, with CSFML, you can recreate the original SFML api except for the SoundStream class (I didn't find yet a easy way to wrap it without reimplementing all openal routine).

68
D / DSFML (a port to the D language)
« on: May 18, 2008, 06:18:41 pm »
Hi,

just to give some updates,

DSFML is now hosted on the SFML svn (cf. wiki if you don't know how to checkout). It will be released with the the upcoming 1.3 sfml. I suggest you to use DSSS and rebuild. To build lib  dsss build in import folder to build the lib, dsss build in samples/dsfml folder for the samples. If you want to compile your own project, just add -I[path of DSFML import] in your dss.conf (or rebuild command line).

If you use it on windows just build SFML (release static) and CSFML (release dll) and place it into the clib/win32 folder of DSFML, but don't overwrite actual .lib (dmd cannot link against visual import lib). For linux-users, just build and install SFML and CSFML. To compile your project, add -S[path of clib/win32]. And place csfml dll in your exe folder.

the documentation isn't on the svn (but will be in the release =) ), if you need it go into the import folder and dsss build -version=Ddoc and you could find multiple html files in doc folder.

Very quick start :

Code: [Select]

module veryquickstart;

import dsfml.system.all;
import dsfml.window.all;
import dsfml.graphics.all;

void main()
{
    RenderWindow app = new RenderWindow(VideoMode(800, 600, 32), "It works !");
    Shape s = Shape.circle(300.f, 300.f, 100.f, Color(120, 120, 120, 120));
    app.setFramerateLimit(100);
   
    Event evt;  
    while (app.isOpened())
    {
        while (app.getEvent(evt))
        {
            // close the window
            if ((evt.Type == Event.EventType.CLOSED) ||
               ((evt.Type == Event.EventType.KEYPRESSED) && (evt.Key.Code == KeyCode.ESCAPE)))
            {
                app.close();
                break;
            }        
        }

        s.move(0.1f, 0);
       
        app.draw(s);
        app.display();
    }
   
}


Currently, i'm "tracking" last remaining bugs, but lib must be usable. =)

69
SFML projects / Ovid the Owl - Freeware Game
« on: May 16, 2008, 01:16:37 pm »
Hi lzr,

very nice work, i definitely love it especially Music and Sound ambiance. =)

70
Feature requests / Some ideas
« on: May 13, 2008, 01:59:08 pm »
Hi,

for the scaling stuffs, SetScale is an assign method (Doesn't matter how many times you call SetScale, the final scale wiil the last call), Scale (float, float) keep multiply the actual scale by the factor. Example :

Code: [Select]
   
    sf::Image Image;
    if (!Image.LoadFromFile("randomImage.bmp"))
        return EXIT_FAILURE;

    sf::Sprite Sprite(Image);

    for(int i = 0; i < 3; i++)
        Sprite.SetScale(1.1f, 1.1f);
    // final scaling factor is 1.1, 1.1

    //..

    for(int i = 0; i < 3; i++)
        Sprite.Scale(1.1f, 1.1f);
    // final scaling factor is 1.331, 1.331



The same logic apply to Move/SetPosition and Rotate/SetRotation.

For overlapping sprite, you could do it with a simple Sprite encapsulation and some Rect<T>.Intersects call.

71
Feature requests / sf::Clock Improvement
« on: May 03, 2008, 02:06:27 am »
Hi Nexus,

as you said, sf::Clock is a ... Clock. =p

You don't have to pause a clock, just ask it elpased time. (maybe a stopwatch, and i'm sure, you could easily do that with an encapsulated Clock).

So, IMO, Clock doesn't need this kind of feat. =)

72
D / DSFML (a port to the D language)
« on: April 22, 2008, 12:19:51 am »
In fact, you're right ... =p

I'm trying to keep the original purpose of SFML (easy and powerful), and i thought that linking import lib would be difficult for people who actually use SFML. But, this doesn't make an huge difference between import or dynamic :

Quote
(import lib version)
dmd [project_files(.d)] [sfml-modules.lib] [import_libray]

(dynamic loading version)
dmd [project_files(.d)] [sfml-modules.lib] -version=Dynamic


and, dynamic loading have no advantages compared to the import linking.

So I keep the dynamic loading (i don't know how linking things are handled by GCC (?) on linux and mac system), but import libs will be the default build.

73
D / DSFML (a port to the D language)
« on: April 20, 2008, 02:52:45 am »
Hi all,

just a little update, binding is almost finished (Currently this is a bind of SFML 1.2. 1.3 modification is not included, I'm waiting Laurent released it, but I already begin to adapt the binding for 1.3).

I did some tests based on Laurent Benchmark SDL (C) / SFML (C++) with Derelict and the SFML D binding. Results are identical of the initial benchmark.

Quote
1/ Test : sprites
Derelict SDL  displayed 8 frames
D SFML displayed 213 frames
--> SFML is 2562% faster than SDL
2/ Test : alpha-blended sprites
Derelict SDL  displayed 5 frames
D SFML displayed 150 frames
--> SFML is 2900% faster than SDL
3/ Test : static text
Derelict SDL  displayed 795 frames
D SFML displayed 5983 frames
--> SFML is 652% faster than SDL
4/ Test : dynamic text
Derelict SDL  displayed 616 frames
D SFML displayed 792 frames
--> SFML is 28% faster than SDL


The test with SDL_gfx was not run because Derelict has no official gfx bind and i cannot donwload the other contribution i find.

After some tests, i found the runtime dll loading (with function pointer etc ...) easier to handle, so this is the default build of the binding, you just need to initialize the SFML binding with :

Code: [Select]
import sfml.dsfml; // only one import

void main()
{
    DSFML.init(); //for all modules or ...

    //...

    DSFML.init(GRAPHICS | WINDOW | SYSTEM); // for selective init (only initialized module are loaded)
}


DLL loading is handled by Sharedlib classes of Phobos or Tango (by the way, this binding works on Phobos and Tango). But dynamic loading have some issues, by example, you cannot use unit tests or static constructor because they are run before the main entry point (so before the call to init). That's why, i keep a second build option to generate the library. External function is only external(C) and the lib must be linked with import library of the C SFML dll. With this option, unit test and static constructor doesn't cause problems and the init is not necessary because DLL loading is handled by the OS, but you need to provide OMF import lib to the linker (generated by implib or others).

Actually, only DLL linking of the SFML is supported.

74
D / DSFML (a port to the D language)
« on: April 15, 2008, 11:57:58 pm »
Hi,

for the IDE, ATM, there are no good IDE with good code completion so I keep using PsPad, but IMO the best autocompletion support is Descent (Eclipse based).

For C++ support, even on D2, the ability to interop with C++ is pretty limited. You cannot call non virtual methods (non virtual is implicit on C++), don"t have access to fields (only via Get Set methods) => here. So, for the moment, i don't want to use D2.

For the namespace, it's an internal probleme of D (which hasn't), but we can use selective renamed import to avoid collision :

Code: [Select]
import sfml.graphics.string : SfString = String;

We can use static import too, but no C++ ns with using etc ...

For the licence, I said I have only tested Derelict way, but in fact, i didn't use it at all and don't need it because tango and phobos now have their own dll loader (std.loader or tango.system.SharedLib) if i need to use dynamic loading later. I must see that with the prior project developper, but for me, i want to keep the original licence of SFML (aka zlib/libpng), I don't like LGPL or GPL stuff.

75
D / DSFML (a port to the D language)
« on: April 15, 2008, 06:11:07 pm »
Hi all,

i'm the person who's currently working on the D binding for SFML. The objective of this binding, is to preserve the SFML api but, C++ -> D is only possible on the D2 compiler, and D2 is, ATM, at experimental stage (and constantly changed ... you said "transitive const" =p). So, given the fact that D already has a C interface, i think it's the best option to bind through the C SFML interface instead of the C++ one. C use in D is easy and lot of other lib use it, the C++ way is too limited (maybe when D2 switch to stable release).

For the technics, at the beginning, i've used the Derelict way (aka dynamically load .dll or .so and instanciate function pointer) i.e. (from the DerelictSDL trunk) :

 
Code: [Select]
extern(C)
{
    typedef int function(Uint32) pfSDL_Init;
    typedef int function(Uint32) pfSDL_InitSubSystem;
    typedef int function(Uint32) pfSDL_QuitSubSystem;
    typedef int function(Uint32) pfSDL_WasInit;
    typedef void function() pfSDL_Quit;
    pfSDL_Init    SDL_Init;
    pfSDL_InitSubSystem  SDL_InitSubSystem;
    pfSDL_QuitSubSystem  SDL_QuitSubSystem;
    pfSDL_WasInit   SDL_WasInit;
    pfSDL_Quit    SDL_Quit;
}

    bindFunc(SDL_Init)("SDL_Init", lib);
    bindFunc(SDL_InitSubSystem)("SDL_InitSubSystem", lib);
    bindFunc(SDL_QuitSubSystem)("SDL_QuitSubSystem", lib);
    bindFunc(SDL_WasInit)("SDL_WasInit", lib);
    bindFunc(SDL_Quit)("SDL_Quit", lib);
   
GenericLoader DerelictSDL;
static this()
{
    DerelictSDL.setup(
        "sdl.dll",
        "libSDL.so, libSDL.so.0, libSDL-1.2.so, libSDL-1.2.so.0",
        "../Frameworks/SDL.framework/SDL, /Library/Frameworks/SDL.framework/SDL, /System/Library/Frameworks/SDL.framework/SDL",
        &load
    );
}


But i have some problems with this design. After some reading, I understand that OptLink (the Digital Mars D linker for non-D folks =p) can link import lib of DLL but only if they are in OMF format (cl or lib, for visual, generate in COFF format). I tried to regenerate import lib from the C SFML dll in the correct format (with implib, a tool from the DMC utility suite), and it worked ! Now, the D lib looks like (from PostFX external definition) :

Code: [Select]
extern(C)
{
struct sfPostFX {};
   
sfPostFX* sfPostFX_CreateFromFile(char*);
sfPostFX* sfPostFX_CreateFromMemory(char*);
void sfPostFX_Destroy(sfPostFX*);
void sfPostFX_SetParameter1(sfPostFX*, char*, float);
void sfPostFX_SetParameter2(sfPostFX*, char*, float, float);
void sfPostFX_SetParameter3(sfPostFX*, char*, float, float, float);
void sfPostFX_SetParameter4(sfPostFX*, char*, float, float, float, float);
void sfPostFX_SetTexture(sfPostFX*, char*, sfImage*);
bool sfPostFX_CanUsePostFX();
}


No need of function pointers or static loader initialization, just link against the correct import lib. I keep working on the Derelict way because i can only test under Windows system and i don't know if the import lib trick is possible with GDC.

For the current status, all packages are binded, except some system classes (like Thread or Mutex which use the phobos or tangos internal ancapsulated in the SFML api) because thread created outside D are not GC scanned (so the Terminate method become unusable because tango or phobos thread cannot be terminated, this is not a bad news, terminate a thread is not a good practices IMO =) ), and i'm currently testing it. For the openGL headers, i have adaptated headers from the OpenGL Binding project.

As I said to Laurent earlier, the next step is 1) solidify the code (writing some unittest, clean the code, and some optimizing stuffs) 2) finish adapting the documentation from doxygen comments to ddoc one 3) rewrite some samples. I hope i can release a first version (tested for windows) this weekend or early during the next week.

It's screenshot time ! =p (you can't see, but quad move with arrow keys =) ).

The code :

Code: [Select]
module test;

import sfml.window.all;
import sfml.system.all;
import sfml.graphics.all;

import sfml.GL.gl;
import sfml.GL.glu;


GLfloat rx = 0.f;
GLfloat ry = 0.f;
GLfloat xspeed = 0.f;
GLfloat yspeed = 0.f;

Input i;

void main()
{
    RenderWindow w = new RenderWindow(VideoMode(1024, 768, 32), "Test");
    i = w.GetInput();
   
    String hello = new String("Duke, say hello to D folks !"w, "comic.ttf", 30.f);
    hello.SetColor(Color.White);
    hello.SetPosition(50.f, 50.f);
   
    Image img = new Image();
    if (!img.LoadFromFile("DukeNukem-3d.tga"))
        assert(0, "Error");
    img.CreateMaskFromColor(Color.White);
    Sprite sprite = new Sprite();
    sprite.SetImage(img);
    sprite.SetSubRect(new Rect!(int)(0, 0, 42, 85));
    sprite.SetPosition(hello.GetRect().GetWidth() + hello.GetRect().GetLeft() + 30.f, 50.f);
   
   
    glClearDepth(1.f);
    glClearColor(0.f, 0.f, 0.f, 0.f);
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.f, 1.f, 1.f, 500.f);
   

    bool cont = true;

    while (cont)
    {
        Event evt;
        while (w.GetEvent(evt))
        {
            switch (evt.Type)
            {
                case Event.EventType.Closed :
                    cont = false;
                break;
                case Event.EventType.Resized :
                    glViewport(0, 0, evt.Size.Width, evt.Size.Height);
                break;
                case Event.EventType.KeyPressed :
                    if (evt.Key.Code == KeyCode.Escape)
                        cont = false;
                    HandleKey(i);
                break;
                default :
                break;
            }
        }
       
        w.SetCurrent();
         
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
       
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.f, 0.f, -200.f);
        glRotatef(rx, 1.f, 0.f, 0.f);
        glRotatef(ry, 0.f, 1.f, 0.f);
       
        glBegin(GL_QUADS);
           
            glColor3f(0.f, 1.f, 0.f);
            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f( 50.f,  50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);
           
            glColor3f(0.f, 1.f, 1.f);
            glVertex3f(-50.f, -50.f, 50.f);
            glVertex3f(-50.f,  50.f, 50.f);
            glVertex3f( 50.f,  50.f, 50.f);
            glVertex3f( 50.f, -50.f, 50.f);
           
            glColor3f(1.f, 1.f, 0.f);
            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f(-50.f,  50.f,  50.f);
            glVertex3f(-50.f, -50.f,  50.f);

            glColor3f(0.f, 0.5f, 0.f);
            glVertex3f(50.f, -50.f, -50.f);
            glVertex3f(50.f,  50.f, -50.f);
            glVertex3f(50.f,  50.f,  50.f);
            glVertex3f(50.f, -50.f,  50.f);
           
            glColor3f(1.f, 0.f, 0.f);
            glVertex3f(-50.f, -50.f,  50.f);
            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f,  50.f);
           
            glColor3f(0.f, 0.f, 1.f);
            glVertex3f(-50.f, 50.f,  50.f);
            glVertex3f(-50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f,  50.f);

        glEnd();
       
        w.Draw(hello);
        w.Draw(sprite);
       
        rx += xspeed;
        ry += yspeed;
       
        w.Display();
    }
}

void HandleKey(Input i)
{
    if (i.IsKeyDown(KeyCode.Up))
    {
        xspeed -= 0.1f;
    }
    if (i.IsKeyDown(KeyCode.Down))
    {
        xspeed += 0.1f;
    }
    if (i.IsKeyDown(KeyCode.Left))
    {
        yspeed -= 0.1f;
    }
    if (i.IsKeyDown(KeyCode.Right))
    {
        yspeed += 0.1f;
    }
}


generated with :

Code: [Select]
dmd program.d program.def libd/sfmlsystem.lib libd/sfmlwindow.lib libd/sfmlgraphics.lib lib/dsfml-system.lib lib/dsfml-window.lib lib/dsfml-graphics.lib lib/opengl32d.lib lib/glu32d.lib tango-user-dmd.lib -g -debug -w -v



If you have any question. =)[/code]

Pages: 1 ... 3 4 [5]