Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Graphics acting up

in Bugs Posts: 237

I’m currently working on a game that I’ve almost finished, and when I start the program, it works fine and graphics look great, but give it some time and the text will start to get a little bit fuzzy, and some sprite have 1-pixel width lines at some points for no reason. Idk if I’m the one experiencing this issue, any advice would help :)

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 7,553

    Do you have background(some color) at the start of the draw routine.

  • edited February 15 Posts: 237

    Yeah, at first I thought it might be because there’s no alpha in the back, but I draw a background at the beginning of the main draw() function and at the beginning of each draw function in each scene. And smooth() doesn’t seem to fix anything, so that’s not the issue either

  • dave1707dave1707 Mod
    edited February 15 Posts: 7,553

    Would you by any chance be using backingMode(RETAINED). I can’t think of anything that would fuzz the text unless the display isn’t being cleared each draw cycle.

  • dave1707dave1707 Mod
    edited February 15 Posts: 7,553

    @CamelCoder Is it possible that you’re displaying the same text and sprites multiple times per draw cycle. The longer the program runs, the more they’re being displayed in the same draw cycle.

    Are you seeing something like this. Move the slider to the right.

    function setup()
        parameter.integer("nbr",1,50,1)
        fill(255)
    end
    
    function draw()
        background(40, 40, 50)    
        for z=1,nbr do
            text("qwertyuiop",WIDTH/2,HEIGHT/2)
            sprite("Planet Cute:Gem Orange",WIDTH/2,HEIGHT/4)
        end
    end
    
  • Posts: 237

    @dave1707 yes, that is exactly what is occurring, to the text at least. The sprites I draw are working fine. The problem is that i just did another sweep of my code and I'm only drawing the text once per frame. backingMode(RETAINED) only makes a difference if the background is even the least bit transparent. That being said, I still tried out backingMode(STANDARD) and that didn't make a difference. As a last resort I even attempted collectGarbage() but as expected, it didn't do anything. But the example you gave above is a great visual of what is happening to my text. But as you probably noticed, it is hard to notice unless you actually focus on it

  • dave1707dave1707 Mod
    Posts: 7,553

    @CamelCoder Are you using a different font. If you are, maybe the font just looks fuzzy. Can you take a screen snapshot and post what the text looks like. The only thing that I can think of that would cause fuzzy text is background() not being called, but you said you’re doing that. I’ll have to try other things.

  • dave1707dave1707 Mod
    Posts: 7,553

    @CamelCoder Is the fuzzy text in a function that might be getting called from multiple places per draw cycle.

  • Posts: 237

    @dave1707 The text is being drawn in the scene’s draw function, which is only called once. I attached two files that are pictures of the texts before and after, and they are only some 15 seconds apart from each other

  • SimeonSimeon Admin Mod
    Posts: 4,927

    @CamelCoder that really looks like the effect which occurs when you overlay the same antialiased shape on top of itself many times.

    Is there anything else you can tell us about how the text is drawn? Is it going into an image with setContext() first?

  • dave1707dave1707 Mod
    Posts: 7,553

    @CamelCoder The next thing to do is copy your code and start block commenting the code until you find the code that’s causing the problem.

  • Posts: 237

    @Simeon @dave1707 that’s what I thought, so I looked through all my code and couldn’t find any way it could be being drawn in layers, and I even drew a red rect right under it immediately before drawing the text and the same thing happened. Also there are no setContext()s in my code.

  • dave1707dave1707 Mod
    Posts: 7,553

    @CamelCoder Can you post your code or is it too big. As I said above, start commenting out chunks of code until the problem goes away. I’m curious what is causing the problem.

  • Posts: 237

    @dave1707 it’s currently part of a game that I’m working on and the file is somewhat large, I’m going to see if I can play around and figure it out, but if I can’t ill send some of the code. Thanks for all the suggestions so far

  • dave1707dave1707 Mod
    Posts: 7,553

    @CamelCoder Hope you can find the cause. If you can’t, you can send the code to me and I’ll figure it out. I like debugging code. I’m sure @Simeon would like to know the cause also.

  • Posts: 237

    @dave1707 all I did was make the class more efficient by simplifying the code and separating similar code into functions and classes and now it’s not glitching anymore lol. Thank you for all the help

  • dave1707dave1707 Mod
    Posts: 7,553

    @CamelCoder Glad to read you fix it. Still curious what was happening. I still think you were displaying the text multiple times per draw cycle.

  • Posts: 237

    @dave1707 I'm also confused still, because I didn't even touch the text drawing functions. I think what the problem was that when I was transitioning scene, I did a fade in fade out kinda thing, so I had a transparent rect drawn over the scene the whole time, and when I wanted to change scenes I'd increase the alpha. I removed that and made a transition class to simplify the code, and all of a sudden it stopped glitching, so I'm pretty sure that was the golden fix

  • dave1707dave1707 Mod
    Posts: 7,553

    @CamelCoder Thanks, that sounds like something that could cause it. I never thought of doing anything like that.

Sign In or Register to comment.