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 / Newbe again......need help

Author
Message
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 15th Dec 2007 18:07 Edited at: 15th Dec 2007 18:08
Well after five years with DBP, I got to a point where I did not need much help. Now with me going to vc++2008 and Dark GDK I am a newbe again. I don't like it much, but that is life.
Why won't this code print out texts, and paste a bitmap to the screen?
code:


All I get is a black screen.
Thank You
renny
aersixb9
16
Years of Service
User Offline
Joined: 29th Nov 2007
Location:
Posted: 15th Dec 2007 18:08
I'm a noob too - do you need a dbSync() in there? (After the dbText())???
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 15th Dec 2007 18:10
yes for the text, I do have it there. just not in the code I put up here.
renny
n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 15th Dec 2007 18:13
Could you post up all of your code?

sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 15th Dec 2007 18:18 Edited at: 15th Dec 2007 18:19
I found the problem with the text
this is what I had





Now can anyone know why the bit map does not paste to screen?
Thank You
renny
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 15th Dec 2007 18:29
Ok, thanks for your help I found what I was doing worng.
bad code:



Good code:


Well back to the unknow
renny
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 15th Dec 2007 19:03
Thank you WindowsKiller , I will try that and see what happens.
Boy, C++ is hard, so many little things.
renny
n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 15th Dec 2007 20:17
Quote: "Thank you WindowsKiller , I will try that and see what happens.
Boy, C++ is hard, so many little things.
renny"


Actually C++ isn't that hard. It's just different from BASIC in that it is a Programmer's Language.

dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 15th Dec 2007 20:27
I have no knowledge in BASIC- I hate BASIC- because for me that's too hard.

dbPrint ( "Sig" );
n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 15th Dec 2007 20:46
I really hope you are joking.

sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 15th Dec 2007 20:56
Ok what I am trying to to do here is Have my image come up on the screen with the text. Than stop there untill you press any key. Then go onto the loop.
I am using dbwaitkey() function. I am using as I did in DBP. It is not working the way I want it to.The image and the text does not print on to the screen untill I press a key.
code:


This is the code that I am having a problem with.



If I do not put the waitkey in there then its loads and print to the screen fine. But once I get in the loop I have no way of dbCLS
(clear the screen).
I hope some one can help, it should work the way I have it.
Thank You
renny
n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 15th Dec 2007 21:24


Why did you put this in a scope?

Either remove the scope, or put dbWaitKey(); ouside the scope.

sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 15th Dec 2007 21:52
What is a scope?????
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 15th Dec 2007 21:55 Edited at: 15th Dec 2007 21:55
dbGamerX that is the problem being a newbe, if you don't know it it is hard. If you know it it is not hard, and you are not a newbe.
renny
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 15th Dec 2007 22:01
Scope? you have unnecessary brackets.

Here is why its called Scope:






Quote: "If you know it it is not hard, and you are not a newbe.
"
Almost perfectly Said

Pharoseer
17
Years of Service
User Offline
Joined: 21st Feb 2007
Location: Right behind you
Posted: 15th Dec 2007 22:02
Hey sadsack,

You have to call the dbSync() command once before you draw the text to draw the back buffer. Here's a clip from what it says in the help file under dbSync():



This is why your text isn't appearing. It is being drawn to the back buffer and not getting drawn to the screen. To solve this, simply put a dbSync() command right after your dbSyncRate(60) command like follows:



Try that and your text should appear. Also, you only have to do that once. You don't have to keep calling dbSync() twice to get things to appear. Just once at the very beginning to initialize the backbuffer and once everytime you want to show your changes. Hope this helps!

