Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Azrael

Power render and C++

This topic is 6601 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is an important topic about PR, So I think i could start a thread about it, heres a few pointers about using PR and C++ 1.-Power render is pure C This is probably the most important point, using C++ OOP and PR must be considered as PORTING it will work but it wont be "automatic switching". 2.-Use globals, some variables in PR need to be accessed by almost all functions, the best way to do this is to use globals, this totally brakes OOP laws, but it works so what the heck? Some globals recomended to be used... viewport, cameras, terrain, etc. if a variable is giving you problems to access it, use it as a global. Eventually you could make them work into a class somehow, but my advice is to simply avoid the headache and make it work as a global. 3.-Some things wont work as C++ There are some PR functions, variables,methods that wont work from inside a class, like callback functions and such, learn what this are, and take them out of the class and to another c file then call it as an extern c. 3.-Use Extern C, this will solve a lot of problems... you can use an actual function from c in c++ with total c syntax by using this carefully. 4.-Remember to change .c to .cpp this solves problems, and yes in the heat of a project and a deadline you can forget that classes wont work in .c files 5.-changing the winutil.c is possible, of course it is, as a matter of fact winutil didnt existed back in PR 2.5 and it still worked, thats like saying you cant make landscapes without landscape studio. It just gets a bit more dificult... and you will probably have to touch win32 and dx coding, newbies should avoid this. extra tip for visual c++ users: are you tired of seing the pr dialog?, just take it off your project and compile it, pr will switch to defaults automatically, you will have to put settings by hand if you are not using defaults but is nice to know. I usually do this for quick testing, and add a dialog for release(a modified dialog that is) 6.-Check the oop example very, very carefully to see more pointers. 7.- add your pointers and opinions, to this thread

Share this post


Link to post
Share on other sites
Advertisement
...must be considered as PORTING...

Not really. ;-)

...this totally brakes OOP laws...

Truthfully, a mix of procedural and OOP programming can be a good thing. Bjarne said so himself.

...you can use an actual function from c in c++ with total c syntax by using this carefully.

Generally it''s not syntax, as C++ and C are nearly identical, it''s the linking methodology. C creates fairly clean linking names, and C++ creates fairly cluttered, gruesome names. By saying "extern ''C''", you''re saying to use the C linking convention and thereby be able to look for the info in the C LIB file by it''s C name, not the C++ name.

..yes in the heat of a project and a deadline you can forget that classes wont work in .c files...

Then you need a little positive reinforcement. ;-)

You can force the compiler to treat C files as C++ or the other way around, but that''s really a bad option, as it invites the really bad behaviour of actually doing so.

==

In the end, it''s really just common sense using PR with C++.

Share this post


Link to post
Share on other sites
Well you can wrap up pr within classes. If lets say one part of pr needs acces to the other just write up classes that will return the varibale need to the other system. Anyways I was writting something unfortunanlty wiork got me so < iwll try to finish this soon


Also the way I do it most of the time for c/c++ is...


I will write my ddraw studd using play oll c style procedures, and for example I will write a sprite class...

Another thing thats has ppl confused is things like malloc and new, sometimes within my class I will use mallonc instead of new but to allocate memory space for a certain data type.

Share this post


Link to post
Share on other sites
I''m using PR with C++. There are some issues... The C/C++ mix gets messy. There are some issues creating wrappers... But in the long run, it turns out pretty well. Yesterday I got the initialization to work. Looks good, darn it!

Share this post


Link to post
Share on other sites
The C/C++ mix gets messy.

Ouch. Blanket statement!

Not necessarily - ANYTHING can get messy. A mix can sometimes be an elegant solution to a problem.

Share this post


Link to post
Share on other sites
perhaps you guys you guys could help me with this..
im trying to turn land1 into c++.
So I simply went in and changed everything to .cpp
i got a bunch of errors as expected... I fixed the ->lptbl declarations and all, no problem there...
But some functions like function callbacks.. give an error like this:
unable to convert from function (___cdecl)(void *) to X
you should use C-style conversion or casting...
I tried to solve it using the offending function outside as a separated c file and calling it like an extern "C" (this had worked before), but it didnt worked neither...

on a side note...im trying to use STL code for the first time, but I always get an error at this line...
list something;
I always get a sintax error when compiling this. thanks I apreciate your help...

Share this post


Link to post
Share on other sites
I don''t know what to tell you... I usually got those errors during linking, not compiling... I used to have a bunch of unresolved externals. Moving them to .c, usually helped. But your case... I think it''s more of a question to Chris

Share this post


Link to post
Share on other sites
unable to convert from function (___cdecl)(void *) to X...

Could you tell me what "X" is? How about showing the declarations?

on a side note...im trying to use STL code for the first time, but I always get an error at this line...
list something;


STL is the Standard Template Libary...meaning they're templates. Thereby, you need to specify what the list is of, like:

list[CMyObject] MyObjectList;

or

queue[CMyObject] MyObjectQueue;

replace the square brackets with angle brackets, of course.

Edited by - revolver on June 16, 2000 2:17:40 PM

Share this post


Link to post
Share on other sites
First of .c or .cpp is just a file extension, you can name your files what ever you want and use any type of extension you want

Share this post


Link to post
Share on other sites
First of .c or .cpp is just a file extension, you can name your files what ever you want and use any type of extension you want or are you guys jusr refering the .c and .cpp as the languages!?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!