A Working Triangle

Now using GLFW3 instead of the custom window class. This library
looks like it will make development much simpler and will make it
so that I am less worried about my windows code breaking. Currently
setup the http://antongerdelan.net/opengl/hellotriangle.html
tutorial in the MySimpleScene. Will probably create another scene
file to try to get the object oriented stuff working.
This commit is contained in:
elipzer 2018-09-05 16:26:50 -04:00
parent 40617c8953
commit b494f68d0c
30 changed files with 4930 additions and 155 deletions

View File

@ -3,7 +3,7 @@
#include "Exception.h"
Application::Application(const char* class_name, HINSTANCE h_instance)
: m_window(class_name, h_instance), m_input_manager(&m_window.get_input_manager()), m_client_size(1280, 720)
: m_client_size(1280, 720)
{
base_init();
}
@ -11,30 +11,38 @@ Application::Application(const char* class_name, HINSTANCE h_instance)
Application::~Application()
{
HGLRC h_glrc = m_window.get_h_glrc();
if (h_glrc != nullptr) {
// Unset the current OpenGL Rendering Context and Device
wglMakeCurrent(NULL, NULL);
wglDeleteContext(h_glrc);
m_window.set_h_glrc(nullptr);
}
}
int Application::run()
{
init();
MessageResponse resp(UNSET);
while (resp != QUIT_MESSAGE) {
// Handle all messages
while ((resp = m_window.handle_message()) == HANDLED_MESSAGE) {}
float delta_time = m_fps.mark();
clock_t clock = m_fps.get_clock();
update(delta_time, clock);
render();
m_window.swap();
try
{
init();
GLenum gl_err;
while (!glfwWindowShouldClose(m_p_window))
{
// Handle all messages
glfwPollEvents();
float delta_time = m_fps.mark();
clock_t clock = m_fps.get_clock();
update(delta_time, clock);
render();
gl_err = glGetError();
if (gl_err != GL_NO_ERROR)
{
throw EXCEPTION("Caught OpenGL Error: " + std::to_string(gl_err));
}
glfwSwapBuffers(m_p_window);
}
return 0;
}
catch (Exception& e)
{
glfwTerminate();
throw e;
}
return 0;
}
void Application::close()
@ -43,45 +51,32 @@ void Application::close()
void Application::base_init()
{
if (!m_window.register_class()) throw EXCEPTION("Unable to register window class.");
if (!m_window.create_window("OpenGLEngine", -1, -1, m_client_size.x, m_client_size.y)) throw EXCEPTION("Unable to create window");
// Initialize window with OpenGL (May want to move this into MyApplication to allow application customization)
// https://www.khronos.org/opengl/wiki/Creating_an_OpenGL_Context_(WGL)
HDC device_context = m_window.get_h_dc();
// PIXELFORMATDESCRIPTOR https://msdn.microsoft.com/en-us/library/cc231189.aspx
PIXELFORMATDESCRIPTOR pfd;
ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.cColorBits = 32;
pfd.cDepthBits = 24;
pfd.cStencilBits = 8;
pfd.iLayerType = PFD_MAIN_PLANE;
int pixel_format = ChoosePixelFormat(device_context, &pfd);
SetPixelFormat(device_context, pixel_format, &pfd);
HGLRC glrc = wglCreateContext(m_window.get_h_dc());
wglMakeCurrent(device_context, glrc);
m_window.set_h_glrc(glrc);
GLenum glewErr = glewInit();
if (glewErr != GLEW_OK)
if (!glfwInit())
{
OutputDebugString("Glew Init Failed: ");
OutputDebugString((char*)glewGetErrorString(glewErr));
OutputDebugString("\n");
throw EXCEPTION("GLEW Init Failure");
throw EXCEPTION("Unable to Initialize GLFW");
}
m_p_window = glfwCreateWindow(m_client_size.x, m_client_size.y, "OpenGLEngine", NULL, NULL);
if (!m_p_window)
{
glfwTerminate();
throw EXCEPTION("Unable to Create GLFW Window");
}
glfwMakeContextCurrent(m_p_window);
glewExperimental = GL_TRUE;
GLenum glew_err = glewInit();
if (glew_err != GLEW_OK)
{
glfwTerminate();
throw EXCEPTION("Unable to Initialize GLEW: " + std::string((char*)glewGetErrorString(glew_err)));
}
m_window.show(SW_NORMAL);
// Output Version Information
OutputDebugString("\nOpenGL Version Information:\nRenderer: ");
OutputDebugString((char*)glGetString(GL_RENDERER));
OutputDebugString("\nOpenGL Version: ");
OutputDebugString((char*)glGetString(GL_VERSION));
OutputDebugString("\n\n");
m_fps.prepare();
}

View File

@ -4,9 +4,10 @@
#include "vec2.h"
#include "Window.h"
#include "FPS.h"
using namespace egm;
// TODO: Close without rendering next frame.
class Application
@ -31,11 +32,8 @@ protected:
// The size of the window
ivec2 m_client_size;
// The window that is used by this application
Window m_window;
// The input manager for the window of this application
const InputManager* m_input_manager;
// The GLFWwindow that is used by this application
GLFWwindow* m_p_window;
// The FPS counter of this application
FPS m_fps;

View File

@ -1,20 +1,24 @@
#pragma once
#include "stdafx.h"
#include <vector>
#include "ShaderProgram.h"
#include "Renderable.h"
template <typename VertexType, typename IndexType>
template <typename RenderableType>
class Batch
{
public:
Batch(ShaderProgram* p_shader_program, const std::vector<Renderable<VertexType, IndexType>*>& p_renderables);
void init()
{
populate_vbos();
setup_vao();
}
virtual void init() = 0; // Maybe make this automatic? Or in the constructor?
virtual void render() = 0;
virtual void render() const = 0;
private:
ShaderProgram* m_p_shader_program;
std::vector<Renderable<VertexType, IndexType>*> m_p_renderables;
protected:
virtual void populate_vbos() = 0;
virtual void setup_vao() = 0;
};

View File

@ -0,0 +1,6 @@
#include "GLFWInputManager.h"
void GLFWInputManager::key_callback(GLFWwindow* p_window, int key, int scancode, int action, int mods)
{
}

View File

@ -0,0 +1,11 @@
#pragma once
#include "stdafx.h"
#include "InputManager.h"
class GLFWInputManager : public InputManager
{
public:
void key_callback(GLFWwindow* p_window, int key, int scancode, int action, int mods);
};

View File

@ -50,16 +50,11 @@ class InputManager
{
public:
InputManager();
~InputManager();
virtual ~InputManager();
//Should be called after each frame to reset the keysPressed
void mark();
void key_down(const unsigned long& keyCode);
void key_up(const unsigned long& keyCode);
void mouse_move(const ivec2& position);
void mouse_scroll(const unsigned int& distance);
bool is_key_down(const unsigned long& keyCode);
bool is_key_pressed(const unsigned long& keyCode);
bool is_key_released(const unsigned long& keyCode);
@ -67,6 +62,12 @@ public:
const ivec2& get_mouse_delta();
const int& get_scroll_distance();
protected:
void key_down(const unsigned long& keyCode);
void key_up(const unsigned long& keyCode);
void mouse_move(const ivec2& position);
void mouse_scroll(const unsigned int& distance);
private:
//Keys pressed since the last frame
//The existance of a value in this array means that the key has changed to that state

View File

@ -1,11 +1,32 @@
#include "MyBatch.h"
void MyBatch::init()
MyBatch::MyBatch(const MyTriangle& triangle)
: m_triangle(&triangle)
{
// TODO
}
void MyBatch::render()
void MyBatch::render() const
{
// TODO
// For now, just render everything!
glBindVertexArray(m_vao);
glDrawArrays(GL_TRIANGLES, 0, 3);
}
void MyBatch::populate_vbos()
{
glGenBuffers(1, &m_vbo);
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
m_triangle->populate_vbo();
}
void MyBatch::setup_vao()
{
glGenVertexArrays(1, &m_vao);
glBindVertexArray(m_vao);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
glBindVertexArray(0);
}

View File

@ -2,8 +2,23 @@
#include "Batch.h"
class MyBatch : public Batch
#include "Renderable.h"
#include "MyTriangle.h"
class MyBatch : public Batch<MyTriangle>
{
void init() override;
void render() override;
public:
MyBatch(const MyTriangle& triangle);
void render() const override;
protected:
void populate_vbos() override;
void setup_vao() override;
private:
const MyTriangle* m_triangle;
GLuint m_vbo;
GLuint m_vao;
};

View File

@ -11,14 +11,3 @@ MyShaderProgram::MyShaderProgram()
attach_shader(m_fragment_shader);
link();
}
GLuint MyShaderProgram::gen_vao() const
{
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
glBindVertexArray(0);
return vao;
}

View File

@ -2,6 +2,7 @@
#include "ShaderProgram.h"
#include "Shader.h"
#include "Renderable.h"
class MyShaderProgram : public ShaderProgram
{
@ -12,14 +13,11 @@ public:
float y;
float z;
};
typedef unsigned int Index;
typedef Renderable<Vertex, Index> RenderableType;
MyShaderProgram();
protected:
GLuint gen_vao() const override;
private:
Shader m_vertex_shader;
Shader m_fragment_shader;

View File

@ -1,6 +1,7 @@
#include "MySimpleScene.h"
MySimpleScene::MySimpleScene()
//: m_batch(m_triangle)
{
}
@ -11,8 +12,24 @@ MySimpleScene::~MySimpleScene()
void MySimpleScene::init()
{
m_shader_program.init();
m_triangle.init();
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
float points[] = {
0.0f, 0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
-0.5f, -0.5f, 0.0f
};
glGenBuffers(1, &m_vbo);
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
glBufferData(GL_ARRAY_BUFFER, 9 * sizeof(float), points, GL_STATIC_DRAW);
glGenVertexArrays(1, &m_vao);
glBindVertexArray(m_vao);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, m_vao);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
}
void MySimpleScene::use()
@ -29,7 +46,11 @@ void MySimpleScene::update(float delta_time, clock_t clock)
void MySimpleScene::render()
{
//m_shader_program.use();
//m_batch.render();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_shader_program.use();
glBindBuffer(GL_ARRAY_BUFFER, m_triangle.get_vbo());
glBindVertexArray(m_vao);
glDrawArrays(GL_TRIANGLES, 0, 3);
}

