Amnesiac5

Members
  • Content count

    72
  • Joined

  • Last visited

Community Reputation

157 Neutral

About Amnesiac5

  • Rank
    Member
  1. OpenGL OpenGL ES 2.0 - glut replacement

    It seems the EGL "is an interface between Khronos rendering APIs" rather than providing keyboard, gamepad and mouse handling. OpenKode it is... o_O
  2. OpenGL OpenGL ES 2.0 - glut replacement

    O-o-o kay. I hadn't come across EGL, it certainly bears further investigation. Thanks.
  3. I'm developing a game using OpenGL ES 2.0, so I need a glut replacement to use with it (my main requirements are for a main loop and keyboard, gamepad and mouse handling). This is for a university project and nominally is cross-platform, in reality I'm developing principally for PC but using OpenGL ES 2.0 while trying to be as platform neutral as possible (with the exception of wanting mouse and gamepad control :) ). So far my only alternatives seem to be glut-es or openkode. Are there any other alternatives? Does anyone have any recommendations? Would SDL work? Any help with this would be most appreciated. TIA A5
  4. So you want to be a rock star?

    Quote:No one talks about breaking into the banking industry...actually they do. No, really.
  5. Quote:Original post by d00fus If you're VC++ based, maybe try __if_exists?That's certainly a possibility, but Paul Sinnett has provided me with a solution: template <typename T> struct has_member_x { template <bool> struct helper {}; // change struct_t to bool template <typename U> static yes test(helper<&U::x> *); // remove sizeof template <typename> static no test(...); static const bool value = sizeof(test<T>(0)) == sizeof(yes); }; Now I just need to spend some time trying to figure out how the blazes it works ! Thanks to all who contributed. A5
  6. Quote:Original post by d00fus As far as I know there's no totally cross-platform way to do this (if so please correct me!). Something such as the following should detect the presence of a member "x" I believe on a compliant compiler: *** Source Snippet Removed *** To make this more useful, you'd probably want to define a macro that declares the has_member_foo struct for each member you want to test for, and probably another macro to wrap the test itself. Note that in general this is a tricky area as it depends on how the compiler treats sizeof expressions, which is by no means standard. See here for more info. Looks like this method won't work with VS 2005 according to this article. I'll try it with 2008 when I get home tonight. [edit] fails in VS 2008, too, dang! Workaround, anyone? A5 [Edited by - Amnesiac5 on June 9, 2009 4:23:54 PM]
  7. Quote:Original post by d00fusOP: I should also emphasise the point others have raised, which is that is this check really necessary for your use? If the only purpose is to prevent instantiation of a template if the type does not have x/y/z members (or getX/getY/getZ accessors), the compiler would do this for you by giving an error when you reference them. What exactly do you want to do with the bool value you get?Whoa, I've been working on this for so long and moved so far from where I started I've almost forgotten... I have several functions which read data from an input stream into a data structure, the data structure may be a sequence container (eg vector<int> or list<float>) or a point. So I want the code to select the correct functions to implement at compile time.
  8. Quote:Original post by LorenzoGatti Quote:Original post by Amnesiac5 I am trying to use the constraint to limit the instantiation of the supports_XYZ template to [2] but, regardless of the type, [1] is always instantiated (both b1 and b2 are set to false). The article does something clearly different from your code: template instantiation fails controllably thanks to an artificial dependence from a typedef that the "function enabler" can be made to contain or not. Boolean constants like yours can be used to choose between the disabler and the enabler, but there are neither if statements nor boolean template parameters in your code. Defining supports_XYZ<must_have_XYZ<T> > makes very little sense if you don't actually instantiate any must_have_XYZ<> (e.g. must_have_XYZ<Pt>). The concern about not knowing the class name is, I'm afraid, absurd: if you don't know what classes posterity will try to use with the templates you are writing now, you cannot tell what template specializations will be needed (and you aren't even certain you'll need to mess with overloading). In the specific case of your example, it's both hard to imagine how constraints() might be adapted to fundamentally different point representations and easy to see that it should really operate on a decently explicit point interface. I'm not too clear what you're saying so please bear with me if I've misinterpreted you. I haven't included any if's since I haven't reached that point in development yet (I believe they're implicit anyway) I'm working towards that point but first need to define a traits class or something like a traits class which will evaluate to true or false dependent on the properites of the passed parameter. In this case, I want members x, y and z (hence the supports_XYZ trait). If they're not present an alternative template would be instantiated or a compiler error would be caused. I'm concerned about the classes properties not it's name. The constraint is my (clearly flawed) attempt at something like a traits class. It was my understanding that since must_have_XYZ<T> is inside template<typename T> struct supports_XYZ it would pick up T from there. Clearly, I'm wrong there, too. Quote:If the template function referred to accessor methods for the three coordinates you could make simple and efficient adapters for different point-like classes rather than unnecessarily assuming that point-like classes have public fields x,y and z. True, but I would've thought that public fields would be just as likely as accessors. A5
  9. Quote:Original post by d00fus As far as I know there's no totally cross-platform way to do this (if so please correct me!). Something such as the following should detect the presence of a member "x" I believe on a compliant compiler: *** Source Snippet Removed *** Note that in general this is a tricky area as it depends on how the compiler treats sizeof expressions, which is by no means standard. Thanks for the feedback. Hmm, this looks like a step in the right direction. I seem to remember seeing sizeof used in similar fashion elsewhere, but blowed if I can remember where. Any references for this? Visual Studio spits out an "error C2070: '': illegal sizeof operand" compilation error for sizeof(test<T>(0)) if I include the line: has_member_x<Point1 >::value; is this the tricky area you're talking about? has_member_x<int >::value; does indeed evaluate to false. A5
  10. As part of a larger project I am trying to develop a function enabler (Dr Dobb's - Function Overloading Based on Arbitrary Properties of Types) to enable a function intended for use with a point class, the implementation and name of which are unknown. I don't want to use any library like BOOST or Loki, etc.. So far I have the following: // constraint template<class T1> struct must_have_XYZ { ~must_have_XYZ() { void(*p)() = constraints; } private: static void constraints() { T1& b = *new T1; b.x = b.y = b.z; } }; // [1] template< typename T > struct supports_XYZ { static const bool value = false; }; // [2] template<typename T> struct supports_XYZ<must_have_XYZ<T> > { static const bool value = true; }; int main() { bool b1 = supports_XYZ<Pt >::value; bool b2 = supports_XYZ<int >::value; return 0; } I am trying to use the constraint to limit the instantiation of the supports_XYZ template to [2] but, regardless of the type, [1] is always instantiated (both b1 and b2 are set to false). Since I don't know the name of the point type/class ahead of time I can't partially specialise like so: template<> struct supports_XYZ<Pt > { // only useful if Pt is defined // won't work for Point or P3d or whatever static const bool value = true; }; Hence the attempt to use a constraint. Am I barking up the wrong tree? Is this even possible? Any help with this much appreciated. A5
  11. [C++] SFINAE

    I get similar error messages from VC++, but I think they may be red herrings and the real culprit may be: line 21 error C2668: 'copy' : ambiguous call to overloaded function Additionally, neither function is a viable candidate for instantiation template <typename Cont, typename Cont2> typename Cont2::iterator copy(const Cont& c, Cont2& dest) { return std::copy(c.begin(), c.end(), std::back_inserter(dest)); } causes error C2664: 'std::_Vector_iterator<_Ty,_Alloc>::_Vector_iterator(const std::_Vector_iterator<_Ty,_Alloc> &)' : cannot convert parameter 1 from 'std::back_insert_iterator<_Container>' to 'const std::_Vector_iterator<_Ty,_Alloc> &' while template <typename Cont, typename It> It copy(const Cont& c, It dest, typename std::iterator_traits<It>::pointer = 0) { return std::copy(c.begin(), c.end(), dest); } causes error C2039: 'iterator_category' : is not a member of 'std::vector<_Ty>' HTH A5
  12. Yay, exams over, so back to the grind... Quote:Original post by Antheus Since you mentioned patterns, start with the whole development methodology. How will user use your class? The "story", or "use-case".I thought I had. This thread is focusing on specific problems I'm having. Quote:Note that Vertex4D and vertices are user defined structures. Library passes values via function parameters and doesn't impose any structure at all. If Vertex4D and vertices are going to be defined by the user some time in the future how can I access (or plan for) them now? TIA A5
  13. Quote:Original post by Antheus Since you mentioned patterns, start with the whole development methodology. How will user use your class? The "story", or "use-case". >>> snip <<< This article Callbacks In C++ Using Template Functors by Rich Hickey (way back from 1994) has been pointed out to me on a newsgroup and seems to cover exactly the problems I'm having, tackling them with a translator. It certainly warrants further investigation. The points you've raised intrigue me greatly (mainly because I'm really struggling to understand what you're talking about) and I'll pursue them further in a week or so after my exams. But for now I really should get on with some revision. Many thanks for the comments and taking the time to answer my queries, all very much appreciated. A5
  14. Quote:Original post by sebbit ObjCallback in that instance serves as the interface for a collection of callback methods. So, instead of passing a different callback for each element of the object file you could jast pass it one concrete instance of an object that implements ObjCallback. Then your parser could just call those methods for every element of the parsed file (addVertex for each vertex and so on for each normal, face ...). Nice and simple and safes you alot of fumbling around with callbacks (which can be quite hard to achive for instance methods in a robust way in c++ if you don't want to use one of the existing libraries).Sorry, I'm not trying to be obtuse but I really can't see what you mean. An example might help. I have pressing matters to attend to, I'll spend some time trying to grok this later. A5
  15. Thanks for the feedback. Quote:Original post by CmpDev I would have to disagree with you here speed is very much so more important. If this is a learning exercise then carry on by all means.For me in this particular context flexibility is more important. Naturally, if, after all this effort, it takes half-an-hour to load an 8 vertex cube then speed would become an issue. My first attempt used non-member function pointers and only returned vectors of strings which necessitated using an intermediate builder. That was about half the speed of Nate Robbins glm.c. A not unreasonable speed, but it lead to the original motivation for this latest exercise to see if converting the stream input to numerical directly would speed things up, but one thing lead to another... [grin] Quote: On the other hand if you want people to use this library, I would argue it would be better to create a pipeline tool to bake the data to in a format which suits the users requirements.Bake? How so? A5