Problems with FX2D

I have some problems with FX2D.

It's a great renderer and its snapy as hell but some functions won't work.

The biggest problem I have is that 'smooth' and 'noSmooth' hase no effect.

In my code I scale an image for the background, it's for a 8 bit style game, but because of the anti aliasing it looks like shit.

Also it seems like the mouseWheel function doesn't works, thats weard to.

Has any body found a work around for theese problems?

It would be nice to be able to use FX2D for that because the framerate compared to the other renderers is just impressiv.

Answers

  • edited January 2018

    That did not work... Thats better:

        PImage floor;
        float xOffset;
        float yOffset;
        int sm = 10;
        boolean pressed = false;
        void setup() {
          noSmooth();
          fullScreen(FX2D);
          floor = loadImage( "-16x16 image here-");
          imageMode(CENTER);
          frameRate(1000);
    
        }
        void draw() {
          background(0);
          for(int y = -floor.height * sm; y < height + (floor.height * 2) * sm; y = y + floor.height * sm) {
            new drawThread(int(-floor.width * sm + xOffset), int(y + yOffset), int(width + (2 * floor.width * sm) + xOffset), sm).start();
          }
          println(frameRate);
          if(pressed) {
            xOffset = xOffset + ((mouseX) - (pmouseX));
            yOffset = yOffset + ((mouseY) - (pmouseY));
            if(xOffset > floor.width * sm) {
              xOffset = 0;
            }
            if(xOffset < -floor.width * sm) {
              xOffset = 0;
            }
            if(yOffset > floor.height * sm) {
              yOffset = 0;
            }
            if(yOffset < -floor.height * sm) {
              yOffset = 0;
            }
          }
        }
    
        class drawThread extends Thread {
          int sx;
          int sy;
          int ex;
          int sm;
    
          public drawThread(int sx, int sy, int ex, int sm) {
            for(int x = sx; x < ex; x = x + floor.width * sm) {
              image(floor, x, sy, floor.height * sm, floor.width * sm);
            }
          }
        }
    
        void mousePressed() {
          pressed = true;
        }
        void mouseReleased() {
          pressed = false;
        }
    
  • edited January 2018

    Drawing things outside the standard draw thread is usually a bad idea

  • edited January 2018

    With the default renderer it works but it is thery slow and the 'drawThread' gets called from the draw as a separate thread to improve performance, in theory....

  • How big is the screen?

  • edited January 2018

    if you have a 16x16 images and always print it at 10 x the size, and hate the bicubic interpolation then maybe make your image 160x160 and don't scale.

    and why call background() if you go on to tile the entire screen?

    with P2D you can call

    ((PGraphicsOpenGL)g).textureSampling(3);
    

    and that'll force linear scaling on the image.

  • edited January 2018

    I have allready made about 50 textures. I know that you can do it that way but it doesn't work with fx2d and p2d is to slow. Maybe I can Try to virtually display the images and then read every Pixel and copy it multiple times in a return image that would be scaled to the start image by a integer factor..... Would be slow to..... Damm

  • It doesn't work because fx2d is not based on open gl but still uses the gpu for that stuff. It isn't blooded like opengl. The code sniped you posted controlles opengl...

  • seems like you've already decided on fx2d

    but with opengl you could do that tiling (with linear scaling) with one quad (using non-unit texture coords), and not have to loop at all.

    my laptop reports 900 fps with the above code using opengl. this is probably enough for anyone. (that said, i don't trust the fps reporting with the threading going on. it's reporting figures above 1000 for fx2d despite you capping it at 1000)

  • Possibly related? There is currently an open issue on noSmooth() for P2D as well:

  • It reported about 900 fps to me to but it is not even near that. Restarting the code sometimes gives about 40 fps. That seems to be pretty accurate because of the obvious stuttering when scrolling through the tiles. Im not shure what you mean with quads. I usually don't use opengl much because I often use Java 2d for easy 2d stuff

Sign In or Register to comment.