PDA

View Full Version : Bluescreen when using Pixels[x,y,0];



Huehnerschaender
02-10-2004, 05:47 PM
Hello folks,

I am trying to upgrade the finished parts of my game to actual Asphyre Version and now there is the following problem:

I need to check single color of pixels when moving the mouse to decide if the mouse is over an "object" or not.

When using the following (sample)code, my computer shows me a bluescreen and reboots:

if Images1.Image['introbtn1'].Pixels[MouseX,MouseY,0] <> Images1.Image['introbtn1'].MaskedColor then
MouseOverBtn := true
else
MouseOverBtn := false;

What is wrong here? I need to check the color under the mouseposition. If it is not the MaskedColor (not visible elements) then I know the mouse is over my button or something similar.

In PowerDraw3Pre this worked perfectly.

Or is there a problem with TAsphyreImages?

Any hint is welcome.

Greetings,
Dirk

LP
02-10-2004, 11:11 PM
I've tried to reproduce the error and no success, Pixels appears to work fine. Make sure "introbtn1" *IS* the name of your image (try accessing the same image using Images1[MyImageIndex]) and also check if the pixel you are trying to access is within images boundaries. If the image you are accessing doesn't have name "introbtn1" - it'll be "nil". In case you already checked all this, then a sample code would help. Finally, does the same thing happen in Software Renderer?

Huehnerschaender
03-10-2004, 08:26 AM
Hi LifePower,
to find out if it is my fault I tried a little thing with your Hasteroids Demo.

The bluescreen also appears if I add only one line to your code:

procedure TMainForm.Timer1Render(Sender: TObject);
begin
if (not PowerDraw1.DeviceActive) then Exit;

with PowerDraw1.Device do
begin
Clear(clBlack);

BeginScene();

OEngine1.Render(VScreen1);
PEngine1.Render(VScreen1);

TextureMap(Images1[2], pBounds4(100, 100, 64, 64), cColor1({clWhite}0), tPattern(0), effectSrcAlpha);

Fonts1[0].TextOut('PixelCol: ' + IntToStr(Images1[2].Pixels[10,10,0]), 4, 14, $FF00FF00);


Fonts1[0].TextOut('FPS: ' + IntToStr(Timer1.FrameRate), 4, 4, $FF00FF00);
Fonts1[0].AlignedOut('Press ESC to exit, SPACE to switch Hardware/Software', 0, 440, taCenter, taBeginning, $FF00FF00);
Fonts1[0].AlignedOut('and finally, ALT + ENTER to switch from windowed to full-screen mode.', 0, 458, taCenter, taBeginning, $FF7FEF00);

EndScene();


Present();
end;
end;

Am I doing something wrong?

Here my PC specs:

Toshiba TECRA S1
Centrino 1,7 Ghz
ATI Mobility Radeon 9000 (latest driver)
Windows XP Prof (latest updates)
Direct X 9.0c

I did not try it on other PCs. This will be the next step to find out more.
But since this is my developement machine, I am very interested in finding out the reason why Pixels does not work here.

Greetings,
Dirk

Huehnerschaender
03-10-2004, 09:15 AM
Ok, tried it on another PC now.

result is nearly the same. NO bluescreen, but the game hangs up.
So I don't think the problem lies in hardware.

Specs of 2nd PC:

Athlon XP 2000
GeForce Ti 4200 (latest drivers)
Windows XP Prof

It would be very nice if you can help me with this.
How did you test Pixels-function? You said it seems to work fine. Maybe I am too blinded from programming to find the "easy solution".

Greetings,
Dirk

LP
03-10-2004, 05:02 PM
Rather than trying on other PC you should check with Software Renderer.
I'm going to release new version of Asphyre and you should experiment with one of its examples.

Huehnerschaender
03-10-2004, 05:35 PM
Pixels-function in Software mode seems to work with your sample.

When trying to start my game in Software mode, all I see is a white screen... Don't know why.

Greets,
Dirk

Huehnerschaender
04-10-2004, 11:29 AM
High LifePower,

I played around a bit with the new releas 0100 and found out the following:

Pixels in Hardware Mode crashes the system on WinXP Prof.

Pixels in Hardware Mode under Win 2000 Prof seems to work.

I tried 4 PCs now, 3 of them with Win XP Prof and they crash.
The only one which works is a Win 2000 Prof PC.

Any idea? Which OS do you have installed?

Greetings,
Dirk

LP
04-10-2004, 02:42 PM
I'm running WinXP and the problem you are mentioning doesn't happen. I'm pretty out of options here so I would really ask you if you can assemble a small compilable example of what you're doing and send it by e-mail to me for further testing. My e-mail address appears in the beginning of most source files.

Thanks!
Lifepower

Huehnerschaender
04-10-2004, 06:56 PM
As I already said,
you can take any of your sample programs and add a line which prints out the color of a pixel every frame.

The example posted before in this topic crashes my systems.

I have found the problem with software renderer. I had the asphyreex.dll from pre-version still in windows\system32-Dir. After I deleted it, I was able to use software mode.

But I still don't know why Pixels in HW-mode crashes my systems. In software-mode it works well and prints out the correct color-value.
As soon as I change to HW-mode the system crashes.

When I use Pixels[x,y,1] instead of Pixels[x,y,0] the system stays stable, but always shows color $0. Maybe this helps you to find out something more.

OK, I hope you can find something out. If it was only one PC I would think it is maybe some kind of WinXP-config problem, but I can't use Pixels on two other WinXP-Systems.

I will try different other settings etc. Maybe I will find the problem. I know it is hard for you to find out something when the problem does not occur on your system. I will "feed" you with anything I find out.

Huehnerschaender
04-10-2004, 09:15 PM
Hello again,

I'm driving mad with this problem.

I am wondering if I have overseen something, so could you please post a snap of code how to use Pixels-function?

Found out something more...

The systems does NOT crash when I define a TAsphyreImage2, load a bitmap from file (not from vtdb into imagelist) and then try to access a single pixel. This works!

In my point of view the problem could be here:

TAsphyreImages is a list of TAsphyreImage. In declaration of TAsphyreImage the functions GetPixel, SetPixel etc are abstract, which means they will be implemented first time in TAsphyreImage2.
So the visual component on my form uses property Pixels from TAsphyreImage, which tries to call functions which are not implemented in this class. Is this the problem?

But if so, why does it work on your system?????

LP
04-10-2004, 10:30 PM
Greetings! I've re-checked pixel code and it seems fine.

Open "Plasma" example and change the "TimerRender" function to the following:

procedure TMainForm.TimerRender(Sender: TObject);
var
i, j: Integer;
begin
with PowerDraw.Device do
begin
Clear($FFFF0000);
BeginScene();

for j:= 0 to Images[0].TextureHeight - 1 do
for i:= 0 to Images[0].TextureWidth - 1 do
Images[0].Pixels[i, j, 0]:= Images[0].Pixels[i, j, 0] and $FFFF0000;

for j:= 0 to (PowerDraw.Height div 256) do
for i:= 0 to (PowerDraw.Width div 256) do
RenderEffect(Images[0], (i * 256), (j * 256), 0, effectNone);

Fonts[0].TextOut('FPS: ' + IntToStr(Timer.FrameRate), 4, 4, $FFFFFFFF, effectNone);

EndScene();
Present();
end;
end;

This uses Pixels property to read and write the entire texture. The example above makes Plasma look in red color only. I had no problems running this on ATI Radeon 9000, Nvidia GeForce 2 Go and Nvidia GeForce 2 MX400 (all run WinXP).
Maybe your problem is driver related? Although since you mentioned a lot of machines, then maybe you are still trying to access pixel outside image's boundaries? Check that your X and Y coordinates do not overpass TextureWidth and TextureHeight (that is, maximum value for X can be TextureWidth - 1, same applies to Y).

EDIT: I did not understood what you were trying to say related to TAsphyreImage... if you use TPowerDraw component it needs TAsphyreImages component to be asociated with it, otherwise no images will be created. When TAsphyreImages is asociated with TPowerDraw, each image class is created with TPowerDraw.Device.NewImage, which creates and returns an TAsphyreImage class which is compatible with the specific TAsphyreDevice (that is, TAsphyreDevice3 creates TAsphyreImage3 class instance).

Huehnerschaender
04-10-2004, 11:11 PM
Hello Lifepower,

thank you very much for your help so far.

The confusion is complete now :shock:
Plasma demo works...
So I don't really know what I am doing wrong.

So please take a look at the above mentioned single line in your demo. Where is the fault?
In the beginning I tried to use variable positions, because I needed Pixels for mouse movement, but to find out something more I tried to get a single Pixel at a specific position in a bitmap, so I used position 10,10 from a picture sized 64*64. This point is definately within the picture.

The fat printed line above in the snap of code I posted lets my computer hang. Does this work on your machine, if you just insert this line in your example?

Concerning the TAsphyreImage-thing I said. I was a little confused because I did never take a closer look at your code and I did not understand correctly how you architecture works. But with your explanation it is a little bit clearer, so just forget what I said :wink:


