Help with math

The Partridge Family were neither partridges nor a family. Discuss.
NaturalDemon
Posts: 97
Joined: October 28th, 2012, 8:28 pm

Re: Help with math

Post by NaturalDemon » September 8th, 2016, 2:35 am

albinopapa wrote:
NaturalDemon wrote:Hmmmm, if i remember correctly, you draw several hundreds of frames per second depending on your hardware.
But you only need max 60 Fps, i believe you see pixels from the previous frame drawn over the current frame.

You should build a state machine with a timer .... That updates a complete drawn frame instead of a partial frame to the gpu buffer once per 16 milisecond (ms). 1000 ms / 60 fps = 16.xxx ms

You only have 1 "backbuffer" and you keep updating those pixels while presenting to the gpu.
You could make a second buffer and alternate between them.
But you need a mechanism to slow down.
Yeah, if you are on the correct thread, the chili framework is already double-buffered, so the frames don't get updated until all is drawn to back buffer, so it's not an issue of seeing pixels from previous frames.
like i said, it has been a while, but i had those same issues back than.... but i did use several hundreds of threads, i did test with a 1000 threads, no performance issues, but clipping.

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Help with math

Post by LuisR14 » September 8th, 2016, 2:43 am

erm, was referring to "forum thread" haha xD (not sure if albinopapa was referring to same thing), tho if you're referring to the kind of clipping that would be called "screen tearing" then he would have to turn on DX's vsync
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Help with math

Post by albinopapa » September 8th, 2016, 4:06 am

vsync is accomplished in DX 11 by the IDXGISwapchain::Present function

Code: Select all

HRESULT Present(
   UINT SyncInterval,               // <- 0 to disable vsync, 1-4 to enable
   UINT Flags
);
it is set to 1 in the framework, so it does have vsync enabled.

And yeah, I was talking about forum threads not CPU threads,.... and how many threads did you have running?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Help with math

Post by chili » September 8th, 2016, 4:08 am

NaturalDemon wrote:
albinopapa wrote:
NaturalDemon wrote:Hmmmm, if i remember correctly, you draw several hundreds of frames per second depending on your hardware.
But you only need max 60 Fps, i believe you see pixels from the previous frame drawn over the current frame.

You should build a state machine with a timer .... That updates a complete drawn frame instead of a partial frame to the gpu buffer once per 16 milisecond (ms). 1000 ms / 60 fps = 16.xxx ms

You only have 1 "backbuffer" and you keep updating those pixels while presenting to the gpu.
You could make a second buffer and alternate between them.
But you need a mechanism to slow down.
Yeah, if you are on the correct thread, the chili framework is already double-buffered, so the frames don't get updated until all is drawn to back buffer, so it's not an issue of seeing pixels from previous frames.
like i said, it has been a while, but i had those same issues back than.... but i did use several hundreds of threads, i did test with a 1000 threads, no performance issues, but clipping.
You are a wild man NaturalDemon.
Chili

egizz983
Posts: 311
Joined: August 27th, 2016, 12:30 pm

Re: Help with math

Post by egizz983 » September 8th, 2016, 8:13 am

Image
result on image with a code below

Code: Select all

for (int a = 0; a < heigth; a++) {
		for (int b = 0; b < width; b++) {
			PutPixel((x+width) - b, (y+heigth) - a, image[b + a * width].GetR(), image[b + a * width].GetG(), image[b + a * width].GetB());
			PutPixel(x, y, 255, 0, 0);
		}
	}
and then depends on xoff,yoff position i will recude height

Code: Select all

if (bullets[a].y <= 0) {//if at the edge draw backwards
	       bullets[a].height -= bullets[a].speed;
	       bullets[a].y+= bullets[a].speed;
               gfx.DrawSpriteBackW(bullets[a].x, bullets[a].y, bullets[a].width, bullets[a].height, Novalvl1, 0, 0, 0);
	}else{ // if not at the edge draw normal
		gfx.DrawSprite(bullets[a].x, bullets[a].y, bullets[a].width, bullets[a].height, Novalvl1, 0, 0, 0);
}
how its looks like now :
https://youtu.be/ePiNun8kIQ0

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Help with math

Post by albinopapa » September 8th, 2016, 9:05 am

Just out of curiosity, why are you wanting to flip the image when the bullet gets to top of screen?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

egizz983
Posts: 311
Joined: August 27th, 2016, 12:30 pm

Re: Help with math

Post by egizz983 » September 8th, 2016, 9:16 am

albinopapa wrote:Just out of curiosity, why are you wanting to flip the image when the bullet gets to top of screen?
imagine this , bullets goes y-- , and meteors goes y++ meteors draw backwards and bullets normal , so i can detect collision easily later , and if its bullet wont hit anything and reach edge then just collapse , at least i think so :D , of course i will need sprite collision so that might be not that important later , and will be easy to change , i am not sure yet i mean how i will deal with that

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Help with math

Post by LuisR14 » September 8th, 2016, 9:20 am

heh, might wanna read my previous post (b4 my last post xD)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

egizz983
Posts: 311
Joined: August 27th, 2016, 12:30 pm

Re: Help with math

Post by egizz983 » September 8th, 2016, 1:43 pm

sorr for being stupid solved :

Code: Select all

        int cc = (width * heigth) - 1;
	for (int a = 0; a < heigth; a++) {
		for (int b = 0; b < width; b++) {
			PutPixel(x - b, y - a, image[cc].GetR(), image[cc].GetG(), image[cc].GetB());
			PutPixel(x, y, 255, 0, 0);
			cc--;
		}
	}

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Help with math

Post by LuisR14 » September 8th, 2016, 7:20 pm

hmm, flipping verticly and horizontly? all you needed was to flip verticly in this case xD

Code: Select all

        int cc = (width * heigth) - 1;
   for (int a = 0; a < heigth; a++) {
      for (int b = 0; b < width; b++) {
         int offset = a + (height - b) * width;
         PutPixel(x, y - a, image[offset].GetR(), image[offset].GetG(), image[offset].GetB());
      }
   }
hmm, what's the point of this line tho?

Code: Select all

         PutPixel(x, y, 255, 0, 0);
don't think you have to 'overwrite' the previous location (it would've most likely been erased cuz of screen clearing)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

Post Reply