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.


Lauris Kaplinski

Member Since 02 Aug 2006
Offline Last Active Feb 18 2013 02:33 AM

#4997000 Sharing C++ object between application and plugin with C interface

Posted by Lauris Kaplinski on 03 November 2012 - 04:40 PM

Why don't you just write the plugins in C++?

Then you're just passing pointers back and forth.


I think he explicitly said that his problem was the potential incompatibility of C++ ABI between the application and the plugin. if he could restrict the plugins to be compiled with precisely the same compiler and settings as the main program, there would'nt be a problem from the start - regardless whether the interface is C or C++.


#4996658 How to store the objects in my world

Posted by Lauris Kaplinski on 02 November 2012 - 02:27 PM

Why do you think that resizing array is slow?
Use std::vector and forget the resizing. I cannot imagine a scenario where this could become bottleneck unless you are doing something very weird. And in the latter case you should fix that weirdness, not worry about vector resizing speed.


#4996653 How powerful is Java?

Posted by Lauris Kaplinski on 02 November 2012 - 02:21 PM

I'd suggest to play Minecraft and decide for yourself Posted Image

But seriously - I very much doubt that you as a hobbyist/independent developer will ever reach a point where Java is not fast or powerful enough for your game. The only place where I can see Java (and other garbage-collected languages) become problematic is console development with very limited memory.


#4996647 Building Games for Android

Posted by Lauris Kaplinski on 02 November 2012 - 02:13 PM

Unity is a good choice but it's Android license costs 400$. Still you can start building your game using free version and buy Android license later when you have to actually implement specific controls and make test builds.

Unity has lots of tutorials and very helpful community.


#4996644 Sharing C++ object between application and plugin with C interface

Posted by Lauris Kaplinski on 02 November 2012 - 02:02 PM

Well, this complicates things. Unless you want to make duplicate hierarchy of POD types or use custom vector-like containers - but neither of these is probably a good idea.

How important part of your program these plugins will be?
Is it realistic that there will be plugins that are compiled with different compilers/settings?

Maybe you can write some simple tests that verify the internal layout of your objects (and std::vector) and simply ignore plugins that do not have identical layouts?


#4996467 Sharing C++ object between application and plugin with C interface

Posted by Lauris Kaplinski on 02 November 2012 - 02:52 AM

My only suggestion is to encapsulate the parts that have to be accessed in plugin into POD types.

Extracting member offsets of course works, except when you are using multiple inheritance. But it makes my eyes hurt, unlike using POD types in C++ code.


#4995380 Chunked LOD Merging between levels

Posted by Lauris Kaplinski on 30 October 2012 - 06:44 AM

I think you are on correct path...
The morph parameter for split should be calculated using tile center.
The morph parameter for join should be calculated using parent tile center.


#4995024 How do I avoid hundreds of identical scene graph traversals?

Posted by Lauris Kaplinski on 29 October 2012 - 06:15 AM

You cannot do frustum culling without knowing the world positions of your children. Unless you cache wold-space bounding boxes or transform frustum during tree traversal.

I think it usually makes sense to cache both world transforms and bounding boxes in each nodes, update these once after each mutation and reuse whenever you need.


#4995019 Concurrent rendering & game-logic

Posted by Lauris Kaplinski on 29 October 2012 - 05:58 AM

If you are using OpenGL you are allready running the majority of the rendering concurrently with the game logic(on the GPU) so breaking off the command passing(which is all OpenGL does) to its own thread is pretty close to pointless. (you shouldn't send that many commands to OpenGL each frame anyway).

a few things you can do if your renderer is slow.
1) Do not use immediate mode.
2). See point 1.

If you're not using immediate mode and its still slow you should profile and see where the slow parts are.


Pretty much this.

Physics normally benefits more from multithreading than rendering.

