1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 20:28:49 -05:00

Renamed glfwGetWindowParam to glfwGetWindowAttrib.

Parameters are something specified at creation time and are often
immutable, while many of the values returned by glfwGetWindowParam
reflected current state not controlled by any parameter or hint.
This commit is contained in:
Camilla Berglund 2013-05-27 15:30:32 +02:00
parent fdd4518ae5
commit ad1f6f0341
11 changed files with 66 additions and 64 deletions

View File

@ -330,6 +330,7 @@ GLFW.
* Renamed header directory `GL` to `GLFW` * Renamed header directory `GL` to `GLFW`
* Renamed `glfw.h` to `glfw3.h` to avoid conflicts with 2.x series * Renamed `glfw.h` to `glfw3.h` to avoid conflicts with 2.x series
* Renamed `glfwOpenWindowHint` to `glfwWindowHint` * Renamed `glfwOpenWindowHint` to `glfwWindowHint`
* Renamed `glfwGetWindowParam` to `glfwGetWindowAttrib`
* Renamed `GLFW_ACTIVE` to `GLFW_FOCUSED` * Renamed `GLFW_ACTIVE` to `GLFW_FOCUSED`
* Renamed `GLFW_FSAA_SAMPLES` to `GLFW_SAMPLES` * Renamed `GLFW_FSAA_SAMPLES` to `GLFW_SAMPLES`
* Renamed `GLFW_WINDOW_NO_RESIZE` to `GLFW_RESIZABLE` * Renamed `GLFW_WINDOW_NO_RESIZE` to `GLFW_RESIZABLE`

View File

@ -257,7 +257,8 @@ Unix-like systems, where it uses the
| `glfwSetMousePosCallback` | @ref glfwSetCursorPosCallback | | | `glfwSetMousePosCallback` | @ref glfwSetCursorPosCallback | |
| `glfwSetMouseWheelCallback` | @ref glfwSetScrollCallback | Accepts two-dimensional scroll offsets as doubles | | `glfwSetMouseWheelCallback` | @ref glfwSetScrollCallback | Accepts two-dimensional scroll offsets as doubles |
| `glfwGetJoystickPos` | @ref glfwGetJoystickAxes | | | `glfwGetJoystickPos` | @ref glfwGetJoystickAxes | |
| `glfwGetGLVersion` | @ref glfwGetWindowParam | Use `GLFW_OPENGL_VERSION_MAJOR`, `GLFW_OPENGL_VERSION_MINOR` and `GLFW_OPENGL_REVISION` | | `glfwGetWindowParam` | @ref glfwGetWindowAttrib | |
| `glfwGetGLVersion` | @ref glfwGetWindowAttrib | Use `GLFW_OPENGL_VERSION_MAJOR`, `GLFW_OPENGL_VERSION_MINOR` and `GLFW_OPENGL_REVISION` |
| `glfwGetDesktopMode` | @ref glfwGetVideoMode | Returns the current mode of a monitor | | `glfwGetDesktopMode` | @ref glfwGetVideoMode | Returns the current mode of a monitor |
@subsection moving_renamed_tokens Tokens @subsection moving_renamed_tokens Tokens

View File

@ -167,7 +167,7 @@ glfwMakeContextCurrent(window);
@endcode @endcode
@section quick_window_params Checking the window close flag @section quick_window_close Checking the window close flag
Each window has a flag indicating whether the window should be closed. This can Each window has a flag indicating whether the window should be closed. This can
be checked with @ref glfwWindowShouldClose. be checked with @ref glfwWindowShouldClose.

View File

@ -25,7 +25,7 @@ glfwInit, can be individually set with @ref glfwWindowHint and reset all at once
to their defaults with @ref glfwDefaultWindowHints. to their defaults with @ref glfwDefaultWindowHints.
Note again that they need to be set *before* the creation of the window you wish Note again that they need to be set *before* the creation of the window you wish
to have the specified properties. to have the specified attributes.
@subsection window_hints_hard Hard and soft constraints @subsection window_hints_hard Hard and soft constraints
@ -34,8 +34,8 @@ Some window hints are hard constraints. These must match the available
capabilities *exactly* for window and context creation to succeed. Hints capabilities *exactly* for window and context creation to succeed. Hints
that are not hard constraints are matched as closely as possible, but the that are not hard constraints are matched as closely as possible, but the
resulting window and context may differ from what these hints requested. To resulting window and context may differ from what these hints requested. To
find out the actual parameters of the created window and context, use the find out the actual attributes of the created window and context, use the
@ref glfwGetWindowParam function. @ref glfwGetWindowAttrib function.
The following hints are hard constraints: The following hints are hard constraints:
- `GLFW_STEREO` - `GLFW_STEREO`

View File

