• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Ty Typhoon
      I like to build my A - Team now.
       
      I need loyal people who can trust and believe in a dream.
      If you got time and no need for direct pay please contact me now.
       
      We cant pay now, you will recieve a lifetime percentage if the released game will give earnings. 
      If I get the best people together for a team, everything should be possible.
       
       
      What i need:
      - Programmer c++
      - Unity / Unreal - we must check whats possible, please share your experience with me.
      - Sculpter, 3D Artist
      - Animator
      - Marketing / Promotion 
       
       
      What i do:
      - Studio Owner
      - Director
      - Recruit exactly you
      - Sounddesign
      - Main theme composing
      - Vocals
      - Game design
      - Gun, swords, shields and weapon design
      - Character, plants and animal design
       
       
      Please dont ask about the Name of the Game, about Designs or Screenshots.
      The game will be defintitly affected about our and your skills if you join the team.
       
       
      Planned for the big Game:
      - 1st person shooter
      - online multiplayer
      - character manipulation
      - complete big open world with like lifetime actions and reactions
      - gunstore with many items to buy
      - many upgrades for players
      - specials like mini games
       
      So if you are interested in joining a team with a nearly complete game idea, contact me now and tell me what you can do.
       
      discord:
      joerg federmann composing#2898
       
       
    • By codelyoko373
      I wasn't sure if this would be the right place for a topic like this so sorry if it isn't.
      I'm currently working on a project for Uni using FreeGLUT to make a simple solar system simulation. I've got to the point where I've implemented all the planets and have used a Scene Graph to link them all together. The issue I'm having with now though is basically the planets and moons orbit correctly at their own orbit speeds.
      I'm not really experienced with using matrices for stuff like this so It's likely why I can't figure out how exactly to get it working. This is where I'm applying the transformation matrices, as well as pushing and popping them. This is within the Render function that every planet including the sun and moons will have and run.
      if (tag != "Sun") { glRotatef(orbitAngle, orbitRotation.X, orbitRotation.Y, orbitRotation.Z); } glPushMatrix(); glTranslatef(position.X, position.Y, position.Z); glRotatef(rotationAngle, rotation.X, rotation.Y, rotation.Z); glScalef(scale.X, scale.Y, scale.Z); glDrawElements(GL_TRIANGLES, mesh->indiceCount, GL_UNSIGNED_SHORT, mesh->indices); if (tag != "Sun") { glPopMatrix(); } The "If(tag != "Sun")" parts are my attempts are getting the planets to orbit correctly though it likely isn't the way I'm meant to be doing it. So I was wondering if someone would be able to help me? As I really don't have an idea on what I would do to get it working. Using the if statement is truthfully the closest I've got to it working but there are still weird effects like the planets orbiting faster then they should depending on the number of planets actually be updated/rendered.
    • By BenjaminBouchet
      Learning game development in Unreal Engine could be a daunting task for someone who don’t know where to start, and a cumbersome process if you don’t organize your progression correctly. One thing commonly known by experienced developers and by people unfamiliar with coding: mastering a development language is a long and difficult task.
      From blueprints to C++ in Unreal Engine
      If you want to learn fast, you need a good learning strategy. Unreal Engine contains a very powerful tool which you can use to learn C++ faster: its blueprint system. Blueprints are extremely easy to learn (and you may already have a good knowledge of them). Thus you can conveniently use them as a guide for writing code in C++. This is the reason why I am writing a tutorial series on how to make the transition from Unreal Engine blueprints to C++.
      Learn and practice C++
      Following this tutorial, you’ll acquire new concepts of C++ programming in every chapter. Then following chapters will give you reasons to reuse and practice those same concepts. There’s no better way to wire you brain.
      Link to the tutorial: [Tutorial] Learn C++ in Unreal Engine 4 by making a powerful camera
      Please do send me as much feedback as you want. I’ll be considering every constructive remarks and taking them into consideration. Your feedback will help me to improve and update the existing chapters and to make the next one better.

      View full story
    • By BenjaminBouchet
      Learning game development in Unreal Engine could be a daunting task for someone who don’t know where to start, and a cumbersome process if you don’t organize your progression correctly. One thing commonly known by experienced developers and by people unfamiliar with coding: mastering a development language is a long and difficult task.
      From blueprints to C++ in Unreal Engine
      If you want to learn fast, you need a good learning strategy. Unreal Engine contains a very powerful tool which you can use to learn C++ faster: its blueprint system. Blueprints are extremely easy to learn (and you may already have a good knowledge of them). Thus you can conveniently use them as a guide for writing code in C++. This is the reason why I am writing a tutorial series on how to make the transition from Unreal Engine blueprints to C++.
      Learn and practice C++
      Following this tutorial, you’ll acquire new concepts of C++ programming in every chapter. Then following chapters will give you reasons to reuse and practice those same concepts. There’s no better way to wire you brain.
      Link to the tutorial: [Tutorial] Learn C++ in Unreal Engine 4 by making a powerful camera
      Please do send me as much feedback as you want. I’ll be considering every constructive remarks and taking them into consideration. Your feedback will help me to improve and update the existing chapters and to make the next one better.
    • By mrDIMAS
      Hello everyone! I need to fill lua table with functions from script file like this:
      function init() end function update() end I need to create table on stack and fill it with this functions from specified file. How can I do this?
  • Advertisement
  • Advertisement