If you still want to use multithreading you can separate the rendering thread. I.e.
  • In your main thread submit relevant geometry to render lists (but you have to make sure that render lists do not reference data that will be modified in game logic thread)
  • While main thread proceeds to next logic/physics update the render thread wakes up and starts submitting render lists to OpenGL
  • You can even start new render list submission before rendering is complete if you guarantee that they do not interfere with each other (i.e. use two separate toplevel list containers and do not share objects)



#4994708 glEnable(GL_TEXTURE_2D) inconsistent?

Posted by Lauris Kaplinski on 28 October 2012 - 08:14 AM

I only glanced through your code, but what I immediately saw:
  • Do not use glTexImage2D in every frame! Use glGenTextures in constructor and then glBindTexture whenever you build or use it.
  • You should use GL_RGBA instead of "4". The latter is relict from OpenGL 1.0 era.
But neither of these problems should cause the textures to not to draw.


#4994669 Feedback on my Game Idea (randomly generated dungeon RPG)

Posted by Lauris Kaplinski on 28 October 2012 - 05:40 AM

Disclaimer: I have not played "Binding of Isaac"

Doing random dungeons is pretty easy. Doing 100 levels of random dungeons is pretty hard if you want to keep gameplay interesting.
I suggest studying the "one and only roguelike" Nethack. It contains many example both how to keep randomly generated dungeons exciting and how to add constant progress into such environment.

As of your main story - do you plan to keep the story only as a generic frame (i.e. opening and ending plus few references) or do you plan to make the story actually relevant in gameplay? In the latter case you have to plan your dungeon design, enemies and progression around it.


#4994146 Affecting the actual player as an alternative to affecting the playable chara...

Posted by Lauris Kaplinski on 26 October 2012 - 08:19 AM

I think I have seen these in some games (cannot remember exactly which ones) and liked them. Such things only have to be rare enough to not cause much frustration.


#4993500 RPG + Fitness = Fitness RPG? Need advice

Posted by Lauris Kaplinski on 24 October 2012 - 12:31 PM

I think the pacing will become big problem.
"Normal" RPG-s can be reasonably be played through in about 40-120 hours. For most players it will take 1-2 weeks of serious gameplay.
Now you probably want to keep players exercising for much longer than only 1-2 weeks. To do that you have to lower the pace of game while keeping it interesting. But if you lower the pace too much people become impatient and either cheat or lose interest.
In any case it will be interesting design exercise so please keep us updated of your ideas/progress.


#4992784 Calc camera position to encompass several points on screen

Posted by Lauris Kaplinski on 22 October 2012 - 08:45 AM

I would do it the following way (using OpenGL matrix):

Place the camera at the median point of your point cloud. Transform all points to camera (view, eye) space.
Now translating camera along it's local Z is equivalent to translating all points along global Z in camera space. I.e. you have to find for each point, which is the smallest translation along z that moves it inside view frustum.

Let your point (in camera coordinate system) be P(x,y,z)

In clip coordinate system:
Qx = 2Px/(R-L) - Pz(R+L)/(R-L)
Qy = 2Py/(T-B) - Pz(T+B)/(T-B)
Qz = -(F+N)/(F-N) - 2FN/(F-N)
Qw = -Pz

And after perspective division
Sx = Qx/Qw
Sy = Qy/Qw
Sz = Qz/Qw

You want to ensure that:
-1 <= Sx <= 1
-1 <= Sy <= 1
-1 <= Sz (you do not want to check far plane here, because otherwise your inequalities may become unsolvable)

Now for each point and for each coordinate x, y and z find maximum z value Pz' that fills the conditions of these inequalities.
Required distance to move camera d = Pz - Pz'
While iterating over all points and all coordinates find the maximum d.


#4992772 Drawing a line on a grid - turn based character movement

Posted by Lauris Kaplinski on 22 October 2012 - 08:10 AM

Find the relative difference between player and target in both X and Y directions (Dx and Dy)
Now if ABS(Dx) > ABS(Dy) then move first along X axis (direction is given by the sign of Dx), otherwise along Y axis.
After each movement evaluate again.




PARTNERS