godot/platform/winrt/gl_context_egl.cpp
Juan Linietsky b24fe3dd20 Huge Amount of BugFix
-=-=-=-=-=-=-=-=-=-=-

-Fixes to Collada Exporter (avoid crash situtions)
-Fixed to Collada Importer (Fixed Animation Optimizer Bugs)
-Fixes to RigidBody/RigidBody2D body_enter/body_exit, was buggy
-Fixed ability for RigidBody/RigidBody2D to get contacts reported and bodyin/out in Kinematic mode.
-Added proper trigger support for 3D Physics shapes
-Changed proper value for Z-Offset in OmniLight
-Fixed spot attenuation bug in SpotLight
-Fixed some 3D and 2D spatial soudn bugs related to distance attenuation.
-Fixed bugs in EventPlayer (channels were muted by default)
-Fix in ButtonGroup (get nodes in group are now returned in order)
-Fixed Linear->SRGB Conversion, previous algo sucked, new algo works OK
-Changed SRGB->Linear conversion to use hardware if supported, improves texture quality a lot
-Fixed options for Y-Fov and X-Fov in camera, should be more intuitive.
-Fixed bugs related to viewports and transparency

Huge Amount of New Stuff:
-=-=-=-=-=-=-=-==-=-=-=-

-Ability to manually advance an AnimationPlayer that is inactive (with advance() function)
-More work in WinRT platform
-Added XY normalmap support, imports on this format by default. Reduces normlmap size and enables much nice compression using LATC
-Added Anisotropic filter support to textures, can be specified on import
-Added support for Non-Square, Isometric and Hexagonal tilemaps in TileMap.
-Added Isometric Dungeon demo.
-Added simple hexagonal map demo.
-Added Truck-Town demo. Shows how most types of joints and vehicles are used. Please somebody make a nicer town, this one is too hardcore.
-Added an Object-Picking API to both RigidBody and Area! (and relevant demo)
2014-10-03 00:10:51 -03:00

151 lines
3.3 KiB
C++

#include "gl_context_egl.h"
using namespace Platform;
void ContextEGL::release_current() {
eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, mEglContext);
};
void ContextEGL::make_current() {
eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext);
};
int ContextEGL::get_window_width() {
return width;
};
int ContextEGL::get_window_height() {
return height;
};
void ContextEGL::swap_buffers() {
if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE)
{
cleanup();
window = CoreWindow::GetForCurrentThread();
initialize();
// tell rasterizer to reload textures and stuff?
}
};
Error ContextEGL::initialize() {
EGLint configAttribList[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 8,
EGL_STENCIL_SIZE, 8,
EGL_SAMPLE_BUFFERS, 0,
EGL_NONE
};
EGLint surfaceAttribList[] = {
EGL_NONE, EGL_NONE
};
EGLint numConfigs = 0;
EGLint majorVersion = 1;
EGLint minorVersion = 0;
EGLDisplay display = EGL_NO_DISPLAY;
EGLContext context = EGL_NO_CONTEXT;
EGLSurface surface = EGL_NO_SURFACE;
EGLConfig config = nullptr;
EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
try {
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (display == EGL_NO_DISPLAY)
{
throw Exception::CreateException(E_FAIL, L"Failed to get default EGL display");
}
if (eglInitialize(display, &majorVersion, &minorVersion) == EGL_FALSE)
{
throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL");
}
if (eglGetConfigs(display, NULL, 0, &numConfigs) == EGL_FALSE)
{
throw Exception::CreateException(E_FAIL, L"Failed to get EGLConfig count");
}
if (eglChooseConfig(display, configAttribList, &config, 1, &numConfigs) == EGL_FALSE)
{
throw Exception::CreateException(E_FAIL, L"Failed to choose first EGLConfig count");
}
surface = eglCreateWindowSurface(display, config, reinterpret_cast<IInspectable*>(window), surfaceAttribList);
if (surface == EGL_NO_SURFACE)
{
throw Exception::CreateException(E_FAIL, L"Failed to create EGL fullscreen surface");
}
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);
if (context == EGL_NO_CONTEXT)
{
throw Exception::CreateException(E_FAIL, L"Failed to create EGL context");
}
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE)
{
throw Exception::CreateException(E_FAIL, L"Failed to make fullscreen EGLSurface current");
}
} catch (...) {
return FAILED;
};
mEglDisplay = display;
mEglSurface = surface;
mEglContext = context;
eglQuerySurface(display,surface,EGL_WIDTH,&width);
eglQuerySurface(display,surface,EGL_HEIGHT,&height);
return OK;
};
void ContextEGL::cleanup() {
if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE)
{
eglDestroySurface(mEglDisplay, mEglSurface);
mEglSurface = EGL_NO_SURFACE;
}
if (mEglDisplay != EGL_NO_DISPLAY && mEglContext != EGL_NO_CONTEXT)
{
eglDestroyContext(mEglDisplay, mEglContext);
mEglContext = EGL_NO_CONTEXT;
}
if (mEglDisplay != EGL_NO_DISPLAY)
{
eglTerminate(mEglDisplay);
mEglDisplay = EGL_NO_DISPLAY;
}
};
ContextEGL::ContextEGL(CoreWindow^ p_window) :
mEglDisplay(EGL_NO_DISPLAY),
mEglContext(EGL_NO_CONTEXT),
mEglSurface(EGL_NO_SURFACE)
{
window = p_window;
};
ContextEGL::~ContextEGL() {
cleanup();
};