Some cleaning up.
This commit is contained in:
parent
6af296409a
commit
1180e576fa
5 changed files with 166 additions and 163 deletions
|
@ -2,104 +2,20 @@
|
|||
|
||||
#include "WaylandEglInterface.h"
|
||||
|
||||
#include <wayland-egl.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
struct wl_egl_window;
|
||||
struct wl_surface;
|
||||
|
||||
class WaylandEglWindowInterface
|
||||
{
|
||||
public:
|
||||
|
||||
WaylandEglWindowInterface(WaylandEglInterface* eglInterface)
|
||||
: mEglInterface(eglInterface)
|
||||
{
|
||||
WaylandEglWindowInterface(WaylandEglInterface* eglInterface);
|
||||
|
||||
}
|
||||
void initialize(wl_surface* surface, int width, int height);
|
||||
|
||||
void initialize(wl_surface* surface, int width, int height)
|
||||
{
|
||||
if (mEglSurface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mEglWindow = wl_egl_window_create(surface, width, height);
|
||||
if (mEglWindow == EGL_NO_SURFACE)
|
||||
{
|
||||
fprintf(stderr, "Can't create egl window\n");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Created egl window\n");
|
||||
}
|
||||
|
||||
mEglSurface = eglCreateWindowSurface(mEglInterface->getDisplay(), mEglInterface->getConfig(), mEglWindow, nullptr);
|
||||
|
||||
if (!mEglSurface)
|
||||
{
|
||||
switch(eglGetError())
|
||||
{
|
||||
//case EGL_NO_SURFACE:
|
||||
//fprintf(stderr, "EGL_NO_SURFACE\n");
|
||||
//break;
|
||||
case EGL_BAD_DISPLAY:
|
||||
fprintf(stderr, "EGL_BAD_DISPLAY\n");
|
||||
break;
|
||||
case EGL_NOT_INITIALIZED:
|
||||
fprintf(stderr, "EGL_NOT_INITIALIZED\n");
|
||||
break;
|
||||
case EGL_BAD_CONFIG:
|
||||
fprintf(stderr, "EGL_BAD_CONFIG\n");
|
||||
break;
|
||||
case EGL_BAD_NATIVE_WINDOW:
|
||||
fprintf(stderr, "EGL_BAD_NATIVE_WINDOW\n");
|
||||
break;
|
||||
case EGL_BAD_ATTRIBUTE:
|
||||
fprintf(stderr, "EGL_BAD_ATTRIBUTE\n");
|
||||
break;
|
||||
case EGL_BAD_ALLOC:
|
||||
fprintf(stderr, "EGL_BAD_ALLOC\n");
|
||||
break;
|
||||
case EGL_BAD_MATCH:
|
||||
fprintf(stderr, "EGL_BAD_MATCH\n");
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown EGL error\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "Created surface failed\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
if (!mEglSurface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (eglMakeCurrent(mEglInterface->getDisplay(), mEglSurface, mEglSurface, mEglInterface->getContext()))
|
||||
{
|
||||
fprintf(stderr, "Made current\n");
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Made current failed\n");
|
||||
}
|
||||
|
||||
glClearColor(1.0, 1.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glFlush();
|
||||
|
||||
if (eglSwapBuffers(mEglInterface->getDisplay(), mEglSurface))
|
||||
{
|
||||
fprintf(stderr, "Swapped buffers\n");
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Swapped buffers failed\n");
|
||||
}
|
||||
}
|
||||
void draw();
|
||||
|
||||
private:
|
||||
wl_egl_window* mEglWindow{nullptr};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue