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

Pages: [1]
1
Feature requests / Mouse capture/grab
« on: November 26, 2009, 07:37:10 pm »
I thought this would have been discussed before, but didn't find anything. A proper mouse capture/input grab mode would be very helpful. Resetting the cursor to the window center is not only a hack, but also fails if the mouse moves too quickly.

2
Window / Incorrect Key codes
« on: August 02, 2009, 04:54:56 pm »
It seems a couple keycodes are not mapped correctly, because the tilde key (VK_OEM_5) is being mapped to backslash. Although the VK_OEM-keys aren't exactly the same everywhere I think they should at least conform to the corresponding keys with a us layout...

3
Graphics / sf::String and tabs
« on: August 02, 2009, 01:07:45 am »
Just wanted to point out that tabs don't work with sf::String. Looking at the code, you are using 4x the advance of a tab character... but a tab is not a printable character, so probably won't have a valid glyph. Perhaps you should use 4x the advance of a space (which is a printable character, and therefore has a glyph)

4
Graphics / Linker warning (SFML-2.0)
« on: July 31, 2009, 05:32:52 pm »
I'm getting a LIBCMT linker warning when I use the sfml-graphics-s.lib (built from sfml-2.0 svn branch, no modifications). I get the same warning when building the samples that use the graphics lib.

5
Feature requests / Push/Pop GL state
« on: July 30, 2009, 09:59:27 pm »
Currently, one can tell a render target to preserve OpenGL state, but this means the complete render state is pushed/popped for each and every drawable. Most of the time when combining OpenGL rendering and SFML rendering, we have a large section of GL code (3D rendering) and a large section of SFML code (GUI overlays etc). Therefore it would be far more efficient to push GL state once before using SFML and popping it once afterward (instead of for each individual sprite, font etc.).

Currently I solved this by making my own (see below), but adding these to the API might be useful.

Code: [Select]

// taken from RenderTarget::Draw and RenderTarget::SetRenderStates
void _preSFML()
{
glMatrixMode(GL_MODELVIEW); glPushMatrix();
glMatrixMode(GL_PROJECTION); glPushMatrix();
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT   | GL_ENABLE_BIT  |
            GL_TEXTURE_BIT      | GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);

glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
}

void _postSFML()
{
glMatrixMode(GL_PROJECTION); glPopMatrix();
glMatrixMode(GL_MODELVIEW);  glPopMatrix();
glPopAttrib();
}

6
Hey, in case anyone remembers my game "Not quite pong", I had been experimenting with doing the rendering in a separate thread (from input&game logic). Here's a very basic / reduced version of what I did. This is written against the current SFML-2.0 branch (but only 1 or 2 lines have to be changed for SFML-1.5) and boost 1.35. A windows binary (requires VS2008 runtimes) is included.

http://www.carolander.net/joe/threaded_gl.zip

You may notice a few differences in behavior from the standard way of doing it. (Try resizing!)

Please tell me if you notice anything strange. Of course comments and suggestions for improvement are welcome :-)

@Laurent: Should you happen to look in this thread, blocking input would be perfect here, as it would get rid of any and all polling  :wink:

7
SFML wiki / [Sources] Thread-safe Resource Manager
« on: July 29, 2009, 07:51:45 am »
Just wanted to point out my thread-safe resource manager:

http://www.sfml-dev.org/wiki/en/sources/resource_manager_l0calh05t

It also uses boost::shared_ptr to prevent resources which are still in use from being unloaded. An example of a font loader is included.

8
General / Build problem (libsndfile related)
« on: July 27, 2009, 09:35:00 pm »
I decided to try to build the sfml2 branch on my linux vm, but I'm having trouble with the build, because the identifiers

SF_FORMAT_OGG
SF_FORMAT_VORBIS
SF_FORMAT_WVE
SF_FORMAT_MPC2K
SF_FORMAT_RF64

are not declared (in SoundFile.cpp)

libsndfile1-dev is installed, but none of these identifiers appear in sndfile.h

9
Audio / [Solved] SetPosition
« on: July 25, 2008, 10:23:03 am »
How is the coordinate system for Sound.SetPosition set up?

x is obviously left->right
but what about y and z?
is the coordinate system right-handed? is y the back->front (or front->back) axis? etc.

