mirror of
https://github.com/swaywm/sway.git
synced 2026-04-22 06:46:27 -04:00
small update + added test lines
This commit is contained in:
parent
ed98da84bb
commit
6ec9622ac6
4 changed files with 936 additions and 896 deletions
|
|
@ -14,7 +14,9 @@ struct gles2_tex_shader {
|
|||
|
||||
struct gles2_renderer {
|
||||
struct wlr_egl *egl;
|
||||
|
||||
float projection[9];
|
||||
|
||||
uint32_t viewport_width;
|
||||
uint32_t viewport_height;
|
||||
|
||||
|
|
@ -32,4 +34,6 @@ struct gles2_renderer {
|
|||
} shaders;
|
||||
};
|
||||
|
||||
struct gles2_renderer *gles2_renderer_create(struct wlr_egl *egl);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
#include <assert.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/backend.h> // TODO: remove if removed from renderer_init
|
||||
#include <wlr/render/egl.h> // TODO: remove if removed from renderer_init
|
||||
#include <wlr/render/egl.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/util/box.h>
|
||||
#include "log.h"
|
||||
|
|
@ -91,7 +90,7 @@ const GLchar tex_fragment_src_external[] =
|
|||
/************************
|
||||
Matrix Consts
|
||||
*************************/
|
||||
|
||||
/*
|
||||
static const GLfloat flip_180[] = {
|
||||
1.0f, 0.0f, 0.0f,
|
||||
0.0f, -1.0f, 0.0f,
|
||||
|
|
@ -104,7 +103,7 @@ static const GLfloat verts[] = {
|
|||
1, 1, // bottom right
|
||||
0, 1, // bottom left
|
||||
};
|
||||
|
||||
*/
|
||||
/************************
|
||||
General Functions
|
||||
*************************/
|
||||
|
|
@ -159,11 +158,12 @@ error:
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct gles2_renderer *gles2_renderer_create(struct wlr_backend *backend) {
|
||||
struct gles2_renderer *gles2_renderer_create(struct wlr_egl *egl) {
|
||||
// TODO: Hyprland way?
|
||||
// TODO: handle case of no drm_fd?
|
||||
int drm_fd = wlr_backend_get_drm_fd(backend);
|
||||
struct wlr_egl *egl = wlr_egl_create_with_drm_fd(drm_fd);
|
||||
//struct wlr_egl *egl = wlr_egl_create_with_drm_fd(drm_fd);
|
||||
//struct wlr_egl *egl = wlr_egl_create_with_context(${1:EGLDisplay display}, ${2:EGLContext context});
|
||||
|
||||
if (egl == NULL) {
|
||||
sway_log(SWAY_ERROR, "GLES2 RENDERER: Could not initialize EGL");
|
||||
return NULL;
|
||||
|
|
@ -260,22 +260,41 @@ error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// TODO: is gles2_get_renderer_in_context(wlr_renderer) implementation needed?
|
||||
static void gles2_begin(struct gles2_renderer *renderer, uint32_t width, uint32_t height) {
|
||||
glViewport(0, 0, width, height);
|
||||
renderer->viewport_width = width;
|
||||
renderer->viewport_height = height;
|
||||
static void gles2_begin(struct gles2_renderer *renderer, uint32_t width,
|
||||
uint32_t height) { glViewport(0, 0, width, height); renderer->viewport_width =
|
||||
width; renderer->viewport_height = height;
|
||||
|
||||
// refresh projection matrix
|
||||
wlr_matrix_projection(renderer->projection, width, height, WL_OUTPUT_TRANSFORM_NORMAL);
|
||||
// refresh projection matrix
|
||||
wlr_matrix_projection(renderer->projection, width, height,
|
||||
WL_OUTPUT_TRANSFORM_NORMAL);
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
static void gles2_clear(const float color[static 4]) {
|
||||
glClearColor(color[0], color[1], color[2], color[3]);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
static void gles2_scissor(struct wlr_box *box) {
|
||||
if (box) {
|
||||
glScissor(box->x, box->y, box->width, box->height);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
} else {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/************************
|
||||
Rendering Functions
|
||||
*************************/
|
||||
|
||||
/*
|
||||
static void gles2_render_rect(struct gles2_renderer *renderer, const struct wlr_box *box, const float color[static 4], const float projection[static 9]) {
|
||||
if (box->width == 0 || box->height == 0) {
|
||||
return;
|
||||
|
|
@ -310,3 +329,5 @@ static void gles2_render_rect(struct gles2_renderer *renderer, const struct wlr_
|
|||
|
||||
glDisableVertexAttribArray(renderer->shaders.quad.pos_attrib);
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend/drm.h>
|
||||
#include <wlr/backend/headless.h>
|
||||
#include <wlr/render/gles2.h> // TODO: remove if no egl needed to init custom renderer
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_buffer.h>
|
||||
#include <wlr/types/wlr_drm_lease_v1.h>
|
||||
|
|
@ -32,6 +33,8 @@
|
|||
#include "sway/tree/view.h"
|
||||
#include "sway/tree/workspace.h"
|
||||
|
||||
#include "sway/desktop/opengl.h"
|
||||
|
||||
struct sway_output *output_by_name_or_id(const char *name_or_id) {
|
||||
for (int i = 0; i < root->outputs->length; ++i) {
|
||||
struct sway_output *output = root->outputs->items[i];
|
||||
|
|
@ -841,6 +844,8 @@ static void handle_present(struct wl_listener *listener, void *data) {
|
|||
|
||||
static unsigned int last_headless_num = 0;
|
||||
|
||||
// TODO: rm comment
|
||||
// hyprland Monitors.cpp: listener_newOutput
|
||||
void handle_new_output(struct wl_listener *listener, void *data) {
|
||||
struct sway_server *server = wl_container_of(listener, server, new_output);
|
||||
struct wlr_output *wlr_output = data;
|
||||
|
|
@ -873,6 +878,14 @@ void handle_new_output(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO: move me to proper spot
|
||||
// TODO: reference wlroots render/wlr_renderer.c: wlr_renderer_autocreate
|
||||
struct wlr_egl *egl = wlr_gles2_renderer_get_egl(server->renderer);
|
||||
struct gles2_renderer *test = gles2_renderer_create(egl);
|
||||
if (!test) {
|
||||
printf("gles2_renderer is null");
|
||||
}
|
||||
|
||||
struct sway_output *output = output_create(wlr_output);
|
||||
if (!output) {
|
||||
return;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue