Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 Dec 2001
Offline Last Active Feb 10 2015 09:02 PM

Posts I've Made

In Topic: SDL_SetRelativeMouseMode problem

26 January 2015 - 06:08 PM

Have you checked to make sure SDL_SetRelativeMouseMode() isn't returning -1?


It's returning zero

In Topic: SDL_SetRelativeMouseMode problem

26 January 2015 - 06:06 PM

ok, well I solved it but it's jenky. There's got to be a better "built in" way.


First I hide the mouse and call SDL_SetWindowGrab so that the mouse will not move outside of the window.

void LockMouse( bool lock )
	SDL_ShowCursor( (lock)? SDL_DISABLE : SDL_ENABLE );

	SDL_bool b = (lock)? SDL_TRUE: SDL_FALSE;
	SDL_SetWindowGrab( mainWindow, b );

	if ( lock )
		mouseLock[0] = mouseInfo.xCur;
		mouseLock[1] = mouseInfo.yCur;

Then, whenever I receive the mouse movement events I do the following to ignore the movement event caused by calling SDL_WarpMouseInWindow:

int32_t deltaW = mouseInfo.xCur;
deltaW -= mouseInfo.xPrev;
deltaW -= mouseDeltaAccum[0];

int32_t deltaH = mouseInfo.yCur;
deltaH -= mouseInfo.yPrev;
deltaH -= mouseDeltaAccum[1];

HandleMouseMovement( deltaW, deltaH );

//warp back to the position where the mouse is "locked"
//and add that movement into the accumulator so it can be ignored later
SDL_WarpMouseInWindow( mainWindow, mouseLock[0], mouseLock[1] );
mouseDeltaAccum[0] = mouseLock[0] - mouseInfo.xCur;
mouseDeltaAccum[1] = mouseLock[1] - mouseInfo.yCur;

In Topic: SDL_SetRelativeMouseMode problem

26 January 2015 - 05:33 PM

It does seem like expected behavior: https://wiki.libsdl.org/SDL_SetWindowGrab states "When input is grabbed the mouse is confined to the window."



Sorry for the very late reply...


It is expected that it's confined to the window, but SDL_SetWindowGrab is supposed to keep generating mouse movement deltas even when it is confined along the edge of the window. So the user wouldn't see the mouse moving to the right outside of the window but your code would still get a deltaX in a rightwards direction.  Anyway, this is still bogging me down so if you or anyone else has additional ideas, let me know!


I'll post if/when I eventually do find a solution, but as I said it's weird that I'm having problems here. I must be missing something kind of obvious...

In Topic: Basic OpenGL State Machine Questions

13 January 2015 - 06:47 PM

So, then to clarify your answer is what I was wanting to do just not possible specifically the way I was thinking of it?


i.e. Say I have a Vertex Array with two possible sets of vertices stored, respectively, in vboID and vboID_2. Is it not possible to swap between those vertex arrays as inputs to my vertex shader without re-calling glBufferData?


What I was envisioning is something like:

  1. Hey, GPU, here is one set of vertices. Save them in Vertex Buffer 'vboID'
  2. Hey, GPU, here is another set of vertices. Save them in Vertex Buffer 'vboID_2'

Then at runtime, depending on conditional logic just swap which buffer is feeding into my shader here:

layout(location=0) in vec3 in_Position;


In Topic: OpenGL 4 Shadow Map Problem

08 January 2015 - 03:39 PM

ok. Actually after making hte GL_TEXTURE_BUFFER -> GL_TEXTURE_2D change shadow maps are totally working! Woo! The other thing that was going on, for the curious, is that I had the Z-Clip plane on my orthographic transform for the depth-writing pass set WAY to high so I was washing out the signal with much too far a clip plane. Basically losing important resolution on my floating point depth value since I was brute forcing a clip from [0 .. FLT_MAX]. Setting the far clip plane to just beyond my scene makes it all happy.