Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


monamimani

Member Since 02 Feb 2011
Offline Last Active Jan 29 2014 07:28 PM

Topics I've Started

Graphics class hierarchy design

02 October 2013 - 07:12 PM

Hi,

 

I am making a renderer and I have set some goals that i want to acheive because i find them ideal to get a clean design. But I have been thinking and trying to make them happen but I can't find a way. So I am turning to you all for some help and ideas.

 

- First I want to separate common, reusable code from platform specific code and I want to make it impossible for other than the responsible project to be able to include platform specific header like, opengl.h, d3d.h, ....

- Second I want to separate the "graphics object" ( like vertex buffer, mesh, device, texture) and the renderer algorithm ( deffered renderer, forward + renderer)

 

So those goal gave me 4 projects. Lets call them DefferedEngine, OglDefferedEngine, Graphics  and OglGrpahics. Those are actually 4 static lib that link in a GraphicsSystem dll. 

 

- Third the platform is known at compile time so I don't want virtual function. ( This is what caused most of my problems)

 

 

I tried the static polymorphism with CRTP but it is a nightmare... Everything that use the type trough the base class need to be templated. Imagine the device class each create function ( create vertex buffer, create index buffer, create texture) are actually templated with different return type.

 

I am pretty sure someone have to have done this before. how did you do it?

 

thanks alot

 

Emmanuel


Design portable vertex declaration

15 July 2013 - 08:32 PM

Hi all,

 

I am a bit stuck I my project and I thought i would come by and seek internet wisdom :)

 

Here is where I am. I am at the point where I have a generic Mesh. It contain a generic VertexBuffer that have different vectors for positions, normals, texcoords, ... As you can see this is platform agnostic.

So I am at the junction between the agnostic code and platform specific. I am wondering if I should just give the generic vertex buffer to Ogl/D3D mesh ( via a common interface, aka virtual function) of if I should construct some platform agnostic vertex declaration to give to the specific implementation with the vertex buffer.

 

Anybody as ideas on this?

 

Thanks

Emmanuel


Class offset with its Base in Multiple inheritance

11 September 2011 - 03:54 PM

Hi all,

I am trying to compute the memory offset of a base class with its parents in a multiple inheritance scenario, I hope to find a general solution the would work for simple and multiple inheritance with or with out virtual function or virtual inheritance.

This is my function to compute the class offset.

   template<typename ClassType, typename ParentType>
 	ptrdiff_t GetClassOffset()
      {
 		static_assert(std::is_base_of<ParentType, ClassType>::value, "The parent type is not the base type of the class type.");

 		constexpr size_t max_size = sizeof(ClassType) + sizeof(ParentType);
        const ClassType* classType = reinterpret_cast<const ClassType* >(max_size);
 		const ParentType* baseType = static_cast<const ParentType* >(classType);

 		uintptr_t classTypeOffset = reinterpret_cast<uintptr_t>(classType);

 		uintptr_t baseTypeOffset = reinterpret_cast<uintptr_t>(baseType);

 		return classTypeOffset - baseTypeOffset; 
      }



And I am testing with those classes

   [code]
   /// First Parent
      class Parent1
      {
 		int dummy;
      };
      /// Second Parent
      class Parent2
      {
           	int dummy;
      };

      /// Third Parent
      class Parent3
      {
 		int dummy;
      };

      /// Fourth Parent
      class Parent4
      {
 		int dummy;
      };

      /// Fifth Parent
      class Parent5
      {
 		int dummy;
      };      

      class MultipleInheritance: public Parent1, public Parent2, public Parent3, public Parent4, public Parent5
      {
 		int dummy;
      };

[/code]



I then tested with this code

[code]
     	std::cout << "Class offset of MultipleInheritance class with " << std::endl;
     	std::cout<< "MultipleInheritance: " << GetClassOffset< MultipleInheritance, MultipleInheritance>() << std::endl;
     	std::cout<< "Parent1: " << GetClassOffset< MultipleInheritance, Parent1>() << std::endl;
     	std::cout<< "Parent2: " << GetClassOffset< MultipleInheritance, Parent2>() << std::endl;
     	std::cout<< "Parent3: " << GetClassOffset< MultipleInheritance, Parent3>() << std::endl;
     	std::cout<< "Parent4: " << GetClassOffset< MultipleInheritance, Parent4>() << std::endl;
     	std::cout<< "Parent5: " << GetClassOffset< MultipleInheritance, Parent5>() << std::endl;

And the result was:


Class offset of MultipleInheritance class with
MultipleInheritance: 0
Parent1: 0
Parent2: -4
Parent3: -8
Parent4: -12
Parent5: -16


What i don't understand is why the offset of the class MultipleInheritance with Parent1 is 0 shouldn't it be -4? and thus everything else would be offseted by 4? Maby the problem is with the function getClassOffset but I don't see it.

Also is this function can cover all the scenario possible, I think it is possible but maybe i don't see it.

Anybody can help me?

Thanks alot

Engine distributed across several machine adivces

18 July 2011 - 08:02 PM

Hi,

I have this project of mine that i am trying to put on it's feet. I want to make a video mapping engine distributed across several machine, or if you prefer a interactive installation engin were several machine has different role.

in example:
we have
0..N GUI connected,
1..N 3d player (machine connected to a projector),
maybe N or just one server and
1 data database.

All those process have their role and have to communicate over network.
- Gui are really just a user interface to do live interaction, or to assemble and integrate an installation.
- 3d player are just rendering and receiving the new updated data.
- Server update the scene and send the changes to GUI and 3d player.
- Data database is where the object serialized would live and ensure no 2 gui modify data at the same time (I am not sure yet about this process)

Now where i need some advice are of the design of the communication and serializing the changes onto the network. Also I am thinking of using an entity component system because i think this way i could distribute the actual update of the scene. An other question I had is the actual gain I can get from an paralelnized entity component system, for example I have a thread that update the TransformationComponent, but this component trigger more thread for independent braches of the tree, to me that look like potentially have a problem of too many thread. I would also ideally go a step further and not just paralelnize by "task" or component but by independent data.

So to recapitulate I need advice on how to takle the communication, do a simple RPC would suffice, I think i'll need a combination of remote function call and sending data.
How to distribute load on different thread and process.

I know those are not easy subject, but i think that is why it is interesting to talk about them so don't be shy and ask me question if you don't understand or post you advice

thanks alot

Mani

p.s. and if it is not interesting enough I have an other question how to work with live video where it need to get to all player and server potentially and being process for effect :)

PARTNERS