huh?

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

huh?

Post by NaturalDemon » November 16th, 2012, 10:29 pm

i finaly have 100% mouse control without using clipcursor function.
as you can see, i dragged the mouse on the Y axis and crosses the border ...
but! ... i have the correct value of 599.

i"m using the references of the window size variables of X and Y from the windows class.
So every class, has the same value

Code: Select all

800 x 600
i substract 1 every where the X or Y values are needed, i skipped none because find/replace.

what is happening?
Attachments
huh.png
what is happening?
(350.96 KiB) Downloaded 120 times

indus
Posts: 35
Joined: November 7th, 2012, 12:35 am

Re: huh?

Post by indus » November 17th, 2012, 1:53 pm

Imagine you have screen width of 10 pixels and screen height of 5 pixels. So you have an array pSysBuffer[50]


0 1 2 3 4 5 6 7 8 9
* * * * * * * * * * 0
* * * * * * * * * * 1
* * * * * * * * * * 2
* * * * * * * * * * 3
* * * 0 * * * * * * 4

Now you want to draw pixel on the position marked with 0, which has coordinates x = 3 , and y = 4.
So you call your PutPixel(3, 4, r, g, b) and it runs the line of code
pSysBuffer[ 3 + ( 10 - 1) * 4 ] = D3DCOLOR_XRGB( r,g,b )
which means you access pSysBuffer at position 39 but the actual position of the pixel in the array is 43.

NaturalDemon
Posts: 97
Joined: October 28th, 2012, 8:28 pm

Re: huh?

Post by NaturalDemon » November 17th, 2012, 11:33 pm

indus wrote:Imagine you have screen width of 10 pixels and screen height of 5 pixels. So you have an array pSysBuffer[50]


0 1 2 3 4 5 6 7 8 9
* * * * * * * * * * 0
* * * * * * * * * * 1
* * * * * * * * * * 2
* * * * * * * * * * 3
* * * 0 * * * * * * 4

Now you want to draw pixel on the position marked with 0, which has coordinates x = 3 , and y = 4.
So you call your PutPixel(3, 4, r, g, b) and it runs the line of code
pSysBuffer[ 3 + ( 10 - 1) * 4 ] = D3DCOLOR_XRGB( r,g,b )
which means you access pSysBuffer at position 39 but the actual position of the pixel in the array is 43.

i might cause the problem myself.
I'm experimenting with threads.
although each thread sleeps for 100 milliseconds.

the error also happens even not moving the mouse.


i"m selftaught programmer and C++ is serious stuff compared C#
and just yeasterday learned about consumer ... programmer aprouch.

i believe my problem is thread sync ...

I need a althernative solution ... to return a D3DCOLOR object and drop it on the Buffer ..... outside of the frame render function.

but than again, thank you for reminding about the Buffer and how it"s build up.
and you might laugh.
i was thinking about it tonight .. just before and ...
the conclusing was ... designing games ... is basicly a optical ilusion
: )
i was thinking about some test logic around that.
a game should never crash ... and deal with faulthy data.

Code: Select all

void D3DGraphics::PutPixel( int x,int y,int r,int g,int b )
{	
	assert( x >= 0 );
	assert( y >= 0 );
	assert( x <= (winSizeX -1)); // -1?
	assert( y <= (winSizeY -1)); // -1?
	try
	{
		pSysBuffer[ x + (winSizeX -1) * y ] = D3DCOLOR_XRGB( r,g,b );

	}
	catch(int e)
	{

	}	
}
a try catch doesn't avoid the faulty data bug.


but anyway ... i like your brief and very visual visaul explication.

NaturalDemon
Posts: 97
Joined: October 28th, 2012, 8:28 pm

Re: huh?

Post by NaturalDemon » November 18th, 2012, 1:45 am

this is ...

Code: Select all

pSysBuffer = new D3DCOLOR[ (winSizeX -1) * (winSizeY - 1) ];
wrong!

i posibly ... was over ambigious .. when i changed that part.

sofar ... so good on my journey ..


thank you ... indus

Post Reply