Unfinished Wayland PR #1
4 changed files with 25 additions and 31 deletions
opengl complete
commit
a932fc00ea
|
|
@ -128,7 +128,7 @@ MWDECL void MwLoop(MwWidget handle);
|
|||
*/
|
||||
MWDECL int MwStep(MwWidget handle);
|
||||
|
||||
/*!
|
||||
/*!MwStep(
|
||||
* @brief Check if any event is pending
|
||||
* @param handle Widget
|
||||
* @return `1` if any event is pending
|
||||
|
|
|
|||
|
|
@ -71,8 +71,6 @@ struct _MwLLWayland {
|
|||
wayland_protocol_t* value;
|
||||
}* wl_protocol_map;
|
||||
|
||||
/*MwLL* subsurfaces;*/
|
||||
|
||||
struct wl_display* display;
|
||||
struct wl_registry* registry;
|
||||
struct wl_compositor* compositor;
|
||||
|
|
@ -80,11 +78,12 @@ struct _MwLLWayland {
|
|||
struct wl_surface* surface;
|
||||
struct wl_shm* shm;
|
||||
struct wl_registry_listener registry_listener;
|
||||
// cairo_surface_t* cairo_surface;
|
||||
|
||||
MwBool configured;
|
||||
MwBool force_redraw;
|
||||
MwBool do_clear;
|
||||
MwU32 x, y, ww, wh;
|
||||
int z_index;
|
||||
|
||||
MwLL parent;
|
||||
|
||||
|
|
@ -97,6 +96,8 @@ struct _MwLLWayland {
|
|||
EGLDisplay egl_display;
|
||||
EGLContext egl_context;
|
||||
EGLSurface egl_surface;
|
||||
GLuint vertex_buffer;
|
||||
GLuint vertex_array;
|
||||
};
|
||||
|
||||
struct _MwLLWaylandColor {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/* $Id$ */
|
||||
|
||||
// #include <GL/gl.h>
|
||||
#include <GL/gl.h>
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
|
|
@ -22,10 +23,9 @@
|
|||
#include <wayland-egl-core.h>
|
||||
#include <wayland-util.h>
|
||||
|
||||
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
|
||||
// PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
|
||||
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
|
||||
PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
|
||||
PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
|
||||
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
|
|
@ -254,7 +254,7 @@ static MwBool egl_setup(MwLL self, int width, int height) {
|
|||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, width, height, -13, -1, 1);
|
||||
glOrtho(0, width, height, 0, -1, 1);
|
||||
|
||||
self->wayland.egl_display = display;
|
||||
self->wayland.egl_surface = surface;
|
||||
|
|
@ -283,11 +283,12 @@ static void xdg_toplevel_configure(void* data,
|
|||
|
||||
if(!self->wayland.egl_setup) {
|
||||
self->wayland.egl_setup = egl_setup(self, width, height);
|
||||
MwLLForceRender(self);
|
||||
} else {
|
||||
wl_egl_window_resize(self->wayland.egl_window_native, width, height, 0, 0);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, width, height, -13, -1, 1);
|
||||
glOrtho(0, width, height, 0, -1, 1);
|
||||
self->wayland.do_clear = MwTRUE;
|
||||
|
||||
// glDeleteTextures(1, &self->wayland.fbo_texture);
|
||||
|
|
@ -303,8 +304,6 @@ static void xdg_toplevel_configure(void* data,
|
|||
// glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
MwLLForceRender(self);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -452,6 +451,8 @@ static void setup_toplevel(MwLL r, int x, int y, int width, int height) {
|
|||
// buffer_setup(&r->wayland);
|
||||
|
||||
wl_surface_commit(r->wayland.surface);
|
||||
|
||||
// glGenBuffers(1, &vertex_buffer);
|
||||
}
|
||||
|
||||
static void setup_subsurface(MwLL parent, MwLL r, int x, int y, int width, int height) {
|
||||
|
|
@ -518,8 +519,6 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
|||
setup_subsurface(parent, r, x, y, width, height);
|
||||
}
|
||||
|
||||
// buffer_setup(&r->wayland);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -581,20 +580,21 @@ static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLL
|
|||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, handle->wayland.fbo);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, handle->wayland.fbo_texture, 0);
|
||||
glLineWidth(1);
|
||||
|
||||
if(points_count == 3) {
|
||||
glBegin(GL_TRIANGLES);
|
||||
} else if(points_count == 4) {
|
||||
glBegin(GL_QUADS);
|
||||
} else {
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
}
|
||||
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
for(i = 0; i < points_count; i++) {
|
||||
glColor3f(color->common.red / 255.0, color->common.green / 255.0, color->common.blue / 255.0);
|
||||
glVertex2f(
|
||||
(handle->wayland.x + points[i].x),
|
||||
(handle->wayland.y + points[i].y));
|
||||
|
||||
if((i % 3) == 0 && i != 0) {
|
||||
glColor3f(color->common.red / 255.0, color->common.green / 255.0, color->common.blue / 255.0);
|
||||
glVertex2f(
|
||||
(handle->wayland.x + points[i].x),
|
||||
(handle->wayland.y + points[i].y));
|
||||
}
|
||||
ceil(handle->wayland.x) + ceil(points[i].x),
|
||||
ceil(handle->wayland.y) + ceil(points[i].y));
|
||||
}
|
||||
glEnd();
|
||||
glFinish();
|
||||
|
|
@ -749,12 +749,6 @@ static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
|
|||
static void MwLLForceRenderImpl(MwLL handle) {
|
||||
wl_surface_damage(handle->wayland.surface, 0, 0, handle->wayland.ww, handle->wayland.wh);
|
||||
|
||||
if(handle->wayland.egl_setup) {
|
||||
if(!eglSwapBuffers(handle->wayland.egl_display, handle->wayland.egl_surface)) {
|
||||
printf("error swapping buffers! %0X\n", eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
wl_surface_commit(handle->wayland.surface);
|
||||
|
||||
handle->wayland.force_redraw = MwTRUE;
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ static XVisualInfo* get_visual_info(Display* display) {
|
|||
}
|
||||
|
||||
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||
printf("%d %d\n", width, height);
|
||||
MwLL r;
|
||||
Window p;
|
||||
XVisualInfo* xvi;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue