1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 02:38:52 -05:00

Merge branch 'master' of ssh://glfw.git.sourceforge.net/gitroot/glfw/glfw

This commit is contained in:
Camilla Berglund 2011-04-06 22:00:25 +02:00
commit 7a73105f48
6 changed files with 40 additions and 59 deletions

View File

@ -500,6 +500,7 @@ typedef struct
/* Custom threading model interface */
typedef struct
{
int dummy;
} GLFWthreadmodel;

View File

@ -57,7 +57,7 @@ GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain)
float value = (float) i / ((float) (size - 1));
// Apply gamma
value = pow(value, gamma) * 65535.f + 0.5f;
value = pow(value, 1.f / gamma) * 65535.f + 0.5f;
// Apply gain
value = gain * (value - 32767.5f) + 32767.5f;

View File

@ -41,14 +41,14 @@
GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return GLFW_RELEASE;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
// Is it a valid key?
if (key < 0 || key > GLFW_KEY_LAST)
{
@ -74,14 +74,14 @@ GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return GLFW_RELEASE;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
// Is it a valid mouse button?
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
{
@ -106,14 +106,14 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
// Return mouse position
if (xpos != NULL)
*xpos = window->mousePosX;
@ -130,14 +130,14 @@ GLFWAPI void glfwGetMousePos(GLFWwindow handle, int* xpos, int* ypos)
GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
// Don't do anything if the mouse position did not change
if (xpos == window->mousePosX && ypos == window->mousePosY)
return;
@ -161,14 +161,14 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
if (xoffset)
*xoffset = window->scrollX;

View File

@ -43,27 +43,16 @@ void _glfwInitTimer(void)
{
__int64 freq;
// Check if we have a performance counter
if (QueryPerformanceFrequency((LARGE_INTEGER*) &freq))
{
// Performance counter is available => use it!
_glfwLibrary.Win32.timer.hasPerformanceCounter = GL_TRUE;
// Counter resolution is 1 / counter frequency
_glfwLibrary.Win32.timer.resolution = 1.0 / (double) freq;
// Set start time for timer
QueryPerformanceCounter((LARGE_INTEGER*) &_glfwLibrary.Win32.timer.t0_64);
}
else
{
// No performace counter available => use the tick counter
_glfwLibrary.Win32.timer.hasPerformanceCounter = GL_FALSE;
// Counter resolution is 1 ms
_glfwLibrary.Win32.timer.resolution = 0.001;
// Set start time for timer
_glfwLibrary.Win32.timer.resolution = 0.001; // winmm resolution is 1 ms
_glfwLibrary.Win32.timer.t0_32 = _glfw_timeGetTime();
}
}
@ -90,7 +79,6 @@ double _glfwPlatformGetTime(void)
else
t = (double)(_glfw_timeGetTime() - _glfwLibrary.Win32.timer.t0_32);
// Calculate the current time in seconds
return t * _glfwLibrary.Win32.timer.resolution;
}

View File

@ -86,8 +86,8 @@ static int setMinMaxAnimations(int enable)
//========================================================================
// Focus the window and bring it to the top of the stack
// Due to some nastiness with how Win98/ME/2k/XP handles SetForegroundWindow,
// we have to go through some really bizarre measures to achieve this
// Due to some nastiness with how XP handles SetForegroundWindow we have
// to go through some really bizarre measures to achieve this
//========================================================================
static void setForegroundWindow(HWND hWnd)
@ -200,8 +200,6 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
if (window->WGL.has_WGL_ARB_pixel_format)
{
// Get pixel format attributes through WGL_ARB_pixel_format
// Only consider doublebuffered OpenGL pixel formats for windows
if (!getPixelFormatAttrib(window, i, WGL_SUPPORT_OPENGL_ARB) ||
!getPixelFormatAttrib(window, i, WGL_DRAW_TO_WINDOW_ARB) ||
!getPixelFormatAttrib(window, i, WGL_DOUBLE_BUFFER_ARB))
@ -209,14 +207,12 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
continue;
}
// Only consider RGBA pixel formats
if (getPixelFormatAttrib(window, i, WGL_PIXEL_TYPE_ARB) !=
WGL_TYPE_RGBA_ARB)
{
continue;
}
// Only consider "hardware-accelerated" pixel formats
if (getPixelFormatAttrib(window, i, WGL_ACCELERATION_ARB) ==
WGL_NO_ACCELERATION_ARB)
{
@ -266,7 +262,6 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
if (!_glfw_DescribePixelFormat(window->WGL.DC, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
continue;
// Only consider doublebuffered OpenGL pixel formats for windows
if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
!(pfd.dwFlags & PFD_SUPPORT_OPENGL) ||
!(pfd.dwFlags & PFD_DOUBLEBUFFER))
@ -274,14 +269,12 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
continue;
}
// Only consider "hardware-accelerated" pixel formats
if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&
(pfd.dwFlags & PFD_GENERIC_FORMAT))
{
continue;
}
// Only RGBA pixel formats considered
if (pfd.iPixelType != PFD_TYPE_RGBA)
continue;

View File

@ -365,14 +365,14 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
GLFWAPI void glfwMakeWindowCurrent(GLFWwindow handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
if (_glfwLibrary.currentWindow == window)
return;
@ -388,6 +388,7 @@ GLFWAPI void glfwMakeWindowCurrent(GLFWwindow handle)
GLFWAPI int glfwIsWindow(GLFWwindow handle)
{
_GLFWwindow* entry;
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
@ -395,8 +396,6 @@ GLFWAPI int glfwIsWindow(GLFWwindow handle)
return GL_FALSE;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
if (window == NULL)
return GL_FALSE;
@ -515,14 +514,14 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint)
GLFWAPI void glfwCloseWindow(GLFWwindow handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
// Allow closing of NULL (to match the behavior of free)
if (window == NULL)
return;
@ -561,14 +560,14 @@ GLFWAPI void glfwCloseWindow(GLFWwindow handle)
GLFWAPI void glfwSetWindowTitle(GLFWwindow handle, const char* title)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
_glfwPlatformSetWindowTitle(window, title);
}
@ -579,14 +578,14 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow handle, const char* title)
GLFWAPI void glfwGetWindowSize(GLFWwindow handle, int* width, int* height)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
if (width != NULL)
*width = window->width;
@ -601,14 +600,14 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow handle, int* width, int* height)
GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
if (window->iconified)
{
// TODO: Figure out if this is an error
@ -636,14 +635,14 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height)
GLFWAPI void glfwGetWindowPos(GLFWwindow handle, int* xpos, int* ypos)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
if (xpos != NULL)
*xpos = window->positionX;
@ -658,14 +657,14 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow handle, int* xpos, int* ypos)
GLFWAPI void glfwSetWindowPos(GLFWwindow handle, int xpos, int ypos)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
if (window->mode == GLFW_FULLSCREEN || window->iconified)
{
// TODO: Figure out if this is an error
@ -682,14 +681,14 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow handle, int xpos, int ypos)
GLFWAPI void glfwIconifyWindow(GLFWwindow handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
if (window->iconified)
return;
@ -703,14 +702,14 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow handle)
GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!window->iconified)
return;
@ -728,14 +727,14 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return 0;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
switch (param)
{
case GLFW_ACTIVE:
@ -799,14 +798,14 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow handle, void* pointer)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
window->userPointer = pointer;
}
@ -817,14 +816,14 @@ GLFWAPI void glfwSetWindowUserPointer(GLFWwindow handle, void* pointer)
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return NULL;
}
_GLFWwindow* window = (_GLFWwindow*) handle;
return window->userPointer;
}