EDIT:
Could you please do me a favour and take one of your samples where you load images from a vtdb. Then insert a line in rendering-process, where you give out the color of a specific pixel using pixels-property.
It seems that my systems only crash if the graphics have been loaded from vtdb. The sample you just posted creates the image with CreateCustom and I tried an example with loadfromfile, which seems to make no problems, too. But when trying to access pixels when graphic has been loaded from vtdb the system hangs up.

LP
05-10-2004, 02:30 AM
Greets... oh well :wink: As you requested, I did the same thing with Combustion Demo. Open it and change "TimerRender" function to this:

procedure TMainForm.TimerRender(Sender: TObject);
var
i, j, k: Integer;
begin
with PowerDraw.Device do
begin
Clear($FF000000 or Cardinal(BlendColor(Color2, Color1, Opacity)));

BeginScene();

for k:= 0 to Images[imageCombustion].TextureCount - 1 do
for j:= 0 to Images[imageCombustion].TextureHeight - 1 do
for i:= 0 to Images[imageCombustion].TextureWidth - 1 do
Images[imageCombustion].Pixels[i, j, k]:= Images[imageCombustion].Pixels[i, j, k] and $FFFF0000;

Particles.Render(VScreen1);

RenderEffect(Images[imagePowerDraw], 80, 160, 0, effectSrcAlpha);
RenderEffect(Images[imagePowerDraw], 320, 160, 1, effectSrcAlpha);
FadeScreen();

FillRect(220, 272, 200, 30, $5F5F5F, effectMultiply);
Rectangle(220, 272, 200, 30, $3F3F3F, $1F1F1F, effectAdd);

Fonts[0].TextOut('Frame Rate: ' + IntToStr(Timer.FrameRate) + ' fps', 228, 272, $FF00FF00);
Fonts[0].TextOut('Particle Count: ' + IntToStr(PCount), 228, 286, $FF9F9F9F);

EndScene();
Present();
end;
end;

And yes, this one works too :wink: You should see completely red smoke... and I maybe you should check if that image you are trying to access is REALLY there (use Images.Count) and has the REAL size of 64x64 and not 0x0 :wink:

Huehnerschaender
05-10-2004, 05:27 AM
Hello Lifepower,

your sample works, but it does not what I meant.
You SET pixels, I just want to GET pixels.
I have sent you a mail with a little sample which does nothing more than:

- load bitmap from vtdb
- print bitmap on screen
- show fps
- show pixelcolor of pixel[1,1,0]

This one hangs up!

If I insert your code to get the picture red, it works!

So there has to be a difference in GET and SET pixel. My problem only occurs when GETTING pixels.

And now the confusing thing:
After changing the picture to red color using pixels[j,i,0] := .... I am able to GET pixels without problems. That's why your samples work because you always manipulate the bitmap by setting pixels.

Please try out the little sample I sent you to see what I mean, but be aware of a bluescreen, so save all your work before :lol:

Greetings,
Dirk

LP
05-10-2004, 03:59 PM
Your program was empty and in my example I used to GET and SET pixels (I change the existing pixel!).

Huehnerschaender
05-10-2004, 04:21 PM
Sorry for the empty project.
I seem to have forgotten to save before I zipped the source :oops:

In your example you did not render the picture before you use Pixels.
Try to render it and THEN access Pixels.
Your example works even on my machine, like every example you gave me :lol:
But you never did exactly what I do...

Render Image
Show PixelColor on screen.

If I add the rendering to your example it hangs again.
It seems that after rendering the texture is locked and Pixels can't access it then. I did not look at the code but I have seen the same behaviour once in DelphiX when I forgot to unlock a texture.


Greets and very much thanks for your patience with me :)

EDIT:
Don't forget to show Framerate on screen. Some computers reboot, on others the program just halts and you can't see this when nothing happens on screen.

Nightmare_82
06-10-2004, 10:10 AM
@Huehnerschaender : What happens when you debug while trying to get the pixel value ? Maybe you can see what's wrong or where it crashes.

Huehnerschaender
06-10-2004, 11:05 AM
Yeah, I already did this with Lifepower.
The error occurs after second render cycle (first frame is rendered well) in procedure EndScene->FlushVertexBuffer following line of code:
if (Failed(VertexBuffer.Lock(0, BufSize * SizeOf(TPGVertex), p, 0))) then
This is line 1377 in AsphyreDev3.pas

Lifepower already tried to investigate the situation, but this error does not occur on his PCs so it is hard to find the problem.

I have 4 of 5 PCs where the little sample program hang up. On his PC it works...

I think I will upload this little sample code today and post a link here. Maybe we can then find out if I am the only one with these problems (Maybe its my WinXP installation causing the problems).

Would be nice if you could test this also then and post if the sample runs well on your system or not and maybe your system configuration.

Greetings,
Dirk