Hash :
8a079e5e
Author :
Date :
2013-10-18T16:13:33
Added an angle_tests project and base class for tests. TRAC #23776 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
#include "ANGLETest.h"
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CLOSE:
PostQuitMessage(0);
return 1;
default:
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
static const PTCHAR GetTestWindowName()
{
return TEXT("ANGLE_TEST");
}
bool ANGLETest::InitTestWindow()
{
WNDCLASS sWC;
sWC.style = CS_OWNDC;
sWC.lpfnWndProc = WndProc;
sWC.cbClsExtra = 0;
sWC.cbWndExtra = 0;
sWC.hInstance = NULL;
sWC.hIcon = NULL;
sWC.hCursor = LoadCursor(NULL, IDC_ARROW);
sWC.lpszMenuName = NULL;
sWC.hbrBackground = NULL;
sWC.lpszClassName = GetTestWindowName();
if (!RegisterClass(&sWC))
{
return false;
}
mNativeWindow = CreateWindow(GetTestWindowName(), NULL, WS_BORDER, 128, 128, 128, 128, NULL, NULL, NULL, NULL);
SetWindowLong(mNativeWindow, GWL_STYLE, 0);
ShowWindow(mNativeWindow, SW_SHOW);
mNativeDisplay = GetDC(mNativeWindow);
if (!mNativeDisplay)
{
DestroyTestWindow();
return false;
}
mDisplay = eglGetDisplay(mNativeDisplay);
if(mDisplay == EGL_NO_DISPLAY)
{
mDisplay = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY);
}
EGLint majorVersion, minorVersion;
if (!eglInitialize(mDisplay, &majorVersion, &minorVersion))
{
DestroyTestWindow();
return false;
}
eglBindAPI(EGL_OPENGL_ES_API);
if (eglGetError() != EGL_SUCCESS)
{
DestroyTestWindow();
return false;
}
return true;
}
bool ANGLETest::DestroyTestWindow()
{
eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(mDisplay);
if (mNativeDisplay)
{
ReleaseDC(mNativeWindow, mNativeDisplay);
mNativeDisplay = 0;
}
if (mNativeWindow)
{
DestroyWindow(mNativeWindow);
mNativeWindow = 0;
}
UnregisterClass(GetTestWindowName(), NULL);
return true;
}
bool ANGLETest::ReizeWindow(int width, int height)
{
RECT windowRect;
if (!GetWindowRect(mNativeWindow, &windowRect))
{
return false;
}
if (!MoveWindow(mNativeWindow, windowRect.left, windowRect.top, width, height, FALSE))
{
return false;
}
return true;
}