Code: Select all
for (int a = 0; a < heigth; a++) {
for (int b = 0; b < width; b++) {
PutPixel(x +b ,y + a , image[b + a * width].GetR(), image[b + a * width].GetG(), image[b + a * width].GetB());
}
}
Code: Select all
for (int a = 0; a < heigth; a++) {
for (int b = 0; b < width; b++) {
PutPixel(x +b ,y + a , image[b + a * width].GetR(), image[b + a * width].GetG(), image[b + a * width].GetB());
}
}
color formula doent mach width 50 height 80freebattie wrote:you just want to change the order the picture is drawn ?or flip it? if u just want to start drawing same picture for bottom right corner you do (a= height - 1; a >= 0;a++) and same whit b i think
and if you want to flip the colors you do this img[(a +((height - 1) ) - b) * width] that how i flip my img at least. but maybe i misunderstand what you ask
Code: Select all
for (int a = heigth; a > 0; a--) {
for (int b = width; b > 0; b--) {
(a +((height - 1) ) - b) * width // (80 + (80 - 1 ) - 50) *50 = 116k instead of 4k
}
}
Code: Select all
for (int a = heigth-1; a > 0; a--) {
for (int b = width; b > 0; b--) {
(b-1) + a * width
}
}
Code: Select all
void Graphics::DrawSpriteBackW(int x, int y, int width, int heigth, std::vector<Color>& image)
{
for (int a = heigth-1; a > 0; a--) {
for (int b = width; b >= 0; b--) {
PutPixel((x+width) - (width -b), (y+heigth) - (heigth- a), image[b - 1 + a*width].GetR(), image[b - 1 + a*width].GetG(), image[b - 1 + a*width].GetB());
}
}
}
Code: Select all
// width 50, height 80
// Your x values for drawing: 0, 1, 2, 3, 4, 5, ...
// Your x values for surface: 49, 48, 47, 46, 45, 44, ...
// Your loops will be going forward, from 0 to 49, and your image index will be going from 49 to 0
for( int iy = 0; iy < height; ++iy )
{
for( int ix = 0; ix < width; ++ix )
{
int surfaceIndex = ( ( width - 1 ) - ix ) + ( iy * width );
PutPixel( x + ix, y + iy, image[ surfaceIndex ] );
}
}
Code: Select all
normal x, and img.x:
for( int y = 0; y < height; y++ )
{
for( int x = 0; x < width; x++ )
{
DrawPixel( x, y, image[ x + y * width ] ); // top/left-to-bottom/right image access -> screen top/left-to-bottom/right
}
}
reverse x, normal img.x: (draw img to flipped screen)
for( int y = 0; y < height; y++ )
{
for( int x = 0; x < width; x++ )
{
DrawPixel( width - x, y, image[ x + y * width ] ); // top/left-to-bottom/right image access -> screen top/right-to-bottom/left
}
}
normal x, reverse img.x: (flip image)
for( int y = 0; y < height; y++ )
{
for( int x = 0; x < width; x++ )
{
DrawPixel( x, y, image[ width - x + y * width ] ); // top/left-to-bottom/right image access -> screen top/left-to-bottom/right
}
}
reverse x, and img.x: (draw flipped img to flipped screen, hence same as normal)
for( int y = 0; y < height; y++ ) // top-to-bottom loop
{
for( int x = 0; x < width; x++ ) // left-to-right loop
{
DrawPixel( width - x, y, image[ width - x + y * width ] ); // top/right-to-bottom/left image access -> screen top/right-to-bottom/left
}
}
Code: Select all
normal x: offset = x; as normal haha
reverse x: offset = (scrnwidth - img.width - x) - (scrnwidth - (scrnwidth - (x + img.width) * 2)) - img.width
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.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.