Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Why this code do not display anythig ?

Author
Message
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 3rd Jun 2005 09:20
Hi,

I create a larger bitmap, draw a text on it, get an image from the text, switch to the screen bitmap, paste the image and nothing appears.
If I do paste the image directly on to the screen it work.

Any idea ?
thx

/kml
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 3rd Jun 2005 09:21
here a part of the code, don't know why using firefox I lost my code everytime...

void scrolling(void) {
dbSetCurrentBitmap (1); //redirect the drawing operation to the screen !
dbText ( 112, 440, currentscrolldatas);
dbGetImage ( 4, 112, 440, 718, 456, 1); //last param mean no effect
dbSetCurrentBitmap (0); //redirect the drawing operation to the screen !
dbPasteImage ( 4, 112, 440 + 16, 0 );
}

/kml
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 3rd Jun 2005 21:15
The function above (scrolling) is called like this.
so dbsync() is there.

while ( LoopSDK ( ) )
{
if ( dbEscapeKey ( ) )
return;
dbCLS ();
rasters();
scrolling();
dbLoopMusic ( 1 );

dbSync ( );
}
free (currentscrolldatas);
}

/kml
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 3rd Jun 2005 21:18
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 3rd Jun 2005 21:21
Hmm,.. just as a note, in your code, if a user hits Escape, the //free (currentscrolldatas); // will not be executed!
(I think)


You should use something like this:
//--------------------------------
DarkSDK ()
{
while ( LoopSDK ( ) && (!(dbEscapeKey()) ) )
{
dbCLS ();
rasters();
scrolling();
dbLoopMusic ( 1 );

dbSync ( );
} // end while ( LoopSDK ( ) && (!dbEscapeKey()) )

free (currentscrolldatas);
} // end DarkSDK()
//--------------------------------

I would suggest you change the if !dbEscapeKey() to something like
// if !(bExitCondition) //

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 3rd Jun 2005 23:20
Here's a complete code (compilable).

So what's wrong with it ?

#include "DarkSDK.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int width = 800, height = 600 , depth = 32; // screen resolution

char * scrollingdatas = "Scrolling content scrolling content.....";

char * currentscrolldatas = (char *) malloc(41);
char index = 40;
char * temp;

// You shoud copy the font Fairlight.ttf in C:\WINDOWS\Fonts !!!
void LoadFont(void) {
char *font = "Tahoma";
dbSetTextFont ( font );
int fontsize = 20;
dbSetTextSize ( fontsize );
}



void initscroll(void) {
strncpy( currentscrolldatas, scrollingdatas, 40);
temp = currentscrolldatas + index;
(*temp) = '\0';
dbCreateBitmap ( 5, 620, 16 );
dbText ( 112, 440, currentscrolldatas);
dbGetImage ( 5, 112, 440, 718, 456, 1); //last param mean no effect
}

void scrolling(void) {
dbSetCurrentBitmap(0);
dbText (112, 200, "This text is displayed why not the image content of the other?");
dbPasteImage ( 5, 112, 440, 0 );
}



void DarkSDK ( void )
{

dbSyncOn ( );
dbSyncRate ( 60 );

dbSetDisplayMode ( width, height, depth );

dbHideMouse ( );
LoadFont();
initscroll();

while ( LoopSDK ( ) )
{
if ( dbEscapeKey ( ) )
return;
dbCLS ();
scrolling();
dbSync ( );
}
free (currentscrolldatas); //if the esc key is pressed the mem is not released!!!
}

/kml
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 4th Jun 2005 00:22
Your dbGetImage coordinates are totally incorrect for the required bitmap size.

kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 4th Jun 2005 01:07
Thanks a lot for pointing the error.
I was too focus on the fact that my bitmap was equal to me screen, this lead me to the error I made.

Regards

working code below :

#include "DarkSDK.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int width = 800, height = 600 , depth = 32; // screen resolution

char * scrollingdatas = "Scrolling content scrolling content.....";

char * currentscrolldatas = (char *) malloc(41);
char index = 40;
char * temp;

void LoadFont(void) {
char *font = "Tahoma";
dbSetTextFont ( font );
int fontsize = 14;
dbSetTextSize ( fontsize );
}



void initscroll(void) {
strncpy( currentscrolldatas, scrollingdatas, 40);
temp = currentscrolldatas + index;
(*temp) = '\0';
dbCreateBitmap ( 5, 620, 16 );
dbText ( 0, 0, currentscrolldatas);
dbGetImage ( 5, 0, 0, 620, 16, 1); //last param mean no effect
}

void scrolling(void) {
dbSetCurrentBitmap(0);
dbText (112, 200, "This text is displayed why not the image content of the other?");
dbPasteImage ( 5, 112, 440, 0 );
}



void DarkSDK ( void )
{

dbSyncOn ( );
dbSyncRate ( 60 );

dbSetDisplayMode ( width, height, depth );

dbHideMouse ( );
LoadFont();
initscroll();

while ( LoopSDK ( ) )
{
if ( dbEscapeKey ( ) )
return;
dbCLS ();
scrolling();
dbSync ( );
}
free (currentscrolldatas); //if the esc key is pressed the mem is not released!!!
}

/kml

Login to post a reply

Server time is: 2024-04-19 16:51:17
Your offset time is: 2024-04-19 16:51:17