@ -1159,8 +1159,8 @@ GLFWAPI void glfwWindowHint(int target, int hint);
* as not all parameters and hints are * as not all parameters and hints are
* [hard constraints](@ref window_hints_hard). This includes the size of the * [hard constraints](@ref window_hints_hard). This includes the size of the
* window, especially for full screen windows. To retrieve the actual * window, especially for full screen windows. To retrieve the actual
* properties of the window and context, use queries like @ref * attributes of the created window and context, use queries like @ref
* glfwGetWindowParam and @ref glfwGetWindowSize. * glfwGetWindowAttrib and @ref glfwGetWindowSize.
* *
* @param[in] width The desired width, in screen coordinates, of the window. * @param[in] width The desired width, in screen coordinates, of the window.
* This must be greater than zero. * This must be greater than zero.
@ -1435,56 +1435,56 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window);
*/ */
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
/*! @brief Returns a parameter of the specified window. /*! @brief Returns an attribute of the specified window.
* *
* This function returns a property of the specified window. There are many * This function returns an attribute of the specified window. There are many
* different properties, some related to the window and others to its context. * attributes, some related to the window and others to its context.
* *
* @param[in] window The window to query. * @param[in] window The window to query.
* @param[in] param The parameter whose value to return. * @param[in] attrib The attribute whose value to return.
* @return The value of the parameter, or zero if an error occurred. * @return The value of the attribute, or zero if an error occurred.
* *
* @par Window parameters * @par Window attributes
* *
* The `GLFW_FOCUSED` parameter indicates whether the window is focused. * The `GLFW_FOCUSED` attribute indicates whether the window is focused.
* *
* The `GLFW_ICONIFIED` parameter indicates whether the window is iconified. * The `GLFW_ICONIFIED` attribute indicates whether the window is iconified.
* *
* The `GLFW_VISIBLE` parameter indicates whether the window is visible. * The `GLFW_VISIBLE` attribute indicates whether the window is visible.
* *
* The `GLFW_RESIZABLE` parameter indicates whether the window is resizable * The `GLFW_RESIZABLE` attribute indicates whether the window is resizable
* by the user. * by the user.
* *
* The `GLFW_DECORATED` parameter indicates whether the window is decorated. * The `GLFW_DECORATED` attribute indicates whether the window is decorated.
* *
* @par Context parameters * @par Context attributes
* *
* The `GLFW_CLIENT_API` parameter indicates the client API provided by the * The `GLFW_CLIENT_API` attribute indicates the client API provided by the
* window's context; either `GLFW_OPENGL_API` or `GLFW_OPENGL_ES_API`. * window's context; either `GLFW_OPENGL_API` or `GLFW_OPENGL_ES_API`.
* *
* The `GLFW_CONTEXT_VERSION_MAJOR`, `GLFW_CONTEXT_VERSION_MINOR` and * The `GLFW_CONTEXT_VERSION_MAJOR`, `GLFW_CONTEXT_VERSION_MINOR` and
* `GLFW_CONTEXT_REVISION` parameters indicate the client API version of the * `GLFW_CONTEXT_REVISION` attributes indicate the client API version of the
* window's context. * window's context.
* *
* The `GLFW_OPENGL_FORWARD_COMPAT` parameter is `GL_TRUE` if the window's * The `GLFW_OPENGL_FORWARD_COMPAT` attribute is `GL_TRUE` if the window's
* context is an OpenGL forward-compatible one, or `GL_FALSE` otherwise. * context is an OpenGL forward-compatible one, or `GL_FALSE` otherwise.
* *
* The `GLFW_OPENGL_DEBUG_CONTEXT` parameter is `GL_TRUE` if the window's * The `GLFW_OPENGL_DEBUG_CONTEXT` attribute is `GL_TRUE` if the window's
* context is an OpenGL debug context, or `GL_FALSE` otherwise. * context is an OpenGL debug context, or `GL_FALSE` otherwise.
* *
* The `GLFW_OPENGL_PROFILE` parameter indicates the OpenGL profile used by the * The `GLFW_OPENGL_PROFILE` attribute indicates the OpenGL profile used by the
* context. This is `GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE` * context. This is `GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE`
* if the context uses a known profile, or `GLFW_OPENGL_NO_PROFILE` if the * if the context uses a known profile, or `GLFW_OPENGL_NO_PROFILE` if the
* OpenGL profile is unknown or the context is for another client API. * OpenGL profile is unknown or the context is for another client API.
* *
* The `GLFW_CONTEXT_ROBUSTNESS` parameter indicates the robustness strategy * The `GLFW_CONTEXT_ROBUSTNESS` attribute indicates the robustness strategy
* used by the context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or * used by the context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or
* `GLFW_NO_RESET_NOTIFICATION` if the window's context supports robustness, or * `GLFW_NO_RESET_NOTIFICATION` if the window's context supports robustness, or
* `GLFW_NO_ROBUSTNESS` otherwise. * `GLFW_NO_ROBUSTNESS` otherwise.
* *
* @ingroup window * @ingroup window
*/ */
GLFWAPI int glfwGetWindowParam(GLFWwindow* window, int param); GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
/*! @brief Sets the user pointer of the specified window. /*! @brief Sets the user pointer of the specified window.
* *

View File

@ -361,7 +361,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
return closest; return closest;
} }
GLboolean _glfwRefreshContextParams(void) GLboolean _glfwRefreshContextAttribs(void)
{ {
_GLFWwindow* window = _glfwPlatformGetCurrentContext(); _GLFWwindow* window = _glfwPlatformGetCurrentContext();

View File

@ -690,15 +690,15 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
const _GLFWfbconfig* alternatives, const _GLFWfbconfig* alternatives,
unsigned int count); unsigned int count);
/*! @brief Checks and reads back properties from the current context. /*! @brief Retrieves the attributes of the current context.
* @return `GL_TRUE` if successful, or `GL_FALSE` if the context is unusable. * @return `GL_TRUE` if successful, or `GL_FALSE` if the context is unusable.
* @ingroup utility * @ingroup utility
*/ */
GLboolean _glfwRefreshContextParams(void); GLboolean _glfwRefreshContextAttribs(void);
/*! @brief Checks whether the desired context properties are valid. /*! @brief Checks whether the desired context attributes are valid.
* @param[in] wndconfig The context properties to check. * @param[in] wndconfig The context attributes to check.
* @return `GL_TRUE` if the context properties are valid, or `GL_FALSE` * @return `GL_TRUE` if the context attributes are valid, or `GL_FALSE`
* otherwise. * otherwise.
* @ingroup utility * @ingroup utility
* *
@ -710,7 +710,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig);
/*! @brief Checks whether the current context fulfils the specified hard /*! @brief Checks whether the current context fulfils the specified hard
* constraints. * constraints.
* @param[in] wndconfig The desired context properties. * @param[in] wndconfig The desired context attributes.
* @return `GL_TRUE` if the context fulfils the hard constraints, or `GL_FALSE` * @return `GL_TRUE` if the context fulfils the hard constraints, or `GL_FALSE`
* otherwise. * otherwise.
* @ingroup utility * @ingroup utility

View File

@ -226,8 +226,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
glfwMakeContextCurrent((GLFWwindow*) window); glfwMakeContextCurrent((GLFWwindow*) window);
// Cache the actual (as opposed to requested) context parameters // Retrieve the actual (as opposed to requested) context attributes
if (!_glfwRefreshContextParams()) if (!_glfwRefreshContextAttribs())
{ {
glfwDestroyWindow((GLFWwindow*) window); glfwDestroyWindow((GLFWwindow*) window);
glfwMakeContextCurrent((GLFWwindow*) previous); glfwMakeContextCurrent((GLFWwindow*) previous);
@ -521,13 +521,13 @@ GLFWAPI void glfwHideWindow(GLFWwindow* handle)
_glfwPlatformHideWindow(window); _glfwPlatformHideWindow(window);
} }
GLFWAPI int glfwGetWindowParam(GLFWwindow* handle, int param) GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(0); _GLFW_REQUIRE_INIT_OR_RETURN(0);
switch (param) switch (attrib)
{ {
case GLFW_FOCUSED: case GLFW_FOCUSED:
return window == _glfw.focusedWindow; return window == _glfw.focusedWindow;

View File

@ -23,8 +23,8 @@
// //
//======================================================================== //========================================================================
// //
// This test creates a windowed mode window with all parameters set to // This test creates a windowed mode window with all window hints set to
// default values and then reports the actual parameters of the created // default values and then reports the actual attributes of the created
// window and context // window and context
// //
//======================================================================== //========================================================================
@ -37,18 +37,18 @@
typedef struct typedef struct
{ {
int param; int attrib;
const char* ext; const char* ext;
const char* name; const char* name;
} ParamGL; } AttribGL;
typedef struct typedef struct
{ {
int param; int attrib;
const char* name; const char* name;
} ParamGLFW; } AttribGLFW;
static ParamGL gl_params[] = static AttribGL gl_attribs[] =
{ {
{ GL_RED_BITS, NULL, "red bits" }, { GL_RED_BITS, NULL, "red bits" },
{ GL_GREEN_BITS, NULL, "green bits" }, { GL_GREEN_BITS, NULL, "green bits" },
@ -61,7 +61,7 @@ static ParamGL gl_params[] =
{ 0, NULL, NULL } { 0, NULL, NULL }
}; };
static ParamGLFW glfw_params[] = static AttribGLFW glfw_attribs[] =
{ {
{ GLFW_CONTEXT_VERSION_MAJOR, "Context version major" }, { GLFW_CONTEXT_VERSION_MAJOR, "Context version major" },
{ GLFW_CONTEXT_VERSION_MINOR, "Context version minor" }, { GLFW_CONTEXT_VERSION_MINOR, "Context version minor" },
@ -100,26 +100,26 @@ int main(void)
printf("window size: %ix%i\n", width, height); printf("window size: %ix%i\n", width, height);
for (i = 0; glfw_params[i].name; i++) for (i = 0; glfw_attribs[i].name; i++)
{ {
printf("%s: %i\n", printf("%s: %i\n",
glfw_params[i].name, glfw_attribs[i].name,
glfwGetWindowParam(window, glfw_params[i].param)); glfwGetWindowAttrib(window, glfw_attribs[i].attrib));
} }
for (i = 0; gl_params[i].name; i++) for (i = 0; gl_attribs[i].name; i++)
{ {
GLint value = 0; GLint value = 0;
if (gl_params[i].ext) if (gl_attribs[i].ext)
{ {
if (!glfwExtensionSupported(gl_params[i].ext)) if (!glfwExtensionSupported(gl_attribs[i].ext))
continue; continue;
} }
glGetIntegerv(gl_params[i].param, &value); glGetIntegerv(gl_attribs[i].attrib, &value);
printf("%s: %i\n", gl_params[i].name, value); printf("%s: %i\n", gl_attribs[i].name, value);
} }
glfwDestroyWindow(window); glfwDestroyWindow(window);

View File

@ -293,10 +293,10 @@ int main(int argc, char** argv)
// Report client API version // Report client API version
api = glfwGetWindowParam(window, GLFW_CLIENT_API); api = glfwGetWindowAttrib(window, GLFW_CLIENT_API);
major = glfwGetWindowParam(window, GLFW_CONTEXT_VERSION_MAJOR); major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
minor = glfwGetWindowParam(window, GLFW_CONTEXT_VERSION_MINOR); minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
revision = glfwGetWindowParam(window, GLFW_CONTEXT_REVISION); revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION);
printf("%s context version string: \"%s\"\n", printf("%s context version string: \"%s\"\n",
get_client_api_name(api), get_client_api_name(api),
@ -325,18 +325,18 @@ int main(int argc, char** argv)
printf("%s context flags parsed by GLFW:", get_client_api_name(api)); printf("%s context flags parsed by GLFW:", get_client_api_name(api));
if (glfwGetWindowParam(window, GLFW_OPENGL_FORWARD_COMPAT)) if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT))
printf(" forward-compatible"); printf(" forward-compatible");
if (glfwGetWindowParam(window, GLFW_OPENGL_DEBUG_CONTEXT)) if (glfwGetWindowAttrib(window, GLFW_OPENGL_DEBUG_CONTEXT))
printf(" debug"); printf(" debug");
if (glfwGetWindowParam(window, GLFW_CONTEXT_ROBUSTNESS) != GLFW_NO_ROBUSTNESS) if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) != GLFW_NO_ROBUSTNESS)
printf(" robustness"); printf(" robustness");
putchar('\n'); putchar('\n');
} }
if (major > 3 || (major == 3 && minor >= 2)) if (major > 3 || (major == 3 && minor >= 2))
{ {
int profile = glfwGetWindowParam(window, GLFW_OPENGL_PROFILE); int profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE);
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
printf("%s profile mask (0x%08x): %s\n", printf("%s profile mask (0x%08x): %s\n",
@ -360,7 +360,7 @@ int main(int argc, char** argv)
strategy, strategy,
get_strategy_name_gl(strategy)); get_strategy_name_gl(strategy));
robustness = glfwGetWindowParam(window, GLFW_CONTEXT_ROBUSTNESS); robustness = glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS);
printf("%s robustness strategy parsed by GLFW: %s\n", printf("%s robustness strategy parsed by GLFW: %s\n",
get_client_api_name(api), get_client_api_name(api),

View File

@ -143,8 +143,8 @@ int main(int argc, char** argv)
glfwSetWindowIconifyCallback(window, window_iconify_callback); glfwSetWindowIconifyCallback(window, window_iconify_callback);
printf("Window is %s and %s\n", printf("Window is %s and %s\n",
glfwGetWindowParam(window, GLFW_ICONIFIED) ? "iconified" : "restored", glfwGetWindowAttrib(window, GLFW_ICONIFIED) ? "iconified" : "restored",
glfwGetWindowParam(window, GLFW_FOCUSED) ? "focused" : "defocused"); glfwGetWindowAttrib(window, GLFW_FOCUSED) ? "focused" : "defocused");
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);