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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - LakySimi1

Pages: [1] 2 3
1
Window / Re: How to properly draw multiple RenderTexture ?
« on: July 30, 2024, 07:50:22 pm »
I have updated the code in the OP.

Exactly, i want different offscreen surfaces where to draw (in my case the RenderTexture_Two is a simple grid that i want to overlap to the RenderTexture_One, to check the allignment and position of things..) and then combine them on screen.

The fact is that the grid is always the same therefore there is no benefit in redrawing it from scratch every frame, i prerender it on the RenderTexture_Two and than use it when needed.

I can simply use a .png with transparency to draw any overlapping image, without any calculation since is an image... but handle it directly in-code, since i think of a simple game, can make things more manageble than have to pass from Gimp.

2
Window / How to properly draw multiple RenderTexture ?
« on: July 29, 2024, 10:09:02 pm »
Hi Everyone,

i'm trying to have two separate RenderTexture, one is the game and the other is a simple grid which, as it is coded, is very slow.

Therefore i want to draw on a separate RenderTexture just one time, and then show it on screen when needed, avoiding any redundant calculation.

I've managed to draw both RenderTexture but when i clear the first one it does not render the second one anymore, here the related code:

(click to show/hide)

Thank you very much in advance!

3
Thank you very much! I've achieved the goal! :D (a bit of thanks also to ChatGPT :P)

Here an example of output, the rectangle rotated to confirm that it does not elaborate in high resolution, as my original code:
(click to show/hide)

Here the code used for the image above, directly implementable:
(click to show/hide)

4
Hi Everyone,

i'm doing my little retro-rpg, with a pixelated low resolution, of course i want it to render, with those big pixels, on higher modern resolution screen.

The method i am using is the following, i do refer to first part of code:
(click to show/hide)

The problem is that drawing lines does not match up with the goals, in fact the following code draws a line of 1 pixel thickness.. how should i proceed?

Line code:
(click to show/hide)

Results:
(click to show/hide)

5
Window / Re: Can draw tiles outside the window cause problems?
« on: July 04, 2024, 02:48:38 pm »
Thank you eXpl0it3e for the direct answer and advices!  :D

6
Window / [SOLVED] Can draw tiles outside the window cause problems?
« on: July 04, 2024, 09:32:22 am »
Hi everyone,

for my 2D game, to properly draw the world (isometric) and have a smooth panning of world view, it is needed to draw  the sprites that forms the world, walls, enemies etc, partially or completely (keeps things easier) outside the window: can this couse problems/error?

Let's imagine the worst case scenario in wich the sprites are drawed quite far from the window borders, as example at the same window width of distance from them.

Thank you very much in advance!

7
Graphics / Re: Tile-based graphic using Sprites.. right?
« on: May 12, 2024, 10:22:53 pm »
Thank you very much for the resources!

8
Graphics / Re: Tile-based graphic using Sprites.. right?
« on: May 08, 2024, 09:20:47 pm »
I think yes but i didn't use "isometric" since is perspective-related and not necessarily tile-related.

Thank you! Searching online i've found this https://www.sfml-dev.org/tutorials/2.4/graphics-vertex-array.php , i think is exctly what i was looking for probably, rigt?

9
Graphics / Tile-based graphic using Sprites.. right?
« on: May 06, 2024, 07:13:07 pm »
Hi everyone,
assuming that i want to make a 2D tile-based game, such as Avadon or Fallout 1/2, in which roofs can disappear to let look inside buildings (like Fallout 1/2), or in which different tiles get darkened depending if they are visible or not to player (like Avadon) (for example), is it right to use Sprites for substantially everyting?

for(each tile to show)
{
    Sprite.setTextureRect(sf::IntRect(x,y,z,k));    //Get tile
    Sprite.setPosition(sf::Vector2f(i.f,j.f));      //Draw coordinates
    Sprite.setColor(sf::Color(255, 255, 255));      //Light
    window.draw(Sprite);                            //Render
}



Avadon
(click to show/hide)
Fallout
(click to show/hide)

10
I made a gross mistake.. Hapax was right

11
General / Re: Pass int/char array to sf::Uint8 array?
« on: April 21, 2024, 03:53:11 pm »
Thank you, i confirm, reducing sizes make it work..

i was trying to make faster the process of writing in pixels accessing it only 1 time, but it seems to not help, even if i do

for (int i = 0; i < 1280 * 720 * 4; i++)
    pixels[i] = 42;

I don't have an increase in performance(/fps)

12
General / Re: Pass int/char array to sf::Uint8 array?
« on: April 21, 2024, 01:46:20 pm »
Good, thanks!

My code does not work due to the following:

char* pixels = new char [1280 * 720 * 4];
char Array [1280 * 720 * 4];

for (int i = 0; i < 1280 * 720 * 4; i++)
    Array[i] = 42;

for (int i = 0; i < 1280 * 720 * 4; i++)
    pixels[i] = Array[i]; // <- does not work, if i change "Array[i]" with a number, such as "42", it does work.
 

13
General / Pass int/char array to sf::Uint8 array?
« on: April 19, 2024, 11:52:48 pm »
Hi everyone,
there is a way to pass an int or maybe better, a char array to sf::Uint8* pixels = new sf::Uint8[WIDTH * HEIGHT * 4] ?

Honestly, i'm ignorant, i want to build the array of pixels in a classic int array, which is faster to manipulate, and then show it on screen.

Right now instead i am manipulating pixels.

14
I also want to make some raytracing experiment but, since the infinitely less complex raycasting is so slow on a 4GHz machine, and it may really means that the pixel-per-pixel approach is wrong, i give it up.. sadly.
I'll share a screenshot of my raycasting engine here:
(click to show/hide)

Multithreading may be an aid, but not a solution i think, since og Doom run flawlessy on a 100MHz 486.. how the heck does it achieve that? Surely it is also GPU based but still, i think it has a lot to do with single pixel drawing.. right?
I kinda know that i have to use the parallel computing o f the GPU.. but how? The only tutorial i find online seems to have the same approach of mine: fill and array and send it to graphic memory.

Compute shaders are totally new to me.. got to search!

15
A quick calculation shows 1280 x 720 x 250fps means each pixel has only 4ns to be rendered.
Considering a single cpu cycle on a 4GHz cpu is 0.25ns, there's not much head room.

This calculation really makes sense to me, 17.4 cycles per pixel, this perspective help to understand.

Therefore, is a bad news, since i really like to draw pixel-per-pixel, maybe it is even foundamental for a raycasting engine.. any suggestion to achieve the single-pixel draw flexibility?

Pages: [1] 2 3