Hello all, been a bit frustrated as of late with one of C++ programming projects. The problem goes like this:
I have a game engine-type thing going that has support for several different rendering APIs (not all simultaneously running, obviously, but you can switch between them at runtime with my console system.) Now in order for everything to play nice, I have a 'pipeline' class that acts as a layer of abstraction between the core engine update mechanics/other stuff it (engine) needs to do, like sound, input, so on, so forth. My problem boils down to this: When the CreateAPIInterface() message is sent to my pipeline class, it requests the setting corresponding to what rendering API should be used. This executes fine, however once it receives/parses the requested string, it *should* instantiate a new, dynamically-allocated instance of a derived renderer class tailored to use one of the four supported paths (DirectX9, 10, OpenGL 2.1, 3.0) Problem is, the 'new' instruction never completes. I can step through (using MSVC++ 2005) my program with the debugger and it just putzes out. No jumping to malloc.c, no heap allocation, nothing. Just putters out entirely. This has me frustrated beyond belief as I have never seen anything of the sort. On top of it all, C++ was supposed to eliminate this kind of oddity, as I understand it. Anyone have any advice/suggestions? I can provide code upon request, I didn't attach it off the bat due to size concerns.
2 1732
Show me the code from the function arguments to where the instantiation should occur.
-
#ifdef _WINDOWS
-
bool CRenderPipeline::CreateAPIInterface(HWND hWnd)
-
{
-
if(settingsManager->GetVar("r_renderPath") == "DIRECT3D9")
-
{
-
MessageBox(NULL, L"Direct3D9 mode activated!", L"", MB_OK);
-
renderInterface = new CRendererDX9;
-
-
renderInterface->InitializeGraphicsSubsystem(hWnd, settingsManager);
-
}
-
else if(settingsManager->GetVar("r_renderPath") == "DIRECT3D10")
-
{
-
MessageBox(NULL, L"Direct3D10 mode activated!", L"", MB_OK);
-
// renderInterface = new CRendererDX10(hWnd, settingsManager);
-
}
-
else if(settingsManager->GetVar("r_renderPath") == "OPENGL2.1")
-
{
-
// renderInterface = new CRendererOGL21();
-
return false;
-
}
-
else if(settingsManager->GetVar("r_renderPath") == "OPENGL3.0")
-
{
-
// renderInterface = new CRendererOGL30();
-
return false;
-
}
-
else
-
{
-
return false;
-
}
-
if(renderInterface)
-
{
-
InitializeOverlayInterface();
-
return true;
-
}
-
else
-
{
-
return false;
-
}
-
}
-
CRendererDX9 class implementation: -
#pragma once
-
-
#include "Renderer.h"
-
-
// DirectX stuff
-
#include "DirectX\d3d9.h"
-
#include "Windows.h"
-
#pragma comment (lib, "DirectX/libs/d3d9.lib")
-
-
class CRendererDX9 : public Renderer
-
{
-
public:
-
~CRendererDX9()
-
{
-
}
-
-
forceinline void DrawFrame()
-
{
-
d3dDeviceInterface->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
-
-
d3dDeviceInterface->BeginScene();
-
d3dDeviceInterface->EndScene();
-
-
d3dDeviceInterface->Present(NULL, NULL, NULL, NULL);
-
}
-
-
bool InitializeGraphicsSubsystem(HWND &targetWindow, CEngineSettingsManager* settings)
-
{
-
MessageBox(NULL, L"Intializing graphics subsystem...", L"", MB_OK);
-
d3dInterface = Direct3DCreate9(D3D_SDK_VERSION);
-
ZeroMemory(&framePresentationParameters, sizeof(framePresentationParameters));
-
// configure initial presentation parameters in here
-
if(bool(settings->GetVar("r_windowed")))
-
{
-
framePresentationParameters.Windowed = true;
-
}
-
else
-
{
-
framePresentationParameters.Windowed = false;
-
}
-
framePresentationParameters.BackBufferWidth = int(settings->GetVar("r_backBufferWidth"));
-
framePresentationParameters.BackBufferHeight = int(settings->GetVar("r_backBufferHeight"));
-
if(bool(settings->GetVar("r_useTripleBuffering")))
-
{
-
framePresentationParameters.BackBufferCount = 2;
-
}
-
else
-
{
-
framePresentationParameters.BackBufferCount = 1;
-
}
-
framePresentationParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
-
-
framePresentationParameters.hDeviceWindow = targetWindow;
-
// end presentation params
-
-
d3dInterface->CreateDevice(D3DADAPTER_DEFAULT,
-
D3DDEVTYPE_HAL,
-
targetWindow,
-
D3DCREATE_HARDWARE_VERTEXPROCESSING,
-
&framePresentationParameters,
-
&d3dDeviceInterface);
-
return true;
-
}
-
-
void ShutdownGraphicsSubsystem()
-
{
-
d3dInterface->Release();
-
d3dDeviceInterface->Release();
-
}
-
protected:
-
-
private:
-
LPDIRECT3D9 d3dInterface;
-
LPDIRECT3DDEVICE9 d3dDeviceInterface;
-
D3DPRESENT_PARAMETERS framePresentationParameters;
-
HWND windowHandle;
-
};
-
Base CRenderer class definition: -
#pragma once
-
-
#include "CommonDefs.h"
-
#include "MemoryPooledObject.h"
-
#include "EngineSettingsManager.h"
-
#include "Camera.h"
-
#include <string>
-
#include "Mathematics/Vectors.h"
-
-
using std::string;
-
-
#ifdef _WINDOWS
-
// windows header, for hWnd definition
-
#include <windows.h>
-
#else
-
// include whatever we need for Linux or OSX
-
#endif
-
-
-
class Renderer : public CMemoryPooledObject
-
{
-
public:
-
-
virtual ~Renderer();
-
-
virtual void DrawFrame()=0;
-
-
#ifdef _WINDOWS // building for Windows, we need the HWND for the window
-
virtual bool InitializeGraphicsSubsystem(HWND &targetWindow, CEngineSettingsManager* settings)
-
{
-
MessageBox(NULL, L"Warning, base renderer class InitializeGraphicsSubsystem() called!", L"", MB_OK);
-
return false;
-
}
-
#else
-
virtual bool InitializeGraphicsSubsystem();
-
{
-
}
-
#endif // _WINDOWS
-
-
virtual void ShutdownGraphicsSubsystem()=0;
-
-
static CCamera* currentView;
-
protected:
-
private:
-
};
-
Pipeline class: -
#pragma once
-
-
#ifdef _WINDOWS
-
#include "RendererDX9.h"
-
// #include "RendererDX10.h"
-
#endif
-
// #include "RendererOGL21.h"
-
// #include "RendererOGL30.h"
-
-
#include "Task.h"
-
#include "EngineSettingsManager.h"
-
#include "Thread.h"
-
#include "CommonDefs.h"
-
-
-
class CRenderPipeline
-
{
-
public:
-
CRenderPipeline(CEngineSettingsManager* _settingsManager);
-
~CRenderPipeline();
-
#ifdef _WINDOWS
-
bool CreateAPIInterface(HWND hWnd); // returns whether or not it succeeded
-
#else
-
bool CreateAPIInterface();
-
#endif
-
bool DestroyAPIInterface();
-
-
#ifdef _WINDOWS
-
bool ReCreateDevice(HWND hWnd); // called when settings are changed
-
#else
-
bool ReCreateDevice();
-
#endif
-
bool InitializeOverlayInterface();
-
-
void OnStart(void* passedInData);
-
-
forceinline unsigned int OnHeartbeat()
-
{
-
renderInterface->DrawFrame();
-
return 0;
-
}
-
-
protected:
-
-
private:
-
Renderer* renderInterface; // the "physical" system that communicates with the API
-
CEngineSettingsManager* settingsManager; // we retrieve various parameters and settings here so we may as well keep the address permanently
-
CRenderPipeline(const CRenderPipeline &pipeline); // copying this seems stupid, deny the ability to do so
-
#ifdef _WINDOWS
-
HWND window;
-
#else
-
#endif
-
};
-
-
There ya go. Let me know if I'm missing anything, and I'd be happy to fill you in.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jimmy Johns |
last post by:
Hi, I have some classes as follows:
#include <iostream>
using namespace std;
class A {
public:
virtual A* clone() const = 0;
};
|
by: Beach Potato |
last post by:
I guess I've been out of C++ for a while, since right now I don't seem
to get a simple solution for overriding inherited constrictors.
What worked in Borland C++ & Pascal (and Java, if I remember...
|
by: Jochen Zeischka |
last post by:
Hello,
I just tried something with multiple inheritance and I have a problem with
the construction of my object.
There's a base class Base, containing an integer. The base class has 2
derived...
|
by: Doug |
last post by:
I have a public abstract class that I want to inherit from in two other
classes. My public abstract one has a constructor with several
parameters. For some reason I cannot get to that constructor...
|
by: Russ Ford |
last post by:
Hi all,
I'm trying to get inheritance and constructors clear in my head (and
in my code). I have the following inheritance situation (all
derivations public):
A is the base class
B is...
|
by: hazz |
last post by:
The following classes follow from the base class ' A ' down to the derived class ' D ' at the bottom of the inheritance chain.
I am calling the class at the bottom, "public class D" from a client...
|
by: Kevin Buchan |
last post by:
I searched the news group and could not find an answer to this question, so
I'll go ahead and post it.
Let's say I have a class A with a couple different constructors... nothin'
special.
Now,...
|
by: andrewfsears |
last post by:
I have a question: I was wondering if it is possible to simulate the
multiple constructors, like in Java (yes, I know that the languages are
completely different)?
Let's say that I have a class...
|
by: Adam Nielsen |
last post by:
Hi everyone,
I'm having some trouble getting the correct chain of constructors to be called when creating an object at the bottom of a hierarchy. Have a look at the code below - the inheritance...
|
by: Peng Yu |
last post by:
Hi,
I want B has all the constructors that A has. Obviously, the code
below would not work. I could define a corresponding B's constructor
for each A's constructor. But if A has many...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| | |