Skip to main content
gamedev.net
🔒 Locked

C++ PowerRender Wrapper

Started by Amadrias Apr 3, 2001 at 6:32 AM 18 replies 800+ views
Original Post
Amadrias
Amadrias
Hi, I am considering building a C++ Wrapper for the common tasks in PowerRender and before working on it, I would like to know if someone already worked on that. I rather work in C++ as I prefer OO programing and modelisation. Let me know ! Amadrias France
ANSI2000
ANSI2000
Actually a w hile back I had tried to initiate something like that! Was a bit harder because PR had globals and structures all over the place.

Should be easier now, all pertinant info is within one structure.

If you need help I can get back into it. I called the libs Extended PR.

Once thing you will notice is alot of the things are done manually in PR, wrappers would be nice
Amadrias
Amadrias
As I am right now trying to learn most of PowerRender, it will be difficult to try to wrap everything in classes.

However, I am right now making my own game with my team and I''ll make a C++ wrapper as I go through its development.

I will sometime release it if I got Chris Agreement of course ;-)

Amadrias
France
ema
ema
Yes!
It should be useful!!!!!!
The cpp example in PR4 is only a superficial try to encapsulate the models in a class. But it shuld be very interesting and useful to have all in OO.

So, if you need help, I should do it. And when you will have some ready, please share it, if chris agree of course...

By,
ema
Amadrias
Amadrias
All right,

Since it seems that we are more than three interested in the OO PowerRender, I''ve already worked on it.

I had structured it this way:

Each class will be defined using CPR at the beginning.
Following are the classes and methods created so far.

Classes:

//This is the main Application entry point. It initilializes the PR Engine, creates and initialize a viewport and a camera, and manages application status (as explained by André LaMothe)
class CPRApp
{
public:
CPRApp(); // Constructor
CPRApp(bool IsDebugMode); // sets windowed mode for debug
virtual ~CPRApp(); // Destuctor
bool Init(PR_DWORD screenwidth,PR_DWORD screenheight,PR_DWORD screenrefreshrate) // Initialize the PR engine, creates viewport and camera. Return false when failure
bool Run() // Main Event loop. Here we''ll find a Game State Manager that will react differently between START,LOADING,RUNNING,PAUSE,MENU,SHUTDOWN. Return false when finished or in critical failure.
bool Done() // Free all memory before exiting
private:
CPRViewPort *theviewport; // One viewport class instance (I will add a real viewport manager later if you want to manage several viewports)
CPRCamera *thecamera; // One camera class instance (I will add a real camera manger later if you want to manage several cameras)
}

class CPRViewPort
{
public:
CPRViewPort();
~CPRViewPort();
bool Init(PR_DWORD x0,PR_DWORD y0,PR_DWORD x1,PR_DWORD y1);
private:
PR_VIEWPORT viewport; // PR Viewport structure
}

class CPRCamera
{
public:
CPRCamera();
~CPRCamera();
bool Init(PR_REAL sourcex,PR_REAL sourcey,PR_REAL sourcez,PR_REAL targetx,PR_REAL targety,PR_REAL targetz) // Initialize camera and sets the camera source and target points
private:
PR_CAMERA *camera; // PR camera structure
}

For now that''s all that I have done, I will add a World Manager where you''ll create and instantiate 3D objects and levels...

Still, I have a problem with the camera class as when I execute an application using it, it crashes when I PR_InitializeCamera(thecamera) with a "Memory Violation Access" message.
Any help would be great!

Amadrias
France
Nat
Nat
Hi..
I have made someadditions to Extended PR. This was around the same time Ansi2000 put it out. Anyways I added sound, keyboard and mouse support. Anyways . do give me your feed back on it..
You can get it at the PR ftp site in User Uploads

Nat
~~~º¥º -
Amadrias
Amadrias
I have downloaded the EPR file and exctract it...

It seems that some parts of it are set for DIrectX7... would you have a DirectX8 version of it or should I have a look and change the code myself ?

Thanks,

Amadrias
France
Nat
Nat
Yes! it is for dx7. Well! I have not changed it. Well I don''t think it would be at all difficult to change it. Give it a Go. Best Option would be to take the PR4 Beta C++ project and replace the files from EPR

Nat
~~~º¥º -
Amadrias
Amadrias
I''ve already done it but it is not sufficient. There is some changes with the header files to include and some functions do not work anymore.

As I don''t know the code as you do, maybe you could do it?
Else, I''ll do it!

Amadrias
France
Nat
Nat
Ok.. Done
It is in user uploads ( pr4epr.zip)
~~~º¥º -
Amadrias
Amadrias
Thanks Nat,

Very useful... It helped me a lot with a memory problem I had with cameras.

Now, I''m gonna use ExtendedPR as an example on how to create the wrapper and I have found, I think, a better way to abstract all these calls to PR. I would then build a totally new wrapper I will call :
xPRience

The goal is to separate all the Parts of a game into the following main classes:

xPRApp // The Application Manager
xPRAppStates // Are sub applications instances that will be used to handle parts specific event loops and logic.
xPR3DEngine // This will do all the 3D related stuff
xPR2DEngine // Same but for 2D
xPRInput // Will handle all the Keyboard,Mouse and Joystick calls and initialization
xPRSound // For the Sound
xPRMusic // For the Music