View File

@ -4,6 +4,7 @@
#include "Scene.h"
#include "MyBatch.h"
#include "MyShaderProgram.h"
#include "MyTriangle.h"
@ -26,7 +27,11 @@ public:
void render() override;
private:
//MyBatch m_batch;
MyShaderProgram m_shader_program;
MyTriangle m_triangle;
//MyTriangle m_triangle;
GLuint m_vbo;
GLuint m_vao;
};

View File

@ -34,6 +34,12 @@ MyTriangle::~MyTriangle()
}
}
void MyTriangle::populate_vbo() const
{
glBufferData(GL_ARRAY_BUFFER, m_p_mesh->vertex_count * sizeof(VertexType), m_p_mesh->vertices, GL_STATIC_DRAW);
}
/*
GLuint MyTriangle::gen_vbo() const
{
GLuint vbo;
@ -42,4 +48,5 @@ GLuint MyTriangle::gen_vbo() const
glBufferData(GL_ARRAY_BUFFER, m_p_mesh->vertex_count * sizeof(VertexType), m_p_mesh->vertices, GL_STATIC_DRAW); // TODO: Optimise Usage
return vbo;
}
*/

View File

@ -10,10 +10,6 @@ public:
MyTriangle();
~MyTriangle();
protected:
GLuint gen_vbo() const override;
private:
void populate_vbo() const override;
};

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -93,6 +93,18 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<Link />
<PostBuildEvent>
<Message>
</Message>
<Command>
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>copy "$(ProjectDir)..\dll\*" "$(OutDir)"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Copy DLLs</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
@ -123,14 +135,28 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Message>
</Message>
<Command>
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>copy "$(ProjectDir)..\dll\*" "$(OutDir)"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Copy DLLs</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Application.cpp" />
<ClCompile Include="Exception.cpp" />
<ClCompile Include="FPS.cpp" />
<ClCompile Include="GLFWInputManager.cpp" />
<ClCompile Include="InputManager.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="MyApplication.cpp" />
<ClCompile Include="MyBatch.cpp" />
<ClCompile Include="MyShaderProgram.cpp" />
<ClCompile Include="MySimpleScene.cpp" />
<ClCompile Include="MyTriangle.cpp" />
@ -141,16 +167,18 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Util.cpp" />
<ClCompile Include="Window.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Application.h" />
<ClInclude Include="Batch.h" />
<ClInclude Include="Exception.h" />
<ClInclude Include="FPS.h" />
<ClInclude Include="GLFWInputManager.h" />
<ClInclude Include="InputManager.h" />
<ClInclude Include="mat4x4.h" />
<ClInclude Include="Mesh.h" />
<ClInclude Include="MyApplication.h" />
<ClInclude Include="MyBatch.h" />
<ClInclude Include="MyShaderProgram.h" />
<ClInclude Include="MySimpleScene.h" />
<ClInclude Include="MyTriangle.h" />
@ -163,7 +191,6 @@
<ClInclude Include="vec2.h" />
<ClInclude Include="vec3.h" />
<ClInclude Include="vec4.h" />
<ClInclude Include="Window.h" />
</ItemGroup>
<ItemGroup>
<None Include="MyFragmentShader.glsl" />

View File

@ -27,9 +27,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Window.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="InputManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -69,11 +66,14 @@
<ClCompile Include="Exception.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MyBatch.cpp">
<Filter>Source Files\Example</Filter>
</ClCompile>
<ClCompile Include="GLFWInputManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Window.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="InputManager.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -131,6 +131,15 @@
<ClInclude Include="Mesh.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Batch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MyBatch.h">
<Filter>Header Files\Example</Filter>
</ClInclude>
<ClInclude Include="GLFWInputManager.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="MyVertexShader.glsl">

View File

@ -16,24 +16,13 @@ public:
virtual ~Renderable() { };
void init()
{
m_vbo = gen_vbo();
}
const MeshType* get_mesh() const
{
return m_p_mesh;
}
GLuint get_vbo() const
{
return m_vbo;
}
virtual void populate_vbo() const = 0;
protected:
virtual GLuint gen_vbo() const = 0;// TODO: A VBO for every object?
const MeshType* m_p_mesh = nullptr;
GLuint m_vbo = 0;
};

View File

@ -1,7 +1,5 @@
#include "Shader.h"
#include <Windows.h>
#include "Exception.h"
Shader::Shader(const std::string& source, ShaderType type)

View File

@ -10,11 +10,6 @@ ShaderProgram::~ShaderProgram()
glDeleteProgram(m_program);
}
void ShaderProgram::init()
{
m_vao = gen_vao();
}
void ShaderProgram::attach_shader(const Shader& shader)
{
glAttachShader(m_program, shader.get_shader());
@ -26,18 +21,12 @@ void ShaderProgram::link()
// TODO: Error handling
}
void ShaderProgram::use()
void ShaderProgram::use() const
{
glUseProgram(m_program);
glBindVertexArray(get_vao());
}
GLuint ShaderProgram::get_program() const
{
return m_program;
}
GLuint ShaderProgram::get_vao() const
{
return m_vao;
}

View File

@ -12,20 +12,14 @@ public:
ShaderProgram();
virtual ~ShaderProgram();
void init();
void use();
void use() const;
GLuint get_program() const;
GLuint get_vao() const;
protected:
void attach_shader(const Shader& shader);
void link();
// Should return the Vertex Attribute Object for this shader. Called once by the constructor.
virtual GLuint gen_vao() const = 0;
private:
GLuint m_program = 0;
GLuint m_vao = 0;
};

View File

@ -1,7 +1,5 @@
#include "stdafx.h"
#include <Windows.h>
#include <string>
#include "Exception.h"

View File

@ -1,6 +1,9 @@
#pragma once
#include <glew/glew.h>
#include <Windows.h>
#include <GLEW/glew.h>
#include <GLFW/glfw3.h>
#pragma comment(lib, "glew32.lib")
#pragma comment(lib, "glfw3.lib")
#pragma comment(lib, "opengl32.lib")

View File

@ -1,8 +1,5 @@
#include "Window.h"
#include <Windows.h>
#include <windowsx.h>
#include <iostream>
#include <map>

BIN
dll/glew32.dll Normal file

Binary file not shown.

BIN
dll/glfw3.dll Normal file

Binary file not shown.

4248
include/GLFW/glfw3.h Normal file

File diff suppressed because it is too large Load Diff

456
include/GLFW/glfw3native.h Normal file
View File

@ -0,0 +1,456 @@
/*************************************************************************
* GLFW 3.2 - www.glfw.org
* A library for OpenGL, window and input
*------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard
* Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would
* be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
*************************************************************************/
#ifndef _glfw3_native_h_
#define _glfw3_native_h_
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************
* Doxygen documentation
*************************************************************************/
/*! @file glfw3native.h
* @brief The header of the native access functions.
*
* This is the header file of the native access functions. See @ref native for
* more information.
*/
/*! @defgroup native Native access
*
* **By using the native access functions you assert that you know what you're
* doing and how to fix problems caused by using them. If you don't, you
* shouldn't be using them.**
*
* Before the inclusion of @ref glfw3native.h, you may define exactly one
* window system API macro and zero or more context creation API macros.
*
* The chosen backends must match those the library was compiled for. Failure
* to do this will cause a link-time error.
*
* The available window API macros are:
* * `GLFW_EXPOSE_NATIVE_WIN32`
* * `GLFW_EXPOSE_NATIVE_COCOA`
* * `GLFW_EXPOSE_NATIVE_X11`
* * `GLFW_EXPOSE_NATIVE_WAYLAND`
* * `GLFW_EXPOSE_NATIVE_MIR`
*
* The available context API macros are:
* * `GLFW_EXPOSE_NATIVE_WGL`
* * `GLFW_EXPOSE_NATIVE_NSGL`
* * `GLFW_EXPOSE_NATIVE_GLX`
* * `GLFW_EXPOSE_NATIVE_EGL`
*
* These macros select which of the native access functions that are declared
* and which platform-specific headers to include. It is then up your (by
* definition platform-specific) code to handle which of these should be
* defined.
*/
/*************************************************************************
* System headers and types
*************************************************************************/
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
// example to allow applications to correctly declare a GL_ARB_debug_output
// callback) but windows.h assumes no one will define APIENTRY before it does
#undef APIENTRY
#include <windows.h>
#elif defined(GLFW_EXPOSE_NATIVE_COCOA)
#include <ApplicationServices/ApplicationServices.h>
#if defined(__OBJC__)
#import <Cocoa/Cocoa.h>
#else
typedef void* id;
#endif
#elif defined(GLFW_EXPOSE_NATIVE_X11)
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
#include <wayland-client.h>
#elif defined(GLFW_EXPOSE_NATIVE_MIR)
#include <mir_toolkit/mir_client_library.h>
#endif
#if defined(GLFW_EXPOSE_NATIVE_WGL)
/* WGL is declared by windows.h */
#endif
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
/* NSGL is declared by Cocoa.h */
#endif
#if defined(GLFW_EXPOSE_NATIVE_GLX)
#include <GL/glx.h>
#endif
#if defined(GLFW_EXPOSE_NATIVE_EGL)
#include <EGL/egl.h>
#endif
/*************************************************************************
* Functions
*************************************************************************/
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
/*! @brief Returns the adapter device name of the specified monitor.
*
* @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
* occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.1.
*
* @ingroup native
*/
GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
/*! @brief Returns the display device name of the specified monitor.
*
* @return The UTF-8 encoded display device name (for example
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.1.
*
* @ingroup native
*/
GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
/*! @brief Returns the `HWND` of the specified window.
*
* @return The `HWND` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_WGL)
/*! @brief Returns the `HGLRC` of the specified window.
*
* @return The `HGLRC` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_COCOA)
/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
*
* @return The `CGDirectDisplayID` of the specified monitor, or
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.1.
*
* @ingroup native
*/
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
/*! @brief Returns the `NSWindow` of the specified window.
*
* @return The `NSWindow` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
/*! @brief Returns the `NSOpenGLContext` of the specified window.
*
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_X11)
/*! @brief Returns the `Display` used by GLFW.
*
* @return The `Display` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI Display* glfwGetX11Display(void);
/*! @brief Returns the `RRCrtc` of the specified monitor.
*
* @return The `RRCrtc` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.1.
*
* @ingroup native
*/
GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
/*! @brief Returns the `RROutput` of the specified monitor.
*
* @return The `RROutput` of the specified monitor, or `None` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.1.
*
* @ingroup native
*/
GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
/*! @brief Returns the `Window` of the specified window.
*
* @return The `Window` of the specified window, or `None` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_GLX)
/*! @brief Returns the `GLXContext` of the specified window.
*
* @return The `GLXContext` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
/*! @brief Returns the `GLXWindow` of the specified window.
*
* @return The `GLXWindow` of the specified window, or `None` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
/*! @brief Returns the `struct wl_display*` used by GLFW.
*
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
/*! @brief Returns the `struct wl_output*` of the specified monitor.
*
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
/*! @brief Returns the main `struct wl_surface*` of the specified window.
*
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
* an [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_MIR)
/*! @brief Returns the `MirConnection*` used by GLFW.
*
* @return The `MirConnection*` used by GLFW, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI MirConnection* glfwGetMirDisplay(void);
/*! @brief Returns the Mir output ID of the specified monitor.
*
* @return The Mir output ID of the specified monitor, or zero if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI int glfwGetMirMonitor(GLFWmonitor* monitor);
/*! @brief Returns the `MirSurface*` of the specified window.
*
* @return The `MirSurface*` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.2.
*
* @ingroup native
*/
GLFWAPI MirSurface* glfwGetMirWindow(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_EGL)
/*! @brief Returns the `EGLDisplay` used by GLFW.
*
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
/*! @brief Returns the `EGLContext` of the specified window.
*
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
/*! @brief Returns the `EGLSurface` of the specified window.
*
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.0.
*
* @ingroup native
*/
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _glfw3_native_h_ */

BIN
lib/glfw3.lib Normal file

Binary file not shown.

BIN
lib/glfw3dll.lib Normal file

Binary file not shown.