|
putpixel "weird" issue. |
Kevin Epps
Member #5,856
May 2005
|
I've optimized some of my code and it helped a lot. I pretty much changed the areas where I've created a bitmap to create_video_bitmap and got a massive jump! But I have on problem. I have a star class that creates a 1x1 video bitmap with and puts a pixel in the bitmap and moves the bitmap accordingly. And it seems to eat up FPS So, I was wondered, "why in the heck would I do that?", and quickly realized why I took that route. When I first wrote the class, I had it where the x and y values would be updated and then just have the pixels drawns at the desired coordinates, but when I do that, the exe crashes with a "alld42.dll access violation" under debug. Here's the class:
I know I can change the putpixel to the color depth version and have, but had just changed it back to see if the color depth version was the problem is all. If I comment out the "y+=speed" then it doesn't crash, but of course the stars don't move either. Any suggestions? |
miran
Member #2,407
June 2002
|
Accessing video memory is so slow you should never do it. Try for example to fill the screen bitmap with putpixel in a double for loop. You will see how the screen is being slowly drawn and it will take seconds. That's how slow this is. And don't create 1x1 bitmaps, that just makes no sense... The crashes you're getting might be because the clipping rectangle is not set or something. When you do a putpixel outside the bounds of the bitmap, it checks for inclusion in the clipping rectangle, but if that's not set properly, it can change memory it shouldn't have. -- |
Kevin Epps
Member #5,856
May 2005
|
Quote: And don't create 1x1 bitmaps, that just makes no sense... Well, yeah, I know that, which is why I'm asking the question in the first place. I wouldn't even have thought to even USE that process if it wasn't crashing to begin with. Quote: The crashes you're getting might be because the clipping rectangle is not set or something. When you do a putpixel outside the bounds of the bitmap, it checks for inclusion in the clipping rectangle, but if that's not set properly, it can change memory it shouldn't have. Well, all the random values should be within the dimensions of the buffer that I'm drawing the stars to. (0 - 640) x (0 - 480), but I'll do some more checking. |
A J
Member #3,025
December 2002
|
Quote:
putpixel(buf, x, y, makecol(255,255,255)); a vline() would be better. ___________________________ |
Audric
Member #907
January 2001
|
> Any suggestions? > Well, all the random values should be within the dimensions of the buffer that I'm drawing the stars to. (0 - 640) x (0 - 480), but I'll do some more checking. |
Kevin Epps
Member #5,856
May 2005
|
Quote: a vline() would be better. duh!! hahaha! Thanks, AJ. I'll go ahead and put that in right now. I don't know why I didn't think of that! Audric: gdb. Is that within the debugging tool in msvc? I code in MSVC. I should've stated that earlier, sorry about that? If it's within the debugging tool, then I get the (alld42.dll) access violation message. |
miran
Member #2,407
June 2002
|
Quote: duh!! hahaha! Thanks, AJ. I'll go ahead and put that in right now. I don't know why I didn't think of that! The Manual is your friend. Quote: gdb. Is that within the debugging tool in msvc? Gdb is the GNU debugger. Not applicable in your case. -- |
A J
Member #3,025
December 2002
|
if your using msvc ___________________________ |
Kevin Epps
Member #5,856
May 2005
|
That's what I've done already and I get the (alld42.dll) access violation message. |
A J
Member #3,025
December 2002
|
in what function ? ___________________________ |
Kevin Epps
Member #5,856
May 2005
|
In this function that in the "include/platform/al386vc.h" file. INLINE _AL_DLL uintptr_t bmp_write_line(BITMAP *bmp, int lyne) { _asm { mov edx, bmp mov ecx, [edx]BITMAP.write_bank mov eax, lyne call ecx } } I just went ahead and just made a 1x1 gif file with a white background and drew it to the screen, because I really didn't want to spend this much time on this. It seems to work fine now. I just wanted to get away from creating bitmaps. |
|