Then, inside each of these main classes we will found all the specific classes such as Viewports and Cameras and so forth...
But the main control will be made by these classes.

As soon as I have something interesting to show, I''ll make post.

Amadrias
France

P.S. : I got a strange feeling... Aren''t we working with PR as if we were working for a GPL product... ;-)
Nat
Nat
Great!... Let me know when it is done.

Have a nice day..

Nat
~~~º¥º -
ANSI2000
ANSI2000
Cool I am surprised it went that far, cheers to nat
Amadrias
Amadrias
hi guys,

Here is a little update on the xPRience C++ Wrapper for PowerRender.

I have quite well progressed and everything seems to work fine (so far).

Following is an example of the code needed to initiate a xPRience Application that sets 640x480 resolution, one keyboard input, one viewport, one camera, one world where to add objects (to be done), add an application state to the Application (used to manage different stages of a game such as LOADING_LEVEL or PLAYING) and waits the user for pressing the KEY_ESC.

xPRGlobal.cpp
/*
Global Application Entry Point
*/

/*
Header Includes
*/
#include "xPRGlobal.h"
#include "xPRApp.h"
#include "AS_Test.h"

/*
Forward Declarations
*/
xPRApp *theApp = new xPRApp(1000,32,32,640,480);
AS_Test *TestAppState = new AS_Test(AS_BEGIN,theApp);

/*
Main Function
*/
void main(int argc,char *argv[])
{
PR_Settings.UseWindowed=1;
theApp->InitVideo();
theApp->InitInput(1,XPR_KEYBOARD);
theApp->AddAppState(TestAppState,AS_BEGIN);
theApp->Run();
theApp->Done();
delete theApp;
delete TestAppState;
exit(0);
}


xPRGlobal.h
/*
Class Header
*/

#ifndef __XPRGLOBAL_H
#define __XPRGLOBAL_H

/*
Header Includes
*/
#include // PowerRender Header Include
#include // Windows Utilities Header Include

/*
Forward Declaration
*/
#define MAX_INPUT_CONTROLS 3 // Maximum number of Input Controls to set
#define MAX_CAMERAS 1 // Maximum number of Cameras to set

#define APPSTATES_NUMBER 1
#define AS_BEGIN 0 // AppState Index for Beginning
#define AS_FINISH 100 // AppState Index for Finishing (Change it to more if needed)


#endif

AS_Test.h
// AS_Test Header

#include "xPRAppState.h"

class AS_Test : public xPRAppState
{
public:
AS_Test(int index,xPRApp *MotherApp):xPRAppState(index,MotherApp){}
int Run();
};

AS_Test.cpp
// AS_Test Source Code

#include "AS_Test.h"

int AS_Test::Run()
{
while(!kbdon[KEY_ESC])
{
UpdateMessages();
}
return AS_FINISH;
}

Hope that you''ll find this as useful as I do.

Next Updates:
- Add 3DWorld Objects manager to World Class
- Add better Settings Manager to Application and AppState Classes

Amadrias
France
Nat
Nat
I think we can keep the C++ wrapper open source and everybody can add their bit to it. I think modifications should be uploaded into User Uploads on a weekly basics so that everybody has access to it.

Lets keep it going
~~~º¥º -
Amadrias
Amadrias
The C++ Wrapper I have been working on was only a test and my view to get the games organized. I am not sure at all that it will fit for all games but it should be sufficiently flexible to allow any game to be developed.

However, before making any decision about it, I NEED CHRIS INPUT on that forum.
As the C++ Wrapper I am working on is based on PowerRender Code I can not distribute it without Chris agreement and I do not think it fits in something OpenSource neither.

Imagine that with that C++ Wrapper, you won't need PR headers anymore as they would be headen in a dll and some of the C++ xPRience libs.

I do not think it is fair for Chris and I do not want to do something that could be bad for him. I just like this talented guy.

Chris, please have a post in this forum to give us some of your thoughts.

By the way, just to answer "ddn", the wrapper is not finished and is just as its beginning.

Amadrias
France

Edited by - amadrias on April 13, 2001 6:11:03 AM
ChrisE
ChrisE
I don''t want any DLL''s distributed that could be used without having the static libraries.

Other than that I have no problems. I just wonder how this will fit in with LStudio and all the work I''ve been doing on the high level engine.


Author of Power Render (http:/www.powerrender.com)
Amadrias
Amadrias
Chris, I didn't looked at the Lstudio yet as I am understanding all the basic routines and turn them in an abstract way represented by the classes available in xPRience.

As soon as I'll get something really interesting, I'll make sure you have the source and the dlls in order to have you in the pipe.

This way, you'll be able to tell if yes or no, this can be used.

By the way, Chris, what are youtalking about when speaking about high level engine ?

Amadrias
France

Edited by - amadrias on April 14, 2001 11:54:47 AM
ChrisE
ChrisE
High level engine is all this stuff:
\pr4\utility\lstudio\TerrainEngine\src


Author of Power Render (http:/www.powerrender.com)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.