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 / how to use darkGDK with c++ empty project?

Author
Message
CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 25th Sep 2010 19:48 Edited at: 25th Sep 2010 19:50
I was trying a simple code because I wanted to be able to use things like cout and stuff along with GDK, so I made an empty c++ project and tried this:

Am I missing a step? If you don't understand i'm trying to include darkGDK without using the wizards and empty GDK project, just an empty C++ one.

I want coke, not Pepsi!
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 25th Sep 2010 23:23
You don't know what you are doing, let me explain this:

Dark GDK is a wrapper for DirectX9, this is a library made by microsoft, this library is responsible for mainly drawing 3d and 2d scenes/images, and a couple of other things

what you are doing is that you are creating a DOS project, the most common use of this is C++ language practice, as it's very very easy to deal with, you dont have to make the window and handle all the messages and stuff, it's all made for you and you just use printf and scanf to interact with it (there are a couple of more things for visualizations, but whatever..), in a real project (i.e. Win32 project)(this is what GDK uses), you must create the window yourself, and handle all the windows messages yourself, GDK does all that for you, and it initializes all the directX stuff to be ready to function

the entry point of a DOS application is int main ( void ), but for a Win32 project it's int WINAPI WinMain ( HINSTANCE, HINSTANCE, LPSTR, int ), actually, GDK alreayd defined WinMain in it's code as the entry point, and inside that it calls DarkGDK, which is not defined in Dark GDK lib, its just declared in a header file or so, when you create a GDK project from the template, it actually creates a Win32 project with special configurations to fit the GDK needs, but you can notice that when you do so, the entry point is void DarkGDK ( void ), why? well actually it's not, as i said above, it's WinMain, but it's called inside GDK, and it calls DarkGDK which you defined right after initializations

so the DarkGDK library is a Win32 project, and the main.cpp (it's not main.cpp actually, but im saying this to make it clearer) code is more or less like this:


those names are not true, and might not exist, it could look way more different, but the general idea will still look the same

so GDK is a DirectX wrapper, all it does is to simplify the use of DirectX, and it does all the winAPI code for you too, it defines a couple of functions (dbSyncOn dbSyncRate dbMakeObjectSphere etc etc (all GDK functions -starting with db*-)), you just use these, and some std functions if you need, inside the DarkGDK body

this dbPrint("heyy"); might look similar to printf ("heyy"); for you, but it's not! it's very different, printf simply writes on the DOS window, but since GDK uses a winAPI window, it cannot just call this function to draw something, and since it's using DirectX, text is handled in a different way

conclusion: you can't use your own entry point as GDK already defines one, and you can't use GDK without DarkGDK function definition because it's being called inside the GDK's entry point and it has no definition and this will cause a linker error, you CAN'T use GDK with a DOS application, but you can do it if you create a Win32 application, but you will need to configure it manually - somewhat pointless to do if you have the wizards.

CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 26th Sep 2010 00:24
im very confused, what project type do I use to mix c++ and GDK??

I want coke, not Pepsi!
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 26th Sep 2010 04:35
If you have installed GDK then there should be a template listed for a GDK project. Click on File -> New -> Project and click on Wizards. There should be several Dark GDK choices. Open one of those and begin your project.

CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 26th Sep 2010 09:10
I know that, I mean using that with c++ #include <iostream>

I want coke, not Pepsi!
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 26th Sep 2010 12:44 Edited at: 26th Sep 2010 12:51
If you create a new Dark GDK project with the "game" template, you can include and use the C++ standard library functions as well. The only trick is to set this configuration variable in the project properties, otherwise you'll get linker errors:

Configuration properties, C/C++, Code Generation: Runtime library = MT (multi-threaded) and not MTd (multi-threaded debug).

Apart from that, you don't need to do anything special and you don't need to start from an empty project to include more C++ functionality. Start from the game template.

You cannot use cout and cin because those are for console programs. Even if you can call them, they won't write anything anywhere because the Dark GDK window is not a console window. But if you want to use file streams (ofstream, ifstream), vectors, strings, etc. functions of the standard library, they will work normally.

(Actually there was a thread recently on the forum about how to mix console output with Dark GDK. But if you already have a Dark GDK window, then it's easier to use the GDK functions to write debug prints into the graphic window.)
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 26th Sep 2010 17:17 Edited at: 26th Sep 2010 17:30
P.S. I found that thread with the console code. It opens a second window and uses that as the text console for cout. But you cannot use console and Dark GDK in the same window.

http://forum.thegamecreators.com/?m=forum_view&t=169941&b=22

Login to post a reply

Server time is: 2024-11-19 18:42:41
Your offset time is: 2024-11-19 18:42:41