10
SFML projects / Not Quite Pong
« on: July 24, 2008, 05:36:10 pm »
having a little free time this week i decided to write a little pong-like game. except with better "physics". you can add spin to the ball, the paddles have rounded corners etc. for collision detection and most of the physics calculations i use box2d, graphics is immediate mode opengl at the moment. the physics are mostly fake though, since the velocity of the ball is fixed (but increased after each paddle contact) and it has a minimum x-component (so that the ball doesn't get "stuck" somewhere in the middle of the playing field). the game part itself is not quite finished yet (no scoring, and the ball bounces off the ends of the field). but i thought someone might want to try anyways (and tell me if the physics are ok)

controls:
w - player 1 up
s - player 1 down
i - player 2 up
k - player 2 down
r - reset

get source code and binary here:
http://cid-c017d9fd84c56d75.skydrive.live.com/browse.aspx/Public

11
Feature requests / Iconified event or window state
« on: July 23, 2008, 08:31:00 am »
I already asked in an older thread of mine (other topic), but would it be possible to add iconified/uniconfied events, or an IsIconified() function? I'm fairly sure that type of event exist for all supported systems...

12
Feature requests / Separate Window.Display from event polling
« on: February 02, 2008, 12:50:33 am »
Would it be possible to split Window.Display from event polling (and expose polling in the public interface)? This could be done via an auto-poll flag (which should be true by default, as not to break the api).

Furthermore it would be *really* nice if I could unbind the current rendercontext, to rebind it again in a different thread.

The first point would separate rendering&input more, and it would become possible to pause rendering (including unnecessary buffer clearing & swapping) when the window is minimized, without automatically also stopping input from being polled (basically resulting in a crash/unresponsive window)

The second point (combined with the first) would make it possible to separate Rendering into a different Thread which make far more sense than having those in the same thread in a multi threading environment (which is something we honestly can't ignore anymore), because rendering has nothing to do with input handling and this way the events could be polled directly in the thread that actually uses the events (which otherwise would have to be sent to the other thread first, possibly requiring extra synchronization).

I really hope you make this possible, as I really like this library, but also need these features.

For a small win32 example of what I want to do, see below:

Code: [Select]

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <GL/gl.h>

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void EnableOpenGL(HDC hDC, HGLRC hRC);
void DisableOpenGL(HDC hDC, HGLRC hRC);

volatile bool quit = false;
volatile bool paused = false;

struct GlThreadData
{
HDC hDC;
HGLRC hRC;
};

DWORD WINAPI GlThread(LPVOID arg1)
{
GlThreadData d = *reinterpret_cast<GlThreadData*>(arg1);
HDC hDC = d.hDC;
HGLRC hRC = d.hRC;
float theta = 0.0f;

EnableOpenGL( d.hDC, d.hRC );

glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );

while(!quit)
{
glClear( GL_COLOR_BUFFER_BIT );

glPushMatrix();
glScalef(0.9f,0.9f,0.9f);
glRotatef( theta, 0.0f, 0.0f, 1.0f );
glBegin( GL_TRIANGLES );
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f );
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f );
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f );
glEnd();
glPopMatrix();

SwapBuffers( d.hDC );

if(!paused)
theta += 1.0f;
}

DisableOpenGL( d.hDC, d.hRC );

return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  LPSTR lpCmdLine, int iCmdShow)
{
WNDCLASS wc;
HWND hWnd;
MSG msg;

wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = L"MsgPumpThread";
RegisterClass(&wc);

hWnd = CreateWindow(
L"MsgPumpThread", L"Threaded OpenGL / Windows Message Pump",
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
0, 0, 300, 300,
NULL, NULL, hInstance, NULL );

PIXELFORMATDESCRIPTOR pfd;
int format;

HDC hDC = GetDC( hWnd );

ZeroMemory( &pfd, sizeof( pfd ) );
pfd.nSize = sizeof( pfd );
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cAlphaBits = 8;
pfd.cDepthBits = 24;
pfd.cStencilBits = 8;
pfd.iLayerType = PFD_MAIN_PLANE;
format = ChoosePixelFormat( hDC, &pfd );
SetPixelFormat( hDC, format, &pfd );

HGLRC hRC = wglCreateContext( hDC );

GlThreadData gtd = { hDC, hRC };

HANDLE hGlThread;
hGlThread=CreateThread(0,0,&GlThread,&gtd,0,0);

while(!quit)
{
if(!GetMessage(&msg, NULL, 0, 0))
{
quit = true;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

WaitForSingleObject(hGlThread,INFINITE);

wglDeleteContext( hRC );
ReleaseDC( hWnd, hDC );

DestroyWindow( hWnd );

return msg.wParam;

}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

switch (message)
{

case WM_CREATE:
return 0;

case WM_CLOSE:
PostQuitMessage( 0 );
return 0;

case WM_DESTROY:
return 0;

case WM_KEYDOWN:
switch ( wParam )
{
case VK_SPACE:
paused = !paused;
return 0;

case VK_ESCAPE:
PostQuitMessage(0);
return 0;

}
return 0;

default:
return DefWindowProc( hWnd, message, wParam, lParam );
}

}

void EnableOpenGL(HDC hDC, HGLRC hRC)
{
wglMakeCurrent( hDC, hRC );
}

void DisableOpenGL(HDC hDC, HGLRC hRC)
{
wglMakeCurrent( NULL, NULL );
}

Pages: [1]