
part: - remove mlx3ds_3dskey.h, instead use hid.h - add definitions of: - mlx_init() - mlx_new_window() - mlx_clear_window() - mlx_destroy_window() - mlx_pixel_put() - mlx_new_image() - mlx_get_data_addr() - mlx_put_image_to_window() - mlx_destroy_image() dev: - Makefile: add rule check_headers - Makefile: add variable FLAGS (call 'make rule FLAGS=flags' to add flags to compilation) - add /dev/norm.sh: nicer norminette - add tester in main(), and related utilsconsole.* docs: - make clear mlx_get_data_addr() docs
52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
/**
|
|
* mlx_window.c
|
|
* for the project "MinilibX for 3DS"
|
|
* by Zy
|
|
* at https://github.com/frzysk/mlx3ds
|
|
*/
|
|
|
|
#include "mlx_window.h"
|
|
|
|
#include "3ds.h"
|
|
#include "mlx_internal.h"
|
|
#include <stdlib.h>
|
|
|
|
t_win mlx_new_window(t_mlx mlx_ptr, int size_x, int size_y, const char *title)
|
|
{
|
|
t_internal_win *r;
|
|
|
|
(void)title;
|
|
if (size_x > GSP_SCREEN_HEIGHT_TOP || size_y > GSP_SCREEN_WIDTH)
|
|
mlx3ds_internal_fatalerror("Window too big for the screen");
|
|
r = malloc(sizeof(t_internal_win));
|
|
if (!r)
|
|
return (NULL);
|
|
r->mlx = mlx_ptr;
|
|
r->width = size_x;
|
|
r->height = size_y;
|
|
r->framebuffer = NULL;
|
|
return (r);
|
|
}
|
|
|
|
int mlx_clear_window(t_mlx mlx_ptr, t_win win_ptr)
|
|
{
|
|
u8 *frame_i;
|
|
u8 *frame;
|
|
|
|
mlx3ds_internal_drawstart(mlx_ptr, win_ptr);
|
|
frame = ((t_internal_win *)win_ptr)->framebuffer;
|
|
frame_i = frame
|
|
+ 3 * ((t_internal_win *)win_ptr)->framebuffer_width
|
|
* ((t_internal_win *)win_ptr)->framebuffer_height;
|
|
while (--frame_i >= frame)
|
|
*frame_i = 0x00;
|
|
mlx3ds_internal_drawend(mlx_ptr, win_ptr);
|
|
return (0);
|
|
}
|
|
|
|
int mlx_destroy_window(t_mlx mlx_ptr, t_win win_ptr)
|
|
{
|
|
((t_internal_mlx *)mlx_ptr)->top_window = NULL;
|
|
free(win_ptr);
|
|
return (0);
|
|
}
|