Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: PXL8  (Read 3970 times)

0 Members and 1 Guest are viewing this topic.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
PXL8
« on: July 19, 2014, 12:08:10 am »
PXL8 - a pixelated render target.

I wanted a simple and generic way to pixelate SFML output so I created PXL8.

You're welcome to use it as much as you like - in projects, studying - and feel free to suggest better ways of writing the code, features that it should have, or any bugs that I have missed.

You can use views with it and draw to it like a normal render target. It supplies you with its pixelated render as a standard sprite, ready to draw to your window as normal.

You can specify the size of the pixel - it does so in each frame in the example provided - by both dimensions (width and height) separately, if you desire.

I'd show you an image with a screenshot but I think you all know what pixelation looks like  ;)

Let me know what you think and I'd like to see projects that are making some use of this :)
I'm providing only source code - no builds - so you will need to compile it yourself, either within your projects or separately. If you do use it, I'd love some credit but you're not required to do so  ;D

Here is the PXL8 GitHub repository.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: PXL8
« Reply #1 on: July 19, 2014, 12:13:25 am »
Why not just use a shader?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: PXL8
« Reply #2 on: July 19, 2014, 12:14:34 am »
Why not just use a shader?
Because I have absolutely no idea how to.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: PXL8
« Reply #3 on: July 19, 2014, 12:31:55 am »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: PXL8
« Reply #4 on: July 19, 2014, 12:34:55 am »
Sorry and thanks, but I should expand...
Because I have absolutely no idea how to use shaders  :P
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

dwarfman78

  • Full Member
  • ***
  • Posts: 228
  • I'm bietzsche, Nietzsche !
    • MSN Messenger - cd4c@hotmail.com
    • View Profile
    • Email
Re: PXL8
« Reply #5 on: July 19, 2014, 07:50:27 am »
i did use this shader for my game menu (on the background) :



All sources are available at my github here : https://github.com/dwarfman78?tab=repositories
@dwarfman78
github.com/dwarfman78

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: PXL8
« Reply #6 on: July 19, 2014, 08:21:30 am »
Quote
Because I have absolutely no idea how to use shaders
Fortunately the "pixelate.frag" shader is part of a complete example :P
Laurent Gomila - SFML developer

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: PXL8
« Reply #7 on: July 19, 2014, 03:07:58 pm »
Shaders are beyond me just now. I think that when I move on to trying to understand OpenGL, I'll start with the pixelate shader  ;D

I must admit though, this "project" helped me to learn a few things. I think it's the first time I've used a RenderTexture...
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: PXL8
« Reply #8 on: July 19, 2014, 04:43:02 pm »
GLSL shaders are totally separate from OpenGL.  I've used the former with some success through SFML even though I've never gotten around to learning OpenGL properly.  Since there are official SFML examples with shaders, and GLSL is a very simple C-like language, it should only take a day of fiddling with the example and reading a tutorial somewhere to get comfortable with writing your own shaders.  Don't be scared of them.  The only real PITA with shaders is you can't printf() or set breakpoints in them (at least not without special OpenGL debugging tools...right?), so you need to be slow and paranoid when developing them.