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
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
5155DECL_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
8389int 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 ]) {
0 commit comments