-Frank
dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 15th Dec 2007 22:12 Edited at: 15th Dec 2007 22:13
I did not mean to offend you. It's just that BASIC was hard for me. Now that I know it, there's no problem with it The reason is because I was still learning the concepts of programming (I only knew HTML two years ago). BASIC was next after HTML/CSS and then I learned C++ (I don't know C lol).

Oh yeah, scope is when you limit the FOV of variables.

Ex say you have int X-


And you declare X here-


X can be accessed by any function because it is global.

If X was here-


It could be seen by int main and the while loop, but not some_other_function. It is a local variable.

To tell the compiler where to "look", you use the scope resolution operator ::

dbPrint ( "Sig" );
n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 16th Dec 2007 03:58
^^ True, but that isn't exactly what a scope is, those are global and local-to-function variables.

A scope is usually reffered to as brackets in a function or just placed somewhere:



Oh, and glad to see that you fixed your problem .

dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 16th Dec 2007 15:55
What I said was a mere illustration Scope is much more than what I said. Thx for making it more clear to sadsack n008- I guess I'm lazy lol

dbPrint ( "Sig" );
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 16th Dec 2007 16:31
Wow - I have to ask - SadSack - Alot of help here eh? I love that! Do you have a better idea about the whole scope thing now?

It used to be GLOBAL SCOPE and LOCAL SCOPE - now with stuff like FreePAscal, Delphi, C++, and .Net - there are various kinds of Scope.

:-> You've been obviously plowing through learning curve and making headway - Good Job!

I'm crawling through terrain terror myself - not going so great - but like you - I'm going to keep hammering at it I might even get a "Bump" on a flat desert today if I'm lucky! (Trying to make the meshs manually versus advanced terrain or using an editor) all learning for me - Not Editor? AHHHHH

sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 16th Dec 2007 17:11
Sorry Pharoseer about that. I went back looked at the help
dbSync(); and there it was. I should have seen it.

scope, well I have looked over what everyone has said, I copyed this thread to notebook and later to day I will go over all that is in it.

I want to thanks all of you for the help you have gave me. I am not a young kid and I never have done any coding untill I got DBP five years ago. Basic was hard for me, but I got to a point that I could do what I needed to do with dbp. I got two C++ books and I get lost trying to read them. It will just take time.
Thank You All
renny
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 16th Dec 2007 17:26 Edited at: 16th Dec 2007 17:27
Renny - I've been coding for YEARS - and C++ books STILL do that to me! I recommend you at least look at the http://www.cplusplus.com/doc/tutorial/ [edit]wrong url - FIXED[/edit]

It helped me - I still forget little details like when the "*" goes in front of a pointer - and when its behind it and other "semantic" stuff sometimes - I know what I WANT to do - then I poke until I know I nailed it - etc.

So - you're doing great- and most of all I hope when you have those little successes (and big ones) you get the "feeling of accomplishment" I do when I get something working.

Today I figured out how to Post without mispelin

dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 16th Dec 2007 18:09
Sometimes I try to get the compiler to try to convert from const char to char, and I forget I need to use pointers.

It's no big deal. I started learning C++ about an year or two ago. And this is how far I got. I'm not satisfied with how far I got

dbPrint ( "Sig" );
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 16th Dec 2007 23:32 Edited at: 16th Dec 2007 23:34
Well, I did feel good untill I went on to the next part of my program. I put in about four lines and got 20 error. Well I worked at it for about 30 to 45 mins. and got the errors down to four.
That was the best I could do. I all so played around with the {}
some. I done understand what the errors are.
Here are the errors:




Here is the code:


What I am trying to do is make a model viewer.
I made one in DBP and trying to convert it to dark GDK C++
I was thinking that I know hot the comm work in DBP and I can learn how to use then in C++.
I tryed to char for entering the models but it is not working right.
It is like it was in the book.
If anyone have time to look at it maybe you can start b me in the right Dir.
Thank YOU
renny
PS. In the input and else statement did I use the {} right?
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 16th Dec 2007 23:48
jason p sage,
I went to that site that you gave me. That is nice. Below is come code I found there. Can I use the header <string> with GDK for inputing the model name?
renny



// my first string
#include <iostream>
#include <string>
using namespace std;

int main ()
{
string mystring = "This is a string";
cout << mystring;
return 0;
}
dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 17th Dec 2007 00:46
The bad code should be:


And if you use string.h, you still can't do much with it using DGDK.

Instead use arrays:

Or:


If you do use string.h and make a string variable, it'll need to be converted into a LONGLONG value.


dbPrint ( "Sig" );
dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 17th Dec 2007 00:49
Oh yeah, for inputting, you'll have to convert to LONGLONG and back to string if you want to use dbInput with it, I think. You never know Practice makes perfect.

dbPrint ( "Sig" );
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 17th Dec 2007 02:31
Thank You dbGamerX,
I will try that tomorrow, I got snowed in today so it looks like I won't be going to work tomorrow. I even got the snow shoes out to day.
renny
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 17th Dec 2007 02:35
Hmmm - I used my own string lib and it seems to work ok - I'm surprised string.h is an issue. I think I "borrow" from it here and there - so that is buffuddling you should say what you did dbGamerX about longlong.

Some sort of Uni-code to REgular byte char's or something?

dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 17th Dec 2007 04:01
When I pass a string (from string.h) to dbPrint, the compiler tells me a conversion error. For some reason, it only passes validation when the string is converted to LONGLONG.

dbPrint ( "Sig" );
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 17th Dec 2007 09:34 Edited at: 17th Dec 2007 09:44
For strings, use the c_str member like so:



Quote: "
if ( model == "" )
"


Why are you comparing model to a pointer to a string literal? For string comparisons use strcmp:



In this case however you only need to check if the first character is 0.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)

Login to post a reply

Server time is: 2024-11-17 00:37:52
Your offset time is: 2024-11-17 00:37:52