summaryrefslogtreecommitdiff
path: root/src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.cxx
blob: a8f1d07fcd4b89653365d8b9d423f87c840a960b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2018 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file.  If this
// file is missing or damaged, see the license at:
//
//     https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
//     https://www.fltk.org/bugs.php
//


#include "../../config_lib.h"
#include "Fl_PicoSDL_Graphics_Driver.H"

#include "Fl_PicoSDL_Screen_Driver.H"
#include <FL/platform.H>
#include "../../Fl_Window_Driver.H"

#include <FL/Fl.H>
#define __APPLE__
#include <SDL2/SDL.h>
#undef __APPLE__

extern Window fl_window;


/*
 By linking this module, the following static method will instantiate the
 PicoSDL Graphics driver as the main display driver.
 */
Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver()
{
  return new Fl_PicoSDL_Graphics_Driver();
}


void Fl_PicoSDL_Graphics_Driver::rectf(int x, int y, int w, int h)
{
  uchar r, g, b;
  Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
  SDL_SetRenderDrawColor((SDL_Renderer*)fl_window, r, g, b, SDL_ALPHA_OPAQUE);
  SDL_Rect rect = {x, y, w, h};
  SDL_RenderFillRect((SDL_Renderer*)fl_window, &rect);
}


void Fl_PicoSDL_Graphics_Driver::line(int x, int y, int x1, int y1)
{
  uchar r, g, b;
  Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
  SDL_SetRenderDrawColor((SDL_Renderer*)fl_window, r, g, b, SDL_ALPHA_OPAQUE);
  SDL_RenderDrawLine((SDL_Renderer*)fl_window, x, y, x1, y1);
}


void Fl_PicoSDL_Graphics_Driver::point(int x, int y)
{
  uchar r, g, b;
  Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
  SDL_SetRenderDrawColor((SDL_Renderer*)fl_window, r, g, b, SDL_ALPHA_OPAQUE);
  SDL_RenderDrawPoint((SDL_Renderer*)fl_window, x, y);
}