mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Moved OpenGL-related functions into *opengl files.
This commit is contained in:
parent
74a6c872d6
commit
aae8999ecf
|
@ -20,10 +20,10 @@ set(common_SOURCES
|
||||||
${GLFW_SOURCE_DIR}/src/error.c
|
${GLFW_SOURCE_DIR}/src/error.c
|
||||||
${GLFW_SOURCE_DIR}/src/fullscreen.c
|
${GLFW_SOURCE_DIR}/src/fullscreen.c
|
||||||
${GLFW_SOURCE_DIR}/src/gamma.c
|
${GLFW_SOURCE_DIR}/src/gamma.c
|
||||||
${GLFW_SOURCE_DIR}/src/glext.c
|
|
||||||
${GLFW_SOURCE_DIR}/src/init.c
|
${GLFW_SOURCE_DIR}/src/init.c
|
||||||
${GLFW_SOURCE_DIR}/src/input.c
|
${GLFW_SOURCE_DIR}/src/input.c
|
||||||
${GLFW_SOURCE_DIR}/src/joystick.c
|
${GLFW_SOURCE_DIR}/src/joystick.c
|
||||||
|
${GLFW_SOURCE_DIR}/src/opengl.c
|
||||||
${GLFW_SOURCE_DIR}/src/time.c
|
${GLFW_SOURCE_DIR}/src/time.c
|
||||||
${GLFW_SOURCE_DIR}/src/window.c
|
${GLFW_SOURCE_DIR}/src/window.c
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,9 +10,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
set(cocoa_SOURCES cocoa_enable.m
|
set(cocoa_SOURCES cocoa_enable.m
|
||||||
cocoa_fullscreen.m
|
cocoa_fullscreen.m
|
||||||
cocoa_gamma.m
|
cocoa_gamma.m
|
||||||
cocoa_glext.m
|
|
||||||
cocoa_init.m
|
cocoa_init.m
|
||||||
cocoa_joystick.m
|
cocoa_joystick.m
|
||||||
|
cocoa_opengl.m
|
||||||
cocoa_time.m
|
cocoa_time.m
|
||||||
cocoa_window.m)
|
cocoa_window.m)
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,30 @@
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Swap buffers
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwPlatformSwapBuffers(void)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||||
|
|
||||||
|
// ARP appears to be unnecessary, but this is future-proof
|
||||||
|
[window->NSGL.context flushBuffer];
|
||||||
|
}
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Set double buffering swap interval
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwPlatformSwapInterval(int interval)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||||
|
|
||||||
|
GLint sync = interval;
|
||||||
|
[window->NSGL.context setValues:&sync forParameter:NSOpenGLCPSwapInterval];
|
||||||
|
}
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Check if an OpenGL extension is available at runtime
|
// Check if an OpenGL extension is available at runtime
|
||||||
//========================================================================
|
//========================================================================
|
|
@ -770,30 +770,6 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||||
[window->NS.window deminiaturize:nil];
|
[window->NS.window deminiaturize:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Swap buffers
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformSwapBuffers(void)
|
|
||||||
{
|
|
||||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
|
||||||
|
|
||||||
// ARP appears to be unnecessary, but this is future-proof
|
|
||||||
[window->NSGL.context flushBuffer];
|
|
||||||
}
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Set double buffering swap interval
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformSwapInterval(int interval)
|
|
||||||
{
|
|
||||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
|
||||||
|
|
||||||
GLint sync = interval;
|
|
||||||
[window->NSGL.context setValues:&sync forParameter:NSOpenGLCPSwapInterval];
|
|
||||||
}
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Write back window parameters into GLFW window structure
|
// Write back window parameters into GLFW window structure
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
|
@ -125,6 +125,51 @@ int _glfwStringInExtensionString(const char* string,
|
||||||
////// GLFW public API //////
|
////// GLFW public API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Swap buffers (double-buffering)
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
GLFWAPI void glfwSwapBuffers(void)
|
||||||
|
{
|
||||||
|
if (!_glfwInitialized)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_glfwLibrary.currentWindow)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_NO_CURRENT_WINDOW, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_glfwLibrary.currentWindow)
|
||||||
|
_glfwPlatformSwapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Set double buffering swap interval (0 = vsync off)
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
GLFWAPI void glfwSwapInterval(int interval)
|
||||||
|
{
|
||||||
|
if (!_glfwInitialized)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_glfwLibrary.currentWindow)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_NO_CURRENT_WINDOW, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfwPlatformSwapInterval(interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Check if an OpenGL extension is available at runtime
|
// Check if an OpenGL extension is available at runtime
|
||||||
//========================================================================
|
//========================================================================
|
|
@ -23,9 +23,9 @@ set(libglfw_SOURCES ${common_SOURCES}
|
||||||
win32_enable.c
|
win32_enable.c
|
||||||
win32_fullscreen.c
|
win32_fullscreen.c
|
||||||
win32_gamma.c
|
win32_gamma.c
|
||||||
win32_glext.c
|
|
||||||
win32_init.c
|
win32_init.c
|
||||||
win32_joystick.c
|
win32_joystick.c
|
||||||
|
win32_opengl.c
|
||||||
win32_time.c
|
win32_time.c
|
||||||
win32_window.c
|
win32_window.c
|
||||||
win32_dllmain.c)
|
win32_dllmain.c)
|
||||||
|
|
|
@ -35,6 +35,31 @@
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Swap buffers (double-buffering)
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwPlatformSwapBuffers(void)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||||
|
|
||||||
|
_glfw_SwapBuffers(window->WGL.DC);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Set double buffering swap interval
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwPlatformSwapInterval(int interval)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||||
|
|
||||||
|
if (window->WGL.has_WGL_EXT_swap_control)
|
||||||
|
window->WGL.SwapIntervalEXT(interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Check if the current context supports the specified WGL extension
|
// Check if the current context supports the specified WGL extension
|
||||||
//========================================================================
|
//========================================================================
|
|
@ -1593,31 +1593,6 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Swap buffers (double-buffering)
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformSwapBuffers(void)
|
|
||||||
{
|
|
||||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
|
||||||
|
|
||||||
_glfw_SwapBuffers(window->WGL.DC);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Set double buffering swap interval
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformSwapInterval(int interval)
|
|
||||||
{
|
|
||||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
|
||||||
|
|
||||||
if (window->WGL.has_WGL_EXT_swap_control)
|
|
||||||
window->WGL.SwapIntervalEXT(interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Write back window parameters into GLFW window structure
|
// Write back window parameters into GLFW window structure
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
45
src/window.c
45
src/window.c
|
@ -984,51 +984,6 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Swap buffers (double-buffering)
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
GLFWAPI void glfwSwapBuffers(void)
|
|
||||||
{
|
|
||||||
if (!_glfwInitialized)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_glfwLibrary.currentWindow)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_NO_CURRENT_WINDOW, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_glfwLibrary.currentWindow)
|
|
||||||
_glfwPlatformSwapBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Set double buffering swap interval (0 = vsync off)
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
GLFWAPI void glfwSwapInterval(int interval)
|
|
||||||
{
|
|
||||||
if (!_glfwInitialized)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_glfwLibrary.currentWindow)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_NO_CURRENT_WINDOW, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfwPlatformSwapInterval(interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Get window parameter
|
// Get window parameter
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
|
@ -11,10 +11,10 @@ set(libglfw_SOURCES ${common_SOURCES}
|
||||||
x11_enable.c
|
x11_enable.c
|
||||||
x11_fullscreen.c
|
x11_fullscreen.c
|
||||||
x11_gamma.c
|
x11_gamma.c
|
||||||
x11_glext.c
|
|
||||||
x11_init.c
|
x11_init.c
|
||||||
x11_joystick.c
|
x11_joystick.c
|
||||||
x11_keysym2unicode.c
|
x11_keysym2unicode.c
|
||||||
|
x11_opengl.c
|
||||||
x11_time.c
|
x11_time.c
|
||||||
x11_window.c)
|
x11_window.c)
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,36 @@ void (*glXGetProcAddressEXT(const GLubyte* procName))();
|
||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Swap OpenGL buffers
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwPlatformSwapBuffers(void)
|
||||||
|
{
|
||||||
|
glXSwapBuffers(_glfwLibrary.X11.display,
|
||||||
|
_glfwLibrary.currentWindow->X11.handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Set double buffering swap interval
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwPlatformSwapInterval(int interval)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||||
|
|
||||||
|
if (window->GLX.has_GLX_EXT_swap_control)
|
||||||
|
{
|
||||||
|
window->GLX.SwapIntervalEXT(_glfwLibrary.X11.display,
|
||||||
|
window->X11.handle,
|
||||||
|
interval);
|
||||||
|
}
|
||||||
|
else if (window->GLX.has_GLX_SGI_swap_control)
|
||||||
|
window->GLX.SwapIntervalSGI(interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Check if an OpenGL extension is available at runtime
|
// Check if an OpenGL extension is available at runtime
|
||||||
//========================================================================
|
//========================================================================
|
|
@ -1566,36 +1566,6 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Swap OpenGL buffers
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformSwapBuffers(void)
|
|
||||||
{
|
|
||||||
glXSwapBuffers(_glfwLibrary.X11.display,
|
|
||||||
_glfwLibrary.currentWindow->X11.handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Set double buffering swap interval
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformSwapInterval(int interval)
|
|
||||||
{
|
|
||||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
|
||||||
|
|
||||||
if (window->GLX.has_GLX_EXT_swap_control)
|
|
||||||
{
|
|
||||||
window->GLX.SwapIntervalEXT(_glfwLibrary.X11.display,
|
|
||||||
window->X11.handle,
|
|
||||||
interval);
|
|
||||||
}
|
|
||||||
else if (window->GLX.has_GLX_SGI_swap_control)
|
|
||||||
window->GLX.SwapIntervalSGI(interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Read back framebuffer parameters from the context
|
// Read back framebuffer parameters from the context
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
Loading…
Reference in New Issue
Block a user