I've been using dbLine to draw lines to bitmap(1) one after the other, the problem is if I draw 2 lines this way, only the first line actually shows when I copy bitmap(1) to bitmap(0) (the screen)
I wrote a simplest example possible demo (below) to demonstrate/prove this.
If I try drawing 3 lines in a row to bitmap(1) then NONE of the lines are showing up when I dbCopyBitmap(1,0)
Any idea's?
Also I suspect it's a bug that dbCLS only clears bitmap(0) and not the current selected bitmap.
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple 2D project that uses Dark GDK
// it can be used as a starting point in making your own 2D games
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
/*---------------------------------------------------------------------------*/
// the main entry point for the application is this function
#define xRes 640 //defining constants for res to only to keep everything REALLY simple, eliminate screen/bitmap h/w check as possible cause for any problems.
#define yRes 480
void DarkGDK ( void )
{
dbSyncOn ( ); //enable video sync
dbSyncRate ( 60 ); //set sync rate
dbDisableEscapeKey ( ); //disable escape to handle manually
dbRandomize ( dbTimer ( ) ); //init random number generator with time seed
dbSetWindowOn(); //init window and set size
dbSetWindowSize (xRes,yRes);
//dbSetDisplayMode( xRes, yRes, 32 );
dbSetWindowPosition( 200, 200 ); //force window position
dbCreateBitmap (1,xRes,yRes); //create a bitmap for our pixel opperations same size as the window
int RenderOrder = 0; //Initialise render order to render to screen only.
while ( LoopGDK ( ) )
{
if (RenderOrder==1) //if ordre==1 then we're rendering to a bitmap
{ //so set the current bitmap and lock Pixels
dbSetCurrentBitmap(1);
dbLockPixels();
}
else //otherwise we're rendering to screen
{ //so set the current bitmap to 0, don't lock pixels on screen
dbSetCurrentBitmap(0); //or it locks application.
}
dbCLS(dbRGB(120, 120, 140)); // **BUG?** clears the screen, not the curent bitmap, is this intended behaviour?? **BUG?**
dbInk(dbRGB(0,200,0),0); //set colour for lines
int i;
for (i=0;i < yRes;i++)
{
dbDot (0, i, dbRGB(150,0,0)); //compare 1
dbDot (xRes/2, i, dbRGB(0,150,0)); //compare 2 (verticle line, half way through screen)
}
for (i=0;i < xRes;i++)
{
dbDot (i, yRes/2, dbRGB(0,0,150)); //compare 3 (horrizontal line, half way through screen)
}
dbLine (1,1,xRes/2,yRes/2); //line from top left edge, to current bitmap centre (renders to both screen and bitmap(1) ok!
dbLine (10,20,50,70); //**BUG** second line at abitrary angle Is not displaying on bitmap(1) **BUG**
//dbLine (94,56,210,175); //**BUG** If this 3rd dbLine is enabled, then NO dbLines render to bitmap(1) **BUG**
dbInk(dbRGB(0,0,255),0); //set colour for circle
dbCircle(xRes/2,yRes/2,20); //draw circle centre of the current bitmap
dbCircle(xRes/2+30,yRes/2+40,20); //draw circle centre of the current bitmap
if (RenderOrder==1) dbUnlockPixels(); //if we're rendering to the bitmap instead of screen (bitmap(0)) then unlock pixels b4 displaying.
if (RenderOrder==1) dbCopyBitmap(1,0); //copy our bitmap to the screen
if ( dbReturnKey()) RenderOrder=1; else RenderOrder=0; //if return key is held, then render to bitmap then copy to screen, else
//render directly to screen
if ( dbEscapeKey ( ) )
break;
dbSync ( );
}
dbDeleteBitmap ( 1); //delete bitmap to cleanup
return;
}