shinyblink / sled

Satanic/Sexy/Stupid/Silly/Shiny LED matrix controller
https://shinyblink.github.io/sled/
ISC License
122 stars 25 forks source link

flt_scale and out_sdl2 do not work together #7

Closed marenz2569 closed 6 years ago

marenz2569 commented 6 years ago

The problem is that out_sdl2 refers to getx() and gety() without knowing if they are really calling the function of this shared library. This results in scaled up matrices, but out_sdl2 only shows a part in the top left corner. Every module must call its own functions like this:

module *this = NULL;

int init(int modno, char *argstr) {
  // this cannot fail, no error parsing is required
  // if this would fail something is seriously wrong
  this = modules_get(modno);

  // and so one
}

int getx(void) {
  return MATRIX_X;
}

int set(int x, int y, RGB *color) {
  if (x<0 || y<0)
    return 1;
  if (x >= this->getx() || y >= this->gety())
    return 2;

  // and so one
}

this->getx() is only getx() in the current version.

Furthermore asserts should be avoided as these will cause people writing animations reimplementing said behaviour of the function int set(...) over and over.

marenz2569 commented 6 years ago

This issue could exist in other output modules than out_sdl2 too.