Power render and C++

Started by
16 comments, last by Azrael 23 years, 10 months ago
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
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++.
Creativity is a bloody nuisance and an evil curse that will see to it that you die from stress and alcohol abuse at a very early age, that you piss off all your friends, break appointments, show up late, and have this strange bohemian urge (you know that decadent laid-back pimp-style way of life). The truly creative people I know all live lousy lives, never have time to see you, don't take care of themselves properly, have weird tastes in women and behave badly. They don't wash and they eat disgusting stuff, they are mentally unstable and are absolutely brilliant. (k10k)
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.
Hardcore Until The End.
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!
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.
Creativity is a bloody nuisance and an evil curse that will see to it that you die from stress and alcohol abuse at a very early age, that you piss off all your friends, break appointments, show up late, and have this strange bohemian urge (you know that decadent laid-back pimp-style way of life). The truly creative people I know all live lousy lives, never have time to see you, don't take care of themselves properly, have weird tastes in women and behave badly. They don't wash and they eat disgusting stuff, they are mentally unstable and are absolutely brilliant. (k10k)
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...

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
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
Creativity is a bloody nuisance and an evil curse that will see to it that you die from stress and alcohol abuse at a very early age, that you piss off all your friends, break appointments, show up late, and have this strange bohemian urge (you know that decadent laid-back pimp-style way of life). The truly creative people I know all live lousy lives, never have time to see you, don't take care of themselves properly, have weird tastes in women and behave badly. They don't wash and they eat disgusting stuff, they are mentally unstable and are absolutely brilliant. (k10k)
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
Hardcore Until The End.
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!?
Hardcore Until The End.

This topic is closed to new replies.

Advertisement