Commit 56cf9af2 by Geoff Lang

Add a FunctionsGL class for loading GL entry points.

BUG=angle:879 Change-Id: I35384f078d2ed86a6c72cc243753b56bc58617b0 Reviewed-on: https://chromium-review.googlesource.com/250390Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 5b8b1087
......@@ -28,7 +28,7 @@ DisplayGL::~DisplayGL()
egl::Error DisplayGL::initialize(egl::Display *display)
{
mRenderer = new RendererGL();
mRenderer = new RendererGL(getFunctionsGL());
return egl::Error(EGL_SUCCESS);
}
......
......@@ -10,6 +10,7 @@
#define LIBANGLE_RENDERER_GL_DISPLAYGL_H_
#include "libANGLE/renderer/DisplayImpl.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
namespace rx
{
......@@ -31,6 +32,8 @@ class DisplayGL : public DisplayImpl
private:
DISALLOW_COPY_AND_ASSIGN(DisplayGL);
virtual const FunctionsGL *getFunctionsGL() const = 0;
RendererGL *mRenderer;
};
......
......@@ -15,6 +15,7 @@
#include "libANGLE/renderer/gl/FenceNVGL.h"
#include "libANGLE/renderer/gl/FenceSyncGL.h"
#include "libANGLE/renderer/gl/FramebufferGL.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/ProgramGL.h"
#include "libANGLE/renderer/gl/QueryGL.h"
#include "libANGLE/renderer/gl/RenderbufferGL.h"
......@@ -26,9 +27,12 @@
namespace rx
{
RendererGL::RendererGL()
: Renderer()
{}
RendererGL::RendererGL(const FunctionsGL *functions)
: Renderer(),
mFunctions(functions)
{
ASSERT(mFunctions);
}
RendererGL::~RendererGL()
{}
......
......@@ -13,11 +13,12 @@
namespace rx
{
class FunctionsGL;
class RendererGL : public Renderer
{
public:
RendererGL();
RendererGL(const FunctionsGL *functions);
~RendererGL() override;
gl::Error flush() override;
......@@ -73,6 +74,8 @@ class RendererGL : public Renderer
void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps, gl::Extensions *outExtensions) const override;
Workarounds generateWorkarounds() const override;
const FunctionsGL *mFunctions;
};
}
......
......@@ -23,12 +23,45 @@
namespace rx
{
class FunctionsGLWindows : public FunctionsGL
{
public:
FunctionsGLWindows(HMODULE openGLModule)
: mOpenGLModule(openGLModule)
, mGetProcAddressWGL(nullptr)
{
ASSERT(mOpenGLModule);
mGetProcAddressWGL = reinterpret_cast<PFNWGLGETPROCADDRESSPROC>(GetProcAddress(mOpenGLModule, "wglGetProcAddress"));
}
virtual ~FunctionsGLWindows()
{
}
private:
void *loadProcAddress(const std::string &function) override
{
void *proc = mGetProcAddressWGL(function.c_str());
if (!proc)
{
proc = GetProcAddress(mOpenGLModule, function.c_str());
}
return proc;
}
HMODULE mOpenGLModule;
typedef PROC(WINAPI *PFNWGLGETPROCADDRESSPROC)(LPCSTR);
PFNWGLGETPROCADDRESSPROC mGetProcAddressWGL;
};
DisplayWGL::DisplayWGL()
: DisplayGL(),
mOpenGLModule(nullptr),
mGLVersionMajor(0),
mGLVersionMinor(0),
mFunctionsWGL(nullptr),
mFunctionsGL(nullptr),
mWindowClass(0),
mWindow(nullptr),
mDeviceContext(nullptr),
......@@ -277,6 +310,9 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
mGLVersionMajor = versionString[0] - '0';
mGLVersionMinor = versionString[2] - '0';
mFunctionsGL = new FunctionsGLWindows(mOpenGLModule);
mFunctionsGL->initialize(mGLVersionMajor, mGLVersionMinor);
return DisplayGL::initialize(display);
}
......@@ -298,6 +334,7 @@ void DisplayWGL::terminate()
mWindowClass = NULL;
SafeDelete(mFunctionsWGL);
SafeDelete(mFunctionsGL);
FreeLibrary(mOpenGLModule);
mOpenGLModule = nullptr;
......@@ -433,6 +470,11 @@ std::string DisplayWGL::getVendorString() const
return "";
}
const FunctionsGL *DisplayWGL::getFunctionsGL() const
{
return mFunctionsGL;
}
void DisplayWGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
{
UNIMPLEMENTED();
......
......@@ -49,6 +49,8 @@ class DisplayWGL : public DisplayGL
private:
DISALLOW_COPY_AND_ASSIGN(DisplayWGL);
const FunctionsGL *getFunctionsGL() const override;
void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
void generateCaps(egl::Caps *outCaps) const override;
......@@ -57,6 +59,7 @@ class DisplayWGL : public DisplayGL
GLuint mGLVersionMinor;
FunctionsWGL *mFunctionsWGL;
FunctionsGL *mFunctionsGL;
ATOM mWindowClass;
HWND mWindow;
......
......@@ -375,6 +375,8 @@
'libANGLE/renderer/gl/FenceSyncGL.h',
'libANGLE/renderer/gl/FramebufferGL.cpp',
'libANGLE/renderer/gl/FramebufferGL.h',
'libANGLE/renderer/gl/FunctionsGL.cpp',
'libANGLE/renderer/gl/FunctionsGL.h',
'libANGLE/renderer/gl/ProgramGL.cpp',
'libANGLE/renderer/gl/ProgramGL.h',
'libANGLE/renderer/gl/QueryGL.cpp',
......@@ -393,6 +395,8 @@
'libANGLE/renderer/gl/TransformFeedbackGL.h',
'libANGLE/renderer/gl/VertexArrayGL.cpp',
'libANGLE/renderer/gl/VertexArrayGL.h',
'libANGLE/renderer/gl/functionsgl_enums.h',
'libANGLE/renderer/gl/functionsgl_typedefs.h',
],
'libangle_gl_wgl_sources':
[
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment