Added glfwGetCurrentWindow.

This commit is contained in:
Camilla Berglund 2010-10-04 23:13:33 +02:00
parent f73f01b68c
commit 419f9f17a1
4 changed files with 23 additions and 0 deletions

View File

@ -417,6 +417,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode, const char* t
GLFWAPI void glfwOpenWindowHint(int target, int hint);
GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window);
GLFWAPI int glfwIsWindow(GLFWwindow window);
GLFWAPI GLFWwindow glfwGetCurrentWindow(void);
GLFWAPI void glfwCloseWindow(GLFWwindow window);
GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title);
GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height);

View File

@ -270,6 +270,7 @@ version of GLFW.</p>
<li>Added <code>glfwGetWindowPos</code> function for querying the position of the specified window</li>
<li>Added <code>glfwSetWindowFocusCallback</code> function and <code>GLFWwindowfocusfun</code> type for receiving window focus events</li>
<li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li>
<li>Added <code>glfwGetCurrentWindow</code> function for retrieving the window whose OpenGL context is current</li>
<li>Added <code>windows</code> simple multi-window test program</li>
<li>Added <code>sharing</code> simple OpenGL object sharing test program</li>
<li>Added a parameter to <code>glfwOpenWindow</code> for specifying a context the new window's context will share objects with</li>

View File

@ -639,6 +639,22 @@ GLFWAPI int glfwIsWindow(GLFWwindow window)
}
//========================================================================
// Returns GL_TRUE if the specified window handle is an actual window
//========================================================================
GLFWAPI GLFWwindow glfwGetCurrentWindow(void)
{
if (!_glfwInitialized)
{
_glfwSetError(GLFW_NOT_INITIALIZED);
return GL_FALSE;
}
return _glfwLibrary.currentWindow;
}
//========================================================================
// Set hints for opening the window
//========================================================================

View File

@ -72,6 +72,11 @@ static GLuint create_texture(void)
static void draw_quad(GLuint texture)
{
int width, height;
glfwGetWindowSize(glfwGetCurrentWindow(), &width, &height);
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.f, 1.f, 0.f, 1.f);