{"action":"created","issue":{"url":"https://api.github.com/repos/tipam/pi3d/issues/188","labels_url":"https://api.github.com/repos/tipam/pi3d/issues/188/labels{/name}","comments_url":"https://api.github.com/repos/tipam/pi3d/issues/188/comments","events_url":"https://api.github.com/repos/tipam/pi3d/issues/188/events","html_url":"https://github.com/tipam/pi3d/pull/188","id":127633930,"number":188,"title":"Texture formats","user":{"login":"swehner","id":273236,"avatar_url":"https://avatars.githubusercontent.com/u/273236?v=3","gravatar_id":"","url":"https://api.github.com/users/swehner","html_url":"https://github.com/swehner","followers_url":"https://api.github.com/users/swehner/followers","following_url":"https://api.github.com/users/swehner/following{/other_user}","gists_url":"https://api.github.com/users/swehner/gists{/gist_id}","starred_url":"https://api.github.com/users/swehner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swehner/subscriptions","organizations_url":"https://api.github.com/users/swehner/orgs","repos_url":"https://api.github.com/users/swehner/repos","events_url":"https://api.github.com/users/swehner/events{/privacy}","received_events_url":"https://api.github.com/users/swehner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-01-20T08:59:35Z","updated_at":"2016-01-21T12:26:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/tipam/pi3d/pulls/188","html_url":"https://github.com/tipam/pi3d/pull/188","diff_url":"https://github.com/tipam/pi3d/pull/188.diff","patch_url":"https://github.com/tipam/pi3d/pull/188.patch"},"body":"Hi,\r\n\r\nThese'd the changes to support the different formats - right now it chooses the format depending on the array's format - this might not be optimal (and the code still needs some error checking), but it should work both for loading a PIL image or an array directly.\r\nAll formats have a different number of channels except GL_ALPHA and GL_LUMINANCE which can be chosen using i_format.\r\n\r\nBTW I've looked at the mipmapping part - and as it was right now memory was allocated for mipmaps even though the mipmap param was false (the filter method was set *after* loading the texture).\r\nI'd also like to add a separate param to choose between GL_NEAREST and GL_LINEAR independent of if mipmaps are used or not (but that's for another PR).\r\n\r\nThat's the example I'm using: https://github.com/swehner/pi3d_demos/blob/test-texture-formats/TFormats.py\r\n\r\nMemory usages on RaspberryPi with `/opt/vc/bin/vcdbg reloc` before the change (only 4 textures because the one with i_format=GL_ALPHA fails to load):\r\n```\r\n[  34] 0x1d324360: used 1.3M (refcount 2 lock count 1, size  1400832, align 4096, data 0x1d325000, d1rual) 'Texture blob'\r\n[  50] 0x1d47b380: used 1.3M (refcount 2 lock count 1, size  1400832, align 4096, data 0x1d47c000, d1rual) 'Texture blob'\r\n[  37] 0x1d5d23a0: used 1.3M (refcount 2 lock count 1, size  1400832, align 4096, data 0x1d5d3000, d1rual) 'Texture blob'\r\n[  31] 0x1d7293c0: used 1.3M (refcount 2 lock count 1, size  1400832, align 4096, data 0x1d72a000, d1rual) 'Texture blob'\r\n```\r\nMemory usages on RaspberryPi with the changes:\r\n```\r\n[  48] 0x1d57b340: used 516K (refcount 2 lock count 1, size   524288, align 4096, data 0x1d57c000, d1rual) 'Texture blob'\r\n[  45] 0x1d5fc360: used 1.0M (refcount 2 lock count 1, size  1048576, align 4096, data 0x1d5fd000, d1rual) 'Texture blob'\r\n[  36] 0x1d6fd380: used 260K (refcount 2 lock count 1, size   262144, align 4096, data 0x1d6fe000, d1rual) 'Texture blob'\r\n[  32] 0x1d73e3a0: used 1.0M (refcount 2 lock count 1, size  1048576, align 4096, data 0x1d73f000, d1rual) 'Texture blob'\r\n[  81] 0x1d83f3c0: used 260K (refcount 1 lock count 0, size   262144, align 4096, data 0x1d840000, d1rual) 'Texture blob'\r\n```\r\nAs you can see the allocated memory is a lot smaller - (according to number of channels except for the rgb image - maybe some memory alignment thing?) and also becaus no space for mipmaps is reserved.\r\n\r\nLet me know what you think!\r\nBefore merging I'd like to do some more error checking on the numpy array format.\r\nAlso do you think it's be with it to convert the image format if r_format is specifide - so e.g. if you set i_format to GL_LUMINANCE and feed in an RGBA image should it convert it to L or load it as GL_RGBA?\r\n"},"comment":{"url":"https://api.github.com/repos/tipam/pi3d/issues/comments/173556152","html_url":"https://github.com/tipam/pi3d/pull/188#issuecomment-173556152","issue_url":"https://api.github.com/repos/tipam/pi3d/issues/188","id":173556152,"user":{"login":"paddywwoof","id":1939398,"avatar_url":"https://avatars.githubusercontent.com/u/1939398?v=3","gravatar_id":"","url":"https://api.github.com/users/paddywwoof","html_url":"https://github.com/paddywwoof","followers_url":"https://api.github.com/users/paddywwoof/followers","following_url":"https://api.github.com/users/paddywwoof/following{/other_user}","gists_url":"https://api.github.com/users/paddywwoof/gists{/gist_id}","starred_url":"https://api.github.com/users/paddywwoof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paddywwoof/subscriptions","organizations_url":"https://api.github.com/users/paddywwoof/orgs","repos_url":"https://api.github.com/users/paddywwoof/repos","events_url":"https://api.github.com/users/paddywwoof/events{/privacy}","received_events_url":"https://api.github.com/users/paddywwoof/received_events","type":"User","site_admin":false},"created_at":"2016-01-21T12:26:07Z","updated_at":"2016-01-21T12:26:07Z","body":"Nice. I will add a version of that demo including mipmap=False, moving the Sprites backwards and forwards and changing the material colours. I have added a line to pi3d/shaders/std_main_uv.inc to allow 'tinting' with all the uv_ shaders\r\n    texc.rgb += unib[1] - vec3(0.5);\r\nI will check how much it effects frame rate but I suspect negligible, then push to origin develop."}}