SDL rendering issue Odroid N2 at 4k

Post Reply
matteoraggi
Posts: 26
Joined: Thu Aug 17, 2017 1:28 am
languages_spoken: english
ODROIDs: going to buy multiple ODROID C2 with linux ubuntu 16 emmc
Has thanked: 2 times
Been thanked: 0
Contact:

SDL rendering issue Odroid N2 at 4k

Unread post by matteoraggi » Wed Jul 31, 2019 7:00 am

When rendering using SDL and SDL2 on the Odroid N2 at 4k HD (3840x2160) the display gets corrupted.
Here you can see the video with the issue: https://gofile.io/?c=pzas1f
Screenshot of the issue here: https://gofile.io/?c=CXvVoQ
I have tested the same code using C (PC), C++ (PC and Pi), Python(PC, Pi and Odroid), Perl 6 (PC), Perl 5 (PC, Pi, Odroid) and Rust... and everyone is working well, apart Odroid n2 with ubuntu 18.04 minimal that is always giving that issue...
I am using odroid n2 with Ubuntu 18.04.2 minimal
http://www.matteoraggi.com

User avatar
odroid
Site Admin
Posts: 31765
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 83 times
Been thanked: 241 times
Contact:

Re: SDL rendering issue Odroid N2 at 4k

Unread post by odroid » Wed Jul 31, 2019 10:43 am

Can you share a test code to reproduce the issue?
Did you use the pre-installed SDL 2 package in the minimal image?

User avatar
meveric
Posts: 10389
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2
Has thanked: 15 times
Been thanked: 117 times
Contact:

Re: SDL rendering issue Odroid N2 at 4k

Unread post by meveric » Wed Jul 31, 2019 3:30 pm

looks like the resolution of the SDL/SDL2 doesn't match the resolution of the display.
Means for example you run display on 4k but the SDL application runs on 640x480 or something like that.
In that case I've seen similar output on other systems multiple times already.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

matteoraggi
Posts: 26
Joined: Thu Aug 17, 2017 1:28 am
languages_spoken: english
ODROIDs: going to buy multiple ODROID C2 with linux ubuntu 16 emmc
Has thanked: 2 times
Been thanked: 0
Contact:

Re: SDL rendering issue Odroid N2 at 4k

Unread post by matteoraggi » Wed Jul 31, 2019 11:13 pm

Yes, I ma using the pre-installed SDL 2 package in the minimal ubuntu 18.04 image
Yes, I am using the default system version of SDL2
No, it is not the resolution, the resolution was set at 4k 3840x216

Here what the code should show (demo made on a pc xubuntu 18.04 using the same 4k monitor and code):
https://gofile.io/?c=ym6jII

here is the code:

Code: Select all

import pygame
from pygame.locals import KEYDOWN, K_ESCAPE, RLEACCEL

class Make_Countdown(pygame.sprite.DirtySprite):
    """
    xpos and ypos are the coords where the text will be centeres and printed. By defaault they are screen_centerx and screen_centery. If you leave posx = None and posy = None these values will be used. If you enter any values, those will be used.
    Font size need to be supplied along with the colour of text, lownum and hinum.
    Countdown = True by default. hinum -> lownum
    Countdown = False lownum -> hinum
    if a font is not supplied (path), the default pygame font will be used.
    Fading out is set by default.
    Time will hold each number on screen for that duration If fade is set that time will be used to fade out."""

    def __init__(self, posx = None, posy = None, colour = (255, 255, 255), number = 600, font = None, fontsize = 600, fade_speed = 5, countdown = True, fadeout = True):

        pygame.sprite.DirtySprite.__init__(self)

        self.screen = pygame.display.get_surface()

        if self.screen == None:
            print"none"
            self.screen =pygame.display.set_mode((3840, 2160), 1, 32)

        self.subsurface = self.screen.subsurface(0, 0, self.screen.get_width(), self.screen.get_height()).convert_alpha()
        self.back = self.screen
        self.background = (0, 0, 0)
        self.alpha = 255
        if posx == None:
            self.posx = 512
        else:
            self.posx = posx
        if posy == None:
            self.posy = 300
        else:
            self.posy = posy
        self.fontsize = fontsize
        self.colour = colour
        self.lownum = 1
        self.hinum = number
        self.font = font
        self.count_down = countdown
        self.fade = fadeout
        self.fade_speed = fade_speed
        self.imagelist = []

        self.renderedfont = pygame.font.Font(self.font, self.fontsize)

        for x in xrange(self.lownum, self.hinum + 1):  # we want to count hinum as well so + 1

            matext = self.renderedfont.render(str(x), True, self.colour, (0, 0, 0)).convert()

            matext.set_colorkey(0, RLEACCEL)

            matext.set_alpha(255)

            self.imagelist.append(matext)



    def run(self, variable):

        direction = variable

        if direction == "down":

            self.imagelist = reversed(self.imagelist)

        for image in self.imagelist:

            self.alpha = 255
            # the calculation below makes the sprite be printed by its center coord
            posx = self.posx - (image.get_width() / 2)
            posy = self.posy - (image.get_height() / 2)
            self.subsurface = self.screen.subsurface(posx, posy, image.get_width(), image.get_height()).convert_alpha()
            for x in xrange(50):

                self.alpha -= 5
                image.set_alpha(self.alpha)


                self.screen.blit(image, (posx, posy))

                pygame.display.update()
                pygame.time.wait(self.fade_speed)  # how long to pause
                self.screen.blit(self.subsurface, (posx, posy))

            for e in pygame.event.get():
                if e.type == KEYDOWN and e.key == K_ESCAPE:
                    raise SystemExit



if __name__ == '__main__':
    pygame.init()
    counter = Make_Countdown()
    # counter.run("up")
    counter.run("down")
I am using odroid n2 with Ubuntu 18.04.2 minimal
http://www.matteoraggi.com

User avatar
meveric
Posts: 10389
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2
Has thanked: 15 times
Been thanked: 117 times
Contact:

Re: SDL rendering issue Odroid N2 at 4k

Unread post by meveric » Thu Aug 01, 2019 1:59 am

Well you're using pygame not SDL / SDL2 directly, that's a huge difference already.

You try to get the display dimensions via pygame and only if it returns nothing, you set it explicitly as 3840x2160.
So in the case THAT something is returned you use that resolution, no matter what it finds.

You might want to add an output on what screen resolution is actually found and used, so you can use this as a debug reference.

I imagine your code probably runs fine under X11/Wayland but with a fbdev display this might behave very differently.
These users thanked the author meveric for the post:
matteoraggi (Thu Aug 01, 2019 6:39 am)
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 0 guests