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.


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

Posts I've Made

In Topic: Design portable vertex declaration

17 July 2013 - 06:12 PM

My model importing system runs at build-time, not runtime (and isn't shipped to the user), so I can do as much platform specific optimizations as I like in it ;)


That is interesting. I guess you use lua to generate c++ code? Are you explaining you system somewhere?


Thanks for the warning about OpenGl. I am more used to DirectX. But I guess Ogl  have a way to test those capabilities?

In Topic: Design portable vertex declaration

16 July 2013 - 06:53 PM

Yes that is what I am juggling with. I am trying to have most a good generic representation but that will allow me to still have some platform specific optimization. For example in the case of the index buffer OpenGl can have index buffer of uint8 where the smallest for D3D is uint16. I know this is for the index buffer but it would be similar for the boneindex where you might want to have a smaller size type.


I don't think your system can handle that? Or Am-I wrong?

In Topic: a slick trick in c++

14 October 2011 - 08:00 PM

Hi first, I am very sorry to wake a old thread but I am trying to implement this trick but slightly different and I can't make it work.

In the class of snk_kid, he has a static array and x,y,z,w members, what I what is to do the opposite. i want to make the x, y, z, w static member pointer and a member array to old the data.

Id it possible I can't mannage to make it work.

[source lang='cpp']template<typename ValueType, CoreFoundation::size_t Rows, CoreFoundation::size_t Cols>class Vector4{public: inline Vector4(ValueType x, ValueType y, ValueType z, ValueType w):x_(x), y_(y), z_(z), w_(w) { } inline ValueType operator()(CoreFoundation::size_t index) { return data_[index]; }; inline const ValueType& operator()(CoreFoundation::size_t index) const { return data_[index]; }; private: ValueType data_[Rows*Cols]; public:typedef ValueType Vector4< ValueType >::* const VectorElement; static VectorElement x_; };template<typename ValueType>typename Vector4<ValueType>::VectorElement Vector4<ValueType>::x_ = &(Vector4<ValueType>::data_[0]);[/source]

What doesn't work is the assignation of the static memeber.

anybody have a clue how to do this?


In Topic: Class offset with its Base in Multiple inheritance

10 October 2011 - 01:43 PM

Thanks alot, it is very interesting to hear your ideas.

@ RobTheBloke:

I never implemented solution 1 and 2, but i work and implemented solution 3. To me because i have experience with the third solution it seams that solution 1 and 2 are more complexe, more involving and depend on a complexe third party code. What i like about solution 3 is that it can be very elegant and even less verbose that what you provided given that you use macros.

@ Codarki

constexpr is a new qualifier for c++0x but I realized that xcode allow the term but doesn't do anything at the moment. I think it will be a good optimization for the reflection system.

I also decided to drop virtual inheritance first because it is impossible to know classes offset in this case. (not that i know of) And that it is usually bad design and can be expressed in better terms. I'll keep the multiple inheritance because it is already working and I don't expect to cost more because of the constexpr qualifier. Everything is know at compile-time so it can be executed at compile time.

SO what i have is a reflection system and each class that need to be reflected add a macros to it's declaration to declare itself and its parents and macros to define the reflected member of the class.

thanks alot

In Topic: Class offset with its Base in Multiple inheritance

22 September 2011 - 05:30 PM

For what purpose? to call methods? or to access data? or both?

There are some really easy ways of doing this. Your approach isn't one of them ;)

Really i only know with offset. What are the other way. What I am doing is a reflection system with macros "trickery" as some people call it. Each metaclass has a list of parents (C3 linearization) and each parent have the class offset. I'll also have a list of exposed members of the class and those offset are relative to this offcourse. I am curious how else it can be acheived?

Correct. It's undefined. However offsets can work, ish (i.e. if you are extremely careful!)

Careful in what way? I know there is special case like virtual inheritance. but For one case it will always work. Like in the case of simple inhertance.

*MIGHT* contain all of it's parents, or it may contain multiple versions of the same class. Virtual inheritance tends to fsck things up quite a bit - although frankly, that's just multiple inheritance.

I think you refer to the case where i would have a hierarchy of multiple inheritance with multiple occurrence of the same classe in the base classes but without qualifying each of them as virtual inheritance. This is considered really really bad coding practices and I think even standart dynamic cast doesn't handle that it just return the firs one it found.

By the way would know know how to get the offset of a class that you derive virtually from ?

Offsets are portable. Bugs due to multiple inheritance/virtual inheritance can be ported to other platforms too ;)

Sorry I don't get it?

As you can see in my results in my first post the offset that i get are negative, which they shouldn't. I implemented my dynamic_cast and it work but the offset need to be positive. What i think is the problem is that the ptrdiff_t overflow from the substraction of the tow uintptr_t.

The problem, as always, is one of logic.

Then you do,

derived - base, aka 0 - 4

Which give you -4 byte but I need to add 4.

Btw, that max_size is cruft. It's sole purpose is to induce chants of WTF in your co-workers. Get rid of it and just use 0. A few more comments wouldn't be out of place either! (Trust me, you'll have quite a few WTF moments when you look back at that code next year)

Ya I realized that I am using -1 it seams more meaninfull when I look at it in the debugger.

Thanks a lot RobTheBloke for your comments.