Setting up C++
by Dmitriy Safro · in Torque Game Builder · 03/04/2005 (12:08 pm) · 13 replies
Hello all,
Im new, and just got the T2D SDK. First impressions are good, particles look sweet, GUI editor is nice, and I havent looked at tilemaps yet.
Current game im making is already half way done with DirectX, I have binary file access, INI file reading, and drawing QUADS from 4 arbitrary point with different colors and alpha values.
Question is, how hard is it to set up the C++ environment and get all those things to work? I havent looked at the source yet, but will do that soon. What I need to know is should I watch out for any pitfalls? I want the game to be all 3 platform compatible, anything I should keep in mind? like the binary file access?
Also.. My current game uses a special timing execution. I picked it up from Gamasutras artile 'Instant Replay'. This executes code at a certain frequency, but renders every frame. This way the game is still frame rate independant, but if its slower than specified it executes code a few times before rendering. This allowes me to save game replays easily, and make sure they get replayed the same exact way every time, because the game goes through the same game states every time.
I will look into T2D further, and I definitely need to do this in C++ and not the scripts, hopefully I'll be able to use both for maximum results.
thanks,
Dima
Im new, and just got the T2D SDK. First impressions are good, particles look sweet, GUI editor is nice, and I havent looked at tilemaps yet.
Current game im making is already half way done with DirectX, I have binary file access, INI file reading, and drawing QUADS from 4 arbitrary point with different colors and alpha values.
Question is, how hard is it to set up the C++ environment and get all those things to work? I havent looked at the source yet, but will do that soon. What I need to know is should I watch out for any pitfalls? I want the game to be all 3 platform compatible, anything I should keep in mind? like the binary file access?
Also.. My current game uses a special timing execution. I picked it up from Gamasutras artile 'Instant Replay'. This executes code at a certain frequency, but renders every frame. This way the game is still frame rate independant, but if its slower than specified it executes code a few times before rendering. This allowes me to save game replays easily, and make sure they get replayed the same exact way every time, because the game goes through the same game states every time.
I will look into T2D further, and I definitely need to do this in C++ and not the scripts, hopefully I'll be able to use both for maximum results.
thanks,
Dima
#2
Are you running on a Windows platform? The Visual Studio project files worked flawlessly for me (which is actually a very rare experience where I'm concerned).
Anyway, keep hunting, you're in good hands here.
03/04/2005 (2:36 pm)
As far as I know there is no detailed engine documentation at this point. I know they're planning it for the future, but for now you'll have to sift your way through the code and try and make heads or tails of it. It is generously commented in a lot of areas, but I'd say familiarity with C++ is a must.Are you running on a Windows platform? The Visual Studio project files worked flawlessly for me (which is actually a very rare experience where I'm concerned).
Anyway, keep hunting, you're in good hands here.
#3
So all I have to do is use the project files that came with it and just add my own code? Or do I need to set up my own main files and link to the engine?
I really need to be able to code in C++, I am familiar with it. Here is wat I need to port over: http://www.chrysb.com/rox
Alot of custom code was already written, and everything works great. My only thought was that with T2D i could easily port the code over for all 3 platforms. Doesnt seem too easy now, as I have to first figure out how the engine works and how to do custom stuff.
03/04/2005 (3:12 pm)
Hm, I do use VS.NET on windows platform. So all I have to do is use the project files that came with it and just add my own code? Or do I need to set up my own main files and link to the engine?
I really need to be able to code in C++, I am familiar with it. Here is wat I need to port over: http://www.chrysb.com/rox
Alot of custom code was already written, and everything works great. My only thought was that with T2D i could easily port the code over for all 3 platforms. Doesnt seem too easy now, as I have to first figure out how the engine works and how to do custom stuff.
#4
I will dedicate a portion of my time back on this thread over the weekend. I really do enjoy discussing the low-level details and I'd like the opportunity to see how I can help you and hopefully explain a few things to people reading this thread who also want to do a similar thing.
T2D is based upon TGE (T3D) which as you're probably well aware by now is a huge volume of code. What I can't help you with is turning this volume of code into some kind of simplistic library with a single main-loop as that's just not where T2D is going to go. I'll leave that kind of thing for 2D libraries.
I can help you with hooking your old code into T2D, creating custom rendering objects, inherting some of the neat features of T2D in your premade objects and more.
It'll probably take quite a while if we are to cover alot of subjects so I'd ask you to prepare a list of things that you need to achieve, otherwise we'll end up discussing too many subjects in one go and we won't get anywhere.
Post up a list of tasks that you'd like to get running in T2D and I'll see how I can help you get there.
As I said before, T2Ds power lies in the ability to do a majority of your game logic in scripts and do the higher-performance stuff in C++. You're working against T2D and TGE by trying to do everything in C++. One of the things I tried to maintain in T2D was to ensure that the script-calls (in the reference documentation) as identically named in the C++ so you can fully understand nearly all the public calls if you understand the script calls.
This is why I urge people to play with the script stuff, even if they are set on using C++.
- Melv.
03/04/2005 (3:32 pm)
@Dmitriy: I'm a C++ guy. T2D scripts are extremely powerful and you can write full games with them but please be assured that I wrote the C++ side of things so that you can customised T2D for yourself. Custom objects, custom-updates, whatever. I'm about to go to bed because it's very late over here and I've been answer questions all day (14 hours) and I need to sleep!I will dedicate a portion of my time back on this thread over the weekend. I really do enjoy discussing the low-level details and I'd like the opportunity to see how I can help you and hopefully explain a few things to people reading this thread who also want to do a similar thing.
T2D is based upon TGE (T3D) which as you're probably well aware by now is a huge volume of code. What I can't help you with is turning this volume of code into some kind of simplistic library with a single main-loop as that's just not where T2D is going to go. I'll leave that kind of thing for 2D libraries.
I can help you with hooking your old code into T2D, creating custom rendering objects, inherting some of the neat features of T2D in your premade objects and more.
It'll probably take quite a while if we are to cover alot of subjects so I'd ask you to prepare a list of things that you need to achieve, otherwise we'll end up discussing too many subjects in one go and we won't get anywhere.
Post up a list of tasks that you'd like to get running in T2D and I'll see how I can help you get there.
As I said before, T2Ds power lies in the ability to do a majority of your game logic in scripts and do the higher-performance stuff in C++. You're working against T2D and TGE by trying to do everything in C++. One of the things I tried to maintain in T2D was to ensure that the script-calls (in the reference documentation) as identically named in the C++ so you can fully understand nearly all the public calls if you understand the script calls.
This is why I urge people to play with the script stuff, even if they are set on using C++.
- Melv.
#5
I'll also say that looking for the script functions within the code really does help understand the inner workings of T2D. In case you haven't noticed already, all of the script functions are wrapped in macros. All you need to do is look for references to ConsoleFunction and ConsoleMethod to see the calls that are exposed to TorqueScript. Also, from a previous Melv post, the script has no main loop. It is purely event based so the .cs files are read-in and compiled during startup and only the callback functions are ever touched again.
I don't know if that helps at all, but perhaps it gives you something to look for while you await Melv's help.
03/05/2005 (5:55 am)
@Dmitriy: In addition to Melv's comments (and let's face it, he is the source) I just wanted to let you know that when I loaded up the .sln file from the VC7 folder I was able to compile T2D with no problems. As a matter of fact, I'm now using my compiled T2D.exe instead of the one shipped with the install.I'll also say that looking for the script functions within the code really does help understand the inner workings of T2D. In case you haven't noticed already, all of the script functions are wrapped in macros. All you need to do is look for references to ConsoleFunction and ConsoleMethod to see the calls that are exposed to TorqueScript. Also, from a previous Melv post, the script has no main loop. It is purely event based so the .cs files are read-in and compiled during startup and only the callback functions are ever touched again.
I don't know if that helps at all, but perhaps it gives you something to look for while you await Melv's help.
#6
Torque / T2D is already set-up to do this. :) Every 32 milliseconds, the Torque platform issues a "tick", at which point the sim can be updated. You can access this tick info in either C++ or script. Check out the fxSceneTicker2D class, as well as the updateScene method (onUpdateScene in script).
Doing what you want to do here is very easy in either C++ or script. I'd actually recommend using script, but you can do whichever you prefer. Probably the best way to get an answer is for you to check out the stuff referenced above and then come back with more specific questions. And as Melv says, if you have a particular list of "things I want to do" for your game, post some of 'em, and we can point you in the right directions.
03/05/2005 (10:53 am)
Hi Dmitry,Quote:.. My current game uses a special timing execution. I picked it up from Gamasutras artile 'Instant Replay'. This executes code at a certain frequency, but renders every frame. This way the game is still frame rate independant, but if its slower than specified it executes code a few times before rendering. This allowes me to save game replays easily, and make sure they get replayed the same exact way every time, because the game goes through the same game states every time.
Torque / T2D is already set-up to do this. :) Every 32 milliseconds, the Torque platform issues a "tick", at which point the sim can be updated. You can access this tick info in either C++ or script. Check out the fxSceneTicker2D class, as well as the updateScene method (onUpdateScene in script).
Doing what you want to do here is very easy in either C++ or script. I'd actually recommend using script, but you can do whichever you prefer. Probably the best way to get an answer is for you to check out the stuff referenced above and then come back with more specific questions. And as Melv says, if you have a particular list of "things I want to do" for your game, post some of 'em, and we can point you in the right directions.
#7
Any help?
03/16/2005 (2:10 pm)
Tried to build T2D in VC .net as a debug version and then as a release version. Both result in the following link error:Quote:The first time I opened the project from the T2D.vcproj file. The second time I opened the project from the T2D.sln file.
fatal error LNK1104: cannot open file 'ljpeg.lib'
Any help?
#8
You need to build all the "libs" as well as the executable. That is the JPEG library.
Select all the projects in the solution to build.
- Melv.
03/16/2005 (2:48 pm)
Joe,You need to build all the "libs" as well as the executable. That is the JPEG library.
Select all the projects in the solution to build.
- Melv.
#9
I am running VC7 Torque 1.4 and release compiles fine I just get this when I compile the debug:
Torque Demo fatal error LNK1104: cannot open file 'ljpeg.lib'
I have tried building the whole solution and even building both the debug and release ljpeg projects. but nothing seems to work.
EDIT: another odd thing is I thought it should be looking for the debug version of ljpeg.lib I have checked all of the project settings and build options and everything says debug :S
EDIT 2: It also is outputting it all the out.VC6.DEBUG :S
12/23/2005 (10:29 am)
I am having the same issue with the ljpeg.lib not being able to open....I am running VC7 Torque 1.4 and release compiles fine I just get this when I compile the debug:
Torque Demo fatal error LNK1104: cannot open file 'ljpeg.lib'
I have tried building the whole solution and even building both the debug and release ljpeg projects. but nothing seems to work.
EDIT: another odd thing is I thought it should be looking for the debug version of ljpeg.lib I have checked all of the project settings and build options and everything says debug :S
EDIT 2: It also is outputting it all the out.VC6.DEBUG :S
#10
LOL
I got it to compile by changing the name of the output directory to out.VC7.DEBUG
not sure why the project is set up to output and read from different directories because I am using a fresh build from the .exe setup. :P
_____________________________________________
EDIT: back again my project is screwed :(
no exe was generated even though it said it was and now it is giving me the freaking ljpeg error again
12/23/2005 (11:14 am)
_____________________________________________LOL
I got it to compile by changing the name of the output directory to out.VC7.DEBUG
not sure why the project is set up to output and read from different directories because I am using a fresh build from the .exe setup. :P
_____________________________________________
EDIT: back again my project is screwed :(
no exe was generated even though it said it was and now it is giving me the freaking ljpeg error again
#11
... but are you having the same problem with T2D as this is currently TGe v1.3? Are you merging the two? This is really a TGE build issue in that case.
Either way, you need to ensure that you're building all the libraries, particularly the zlib one as other libraries depend on it. Make sure that they are being built; try using the batch build facility in VC7.
- Melv.
12/24/2005 (1:11 am)
Quote:I am running VC7 Torque 1.4
... but are you having the same problem with T2D as this is currently TGe v1.3? Are you merging the two? This is really a TGE build issue in that case.
Either way, you need to ensure that you're building all the libraries, particularly the zlib one as other libraries depend on it. Make sure that they are being built; try using the batch build facility in VC7.
- Melv.
#12
Had this issue with T2D 1.02 as well, after setting the solution start to the correct part, the problem disappeared.
12/24/2005 (3:27 am)
Problem with the solution is, that it has the wrong part as "main" set. This results in libjpeg not being built first.Had this issue with T2D 1.02 as well, after setting the solution start to the correct part, the problem disappeared.
#13
- Melv.
12/24/2005 (5:17 am)
Well, getting T2D to build is real easy. You might want to try the alpha#2 solution which I believe had an update to ensure everything is built in order. Download that one to see the correct build dependancies etc.- Melv.
Dmitriy Safro
I've looked over the source, and must admit I am a bit confused. I am not that good at C++, but here I couldnt figure out waht is going on. So much code....
I need to be able to do custom work with the code, as mentioned before, quads are a must, as I nee to draw each vertex with different colors and alphas. Also i need to be able to pull each vert away to create non tiled looking tilemaps, hehe
scripts are all great and stuff, but for my perpose I dont think they'll cut it. Is there a plan for some tutorials gon how to set up C++ and get stuff going with it? I hope so, cant do everything I need with scripts.