1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#include <gmock/gmock.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#include <glbinding/AbstractFunction.h>
#include <glbinding/Meta.h>
#include <glbinding/ContextInfo.h>
#include <glbinding/Version.h>
#include <glbinding/Binding.h>
#include <glbinding/gl/gl.h>
using namespace gl;
using namespace glbinding;
class MultiContext_test : public testing::Test
{
public:
};
namespace
{
void error(int /*errnum*/, const char * /*errmsg*/)
{
FAIL();
}
}
TEST_F(MultiContext_test, Test)
{
int success = glfwInit();
EXPECT_EQ(1, success);
glfwSetErrorCallback(error);
glfwWindowHint(GLFW_VISIBLE, false);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, false); // does not work for all opengl drivers
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow * window1 = glfwCreateWindow(320, 240, "", nullptr, nullptr);
EXPECT_NE(nullptr, window1);
glfwDefaultWindowHints();
glfwWindowHint(GLFW_VISIBLE, false);
GLFWwindow * window2 = glfwCreateWindow(320, 240, "", nullptr, nullptr);
EXPECT_NE(nullptr, window2);
glfwMakeContextCurrent(window1);
Binding::initialize(false);
#ifdef SYSTEM_WINDOWS
EXPECT_EQ(Version(3, 2), ContextInfo::version());
#elif defined(SYSTEM_DARWIN)
EXPECT_EQ(Version(4, 1), ContextInfo::version());
EXPECT_EQ(nullptr, Binding::DispatchCompute.address());
#else // Linux
EXPECT_EQ(Version(3, 2), ContextInfo::version());
EXPECT_NE(nullptr, Binding::DispatchCompute.address());
#endif
glfwMakeContextCurrent(window2);
Binding::initialize(false);
Binding::releaseCurrentContext();
glfwMakeContextCurrent(window1);
Binding::releaseCurrentContext();
glfwTerminate();
}
|