Skip to content

Commit 84de113

Browse files
committed
Use libvideo-driver for gfx(1)
1 parent 8f66e6b commit 84de113

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

kos/src/apps/.sources

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ DEFINE_SIMPLE_C_APPLICATION("keymap", USELIB("libkeymap"))
4141
DEFINE_SIMPLE_C_APPLICATION("getconf")
4242
DEFINE_SIMPLE_C_APPLICATION("snake")
4343
DEFINE_SIMPLE_C_APPLICATION("vconf")
44-
DEFINE_SIMPLE_CXX_APPLICATION("gfx", USELIB("libvideo-gfx"))
44+
DEFINE_SIMPLE_CXX_APPLICATION("gfx", USELIB("libvideo-driver") USELIB("libvideo-gfx"))
4545
DEFINE_SIMPLE_C_APPLICATION("showpic",
4646
USELIB("libvideo-driver")
4747
USELIB("libvideo-gfx")

kos/src/apps/gfx/main.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define _GNU_SOURCE 1
2323
#define _KOS_SOURCE 1
2424
#define LIBVIDEO_GFX_WANT_PROTOTYPES
25+
#define LIBVIDEO_DRIVER_WANT_PROTOTYPES
2526

2627
#include <hybrid/compiler.h>
2728

@@ -42,14 +43,19 @@
4243
#include <unistd.h>
4344

4445
#include <libvideo/color.h>
46+
#include <libvideo/driver/adapter.h>
47+
#include <libvideo/driver/monitor.h>
4548
#include <libvideo/gfx/buffer.h>
4649
#include <libvideo/gfx/font.h>
4750
#include <libvideo/gfx/gfx.h>
4851
#include <libvideo/gfx/screen.h>
4952
#include <libvideo/gfx/surface.h>
53+
#include <libvideo/rect.h>
5054

5155
DECL_BEGIN
5256

57+
static struct video_rect const RECT_FULL = VIDEO_RECT_INIT_FULL;
58+
5359
#if 1
5460
#define rand_color() \
5561
VIDEO_COLOR_RGBA(rand() % 256, rand() % 256, rand() % 256, rand() % 256)
@@ -82,7 +88,9 @@ PRIVATE void enable_rawtty_mode(void) {
8288

8389
int main(int argc, char *argv[]) {
8490
bool is_blocking = false;
85-
REF struct screen_buffer *screen;
91+
REF struct video_adapter *adapter;
92+
REF struct video_monitor *monitor;
93+
REF struct video_buffer *screen;
8694
REF struct video_font *font;
8795
struct video_fontprinter_data fontprinter_data;
8896
struct video_gfx gfx;
@@ -92,10 +100,17 @@ int main(int argc, char *argv[]) {
92100

93101
enable_rawtty_mode();
94102

95-
/* Bind the screen buffer. */
96-
screen = screen_buffer_create(NULL);
103+
/* Load default video adapter and monitor */
104+
adapter = video_adapter_open(NULL);
105+
if (!adapter)
106+
err(EXIT_FAILURE, "Failed to open video adapter");
107+
monitor = video_adapter_getmonitor(adapter, 0);
108+
if (!monitor)
109+
err(EXIT_FAILURE, "Failed to access monitor with id=0");
110+
screen = video_monitor_getbuffer(monitor);
97111
if (!screen)
98-
err(EXIT_FAILURE, "Failed to load screen buffer");
112+
err(EXIT_FAILURE, "Failed to get screen buffer");
113+
99114
video_buffer_getgfx(screen, &gfx, GFX_BLENDMODE_ALPHA);
100115

101116
/* Load the video-mode font. */
@@ -164,7 +179,7 @@ int main(int argc, char *argv[]) {
164179

165180
for (;;) {
166181
char buf[1];
167-
screen->updaterect();
182+
video_monitor_updaterect(monitor, &RECT_FULL);
168183
if (read(STDIN_FILENO, buf, 1) < 1)
169184
break;
170185
if (buf[0] == '+') {
@@ -199,7 +214,7 @@ int main(int argc, char *argv[]) {
199214
ssize_t error;
200215
char buf[1];
201216
video_color_t color;
202-
screen->updaterect();
217+
video_monitor_updaterect(monitor, &RECT_FULL);
203218
error = read(STDIN_FILENO, buf, 1);
204219
if (error == 1) {
205220
switch (buf[0]) {

kos/src/apps/showpic/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ int main(int argc, char *argv[]) {
553553
return 1;
554554
}
555555

556-
/* Bind the screen buffer. */
556+
/* Load default video adapter and monitor */
557557
adapter = video_adapter_open(NULL);
558558
if (!adapter)
559559
err(EXIT_FAILURE, "Failed to open video adapter");

0 commit comments

Comments
 (0)