C++ Module based Polymorphism VS Data Locality

Recommended Posts

Hey guys, 

I'm trying to develop an engine that supports consoles, as well as all PCs. I also wanted the users in windows, Mac, and Linux to use different graphics libraries. To that end I need to support many different windowing and graphics systems. To deal with that, I simply abstract them using Polymorphism, creating a base class as an interface before I inherit all the actual functions and data in another class. This approach is so far bad for data locality as I have to use pointers to objects and new rather than putting the data directly in arrays. While I'm going to use indirect multi draw and command buffers to alleviate this issue, it's still an issue. And in the case of compiling the libraries statically, I'd have to ship multiple, larger executables.

To reiterate: Is there a way to use dynamic module based Polymorphism without requiring pointers to objects? If not, would the data locality issues be significant enough to warrant just making my libraries static and shipping multiple executables per graphics system (ie: Vulkan, Opengl, and Directx on Windows). 

Edited by KarimIO

Share this post


Link to post
Share on other sites
Advertisement

Run-time polymorphism in C++ is done via pointers and references and there's no way around that. You can be careful about where you allocate the memory, and this can help with data locality, but that's probably not the best way to approach this.

Graphics library choice can be a compile time setting. You can implement a compile-time interface in C++ via the curiously recurring template pattern, if you like. (https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern).

You're wrong about shipping larger executables in the static case. Either the function is used, in which case it's linked into the executable, or it's not, and it's not. If anything the polymorphic case is potentially worse because sometimes it's not easy for the linker to know whether you'll ever call a certain derived function or not.

It's impossible to say whether the data locality issues are significant because it depends entirely on your specific implementation. At one ludicrous extreme, if you just have 1 virtual function call such as DoAllGraphics() and it has a DirectX implementation and an OpenGL implementation, then it is going to have absolutely no effect whatsoever. At the other ludicrous extreme, if you have a virtual HandleVertex function then obviously that's going to be awful. You will want an interface that is sufficiently high level that you are not performing thousands of virtual function calls per second, which may involve some compromises such as code duplication.

Share this post


Link to post
Share on other sites
5 hours ago, KarimIO said:

Is there a way to use dynamic module based Polymorphism without requiring pointers to objects?

Research SOLID principles. It is one of many patterns that have been realized as major differences between flexible maintainable code and nightmarish code. 

That link is just the starting point. There is an enormous body of literature, also including research papers and conference talks, on the subject.

For this type of library that can be swapped out, the acronym letter D (Dependency Inversion) is most critical, followed by the L (Liskov substitution).  Dependency inversion means all the code is written against the abstract library and not the concrete implementation, so the abstract graphics instead of the D3D or OGL or Vulcan code. The substitution principle means that the actual concrete implementation will work perfectly as long as the abstract library is followed.

Share this post


Link to post
Share on other sites
25 minutes ago, frob said:

Research SOLID principles. It is one of many patterns that have been realized as major differences between flexible maintainable code and nightmarish code. 

That link is just the starting point. There is an enormous body of literature, also including research papers and conference talks, on the subject.

For this type of library that can be swapped out, the acronym letter D (Dependency Inversion) is most critical, followed by the L (Liskov substitution).  Dependency inversion means all the code is written against the abstract library and not the concrete implementation, so the abstract graphics instead of the D3D or OGL or Vulcan code. The substitution principle means that the actual concrete implementation will work perfectly as long as the abstract library is followed.

I'm, generally, abiding by those principles. I am mostly referring to technical limitations of c++

Share this post


Link to post
Share on other sites

In that case, you understand why using pointers to objects are a necessity.

This is true of all programming languages for this feature.  You are replacing one set of things with another set of things, therefore you need some form of indirection which can select the proper elements. In C++ that is handled through pointers, including features like the vtable pointer.

Share this post


Link to post
Share on other sites
3 minutes ago, frob said:

In that case, you understand why using pointers to objects are a necessity.

This is true of all programming languages for this feature.  You are replacing one set of things with another set of things, therefore you need some form of indirection which can select the proper elements. In C++ that is handled through pointers, including features like the vtable pointer.

I suppose I was mostly trying to change the definition of those things rather than swap them out, though at runtime. Thanks though. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Advertisement