Tag Info

New answers tagged

2

simple solution using a uniform vector: float dx = target->x - x; float dy = target->y - y; float dist = std::sqrt(dx*dx+dy*dy); if (dist > speed * delta) { dx /= dist; dy /= dist; x += dx * speed * delta; y += dy * speed * delta; } else { x = target->x; y = target->y; }


1

You probably don't need to worry about the edge concept explicitly, in scene graphs. Any time that a parent object in the scene graph holds a reference to one or more children, that reference (pointer) is itself the connection that would be termed an "edge". It it is likely that the child also holds a reference back to the parent. These are just pointers. ...


0

Your system looks fine. I am more used to having all of my configurations for a game in a single file but I also work on very large projects where I have folders of configurations. Your system as described above should be able to handle both of those situations just fine. I do not see any concerns you may be perceiving in the question nor do I foresee any ...


2

There's an error in basic.frag. Instead of setting FragColor, you're setting Color, which is an input variable. I don't know why that's not being reported as an error because it is certainly not permitted. As for the flashing problem, I have a feeling it might be due to a ping-ponging double-buffer setup. Since you only draw the scene once, every other ...


1

I think these two lines are not needed: Subtract(a,&entities[target].pos);// Make it relative to the obstacle model ... Subtract(b,&entities[target].pos);// Make it relative to the obstacle model I don't see why are you adding them. I think that if you remove them it should work as intended. EDIT: when you calculate the normal to the triangle ...


0

Have you taken a look at the official UE4 Tower Defense sample/tutorial? That sample demonstrates a UE4 project where the player is not associated with any one in-game character, instead providing building orders and high-level AI directives.


1

You should check these for audio synthesis in C++. Check the sources as well. You may find a way to write audio buffer on the fly according to some parameters passed from physics engine. The Synthesis ToolKit in C++ (STK) NSound CSound and its resources page.


1

Your best bet with these kind of questions is to implement it and see on your target/example hardware how it works out. For Direct3D 11, you can try out the InstancingFX11 sample from MSDN Code Gallery.


1

Usage of glVertexAttribPointer is suspicious. glVertexAttribPointer( 2, // 3, // Mistake in TexCoords, should be 2 GL_FLOAT, // GL_FALSE, // 0, // Should be size of your vertex (void*)0 // Should be offset within vertex ); Check the documentation ...


2

Instead of building the cube in geometry shader from a point, its better to do an instanced render of a simple cube VBO, and forego a geometry shader entirely. The only time you wouldn't want to do that is if each cube has rapidly changing orientation and you need to recalculate its modelview every pass. In which case, have position and orientation as ...


0

There is no need to have a DX8 SDK. Most of the older DX9 SDKs include the necessary files for D3D8 (include/lib). This one includes the required files, for example: http://www.microsoft.com/en-us/download/details.aspx?id=10368 As for the 8.0/8.1 thing, if that's a concern - Microsoft never separated these as DLLs so it's safe to assume that they're quite ...


2

The .fxo files are compiled shader files. Think of .obj/.o files for C and C++, but for HLSL. They're the result of running the shader compiler fxc.exe over your shader files. The advantages of .fxo files are three fold. First, the make reverse engineering of your shader code a bit more difficult, which is advantageous for some of the higher-end games with ...


1

You could create a pool at the manager which will clean up all after or before the EntityManager::update. This way it is save. using 'delete this' will raise big issues amongst a lot of developers. std::vector m_garbage; void EntityManager::collect(Entity* entity) { entity->collected = true; garbage.push_back(entity); } void ...


0

It depends on what remove_entity does. If you're freeing some memory then you shouldn't access the this pointer after calling remove_entity. If you're just marking the entity as "to be deleted later", then you can do whatever you want with it. Usually what happens is entities add themselves to a buffer, and at the end of the game's update loop the manager ...


0

There exists a manifold from the time BeginContact is called just up until EndContact is called. When EndContact is called the manifold is no longer valid. This means you can store the b2Contact pointer once BeginContact is called. For every game loop that EndContact is not called you can access the b2Contact pointer and query the manifold. This way you ...


1

If you upload VBOs with many identical cubes inside of them you will just waste bus bandwidth. The keyword you should search for is "instanced rendering". There are many questions about it on here.


3

Your geometry shader should take a single point (center of the cube) with a front vector and an up vector. You can then output 12 triangles (6 faces x 2 tri for a quad) using the single point as the center of the cube and the cross-product of front & up for the right vector. // table of all triangle vertices to make the cube const vec3 face_table[12*3] ...


0

After a full day of testing and google searching I finally came upon the fix so I'm sharing it here : uniform vec2 Resolution;//This is the render target size, i.e. what you feed into glViewport vec2 screen; screen.x = ( gl_FragCoord.x - Resolution.x / 2.0 ) / ( Resolution.x / 2.0 ); screen.y = ( (Resolution.y - gl_FragCoord.y) - ...


0

In theory it should not happen but because of the way the GPU rasterizes triangle lines there are some rounding errors on this particular GPU that differ between the texture coordinates and the pixel coordinates. Texture coordinates does not use the same precision as the vertex coordinates, add to this perspective correction (even though the triangles are ...


-1

Your problem is that you have not set your target and shader resource view formats properly: // Setup the description of the render target view. renderTargetViewDesc.Format = textureDesc.Format; Should be set to a DXGI_FORMAT such as DXGI_FORMAT_R32G32B32A32_FLOAT. See msdn's documentation on DXGI_FORMAT for more information regarding DXGI_FORMAT. The ...


0

Here is my java implementation to get the closest one from a quadTree. It deals with the problem dlras2 is describing: I think the operation is really efficient. It is based on the distance to a quad to avoid searching in quads further way then the current closest. // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...


1

Main problem with global variables in C++ that compilers don't guarantee initialization order. Let's you have 2 global variables with constructors: global_A g_a; ... global_B g_b; ... global_A::global_A() { this->test = 5; // test is int } ... global_B::global_B() { printf( "%d", g_a.test ); } If initialization order of g_a and g_b is ...


0

Global's initialization happens before main() gets called and the UI setup stuff happens if that takes too long then the game window may take a long time to show up. Common rule in UX (user experience) is to react to user input as fast as possible even if the result is not yet available. This is a common setup for games as they will show a semi-static ...


0

I created an drawing app for kids and I think the RenderTexture is the best solution for such applications. You can use visit() method of Sprite and draw(=visit) a point ( probably a circle sprite) on your canvas(=RenderTexture) while touch is moving(=onTouchMoved). Don't forget to call RenderTexture->begin()/end() when using visit function. This if ...


6

In short - it is better to do the transformation on the GPU. Firstly, the GPU is designed to support huge amounts of parallelisation. Your CPU on the other hand is not nearly as capable. The NVIDIA GTX 980, for example, has 2048 CUDA cores to process those vertices with in comparison to the 2-16 threads/cores a processor might support. So from a number ...


1

You might actually be better of with using std::map for this one, depending on your exact use-case. I did some testing on our little rendering framework where I thought std::unordered_map would be good for maintaining a map of graphics resources (we are using std::map there now). I found that it's actually slower to use std::unordered_map since the ...


3

The obvious approach to me would be to invert the interaction between Renderer and Mesh, making the render() method a member of Mesh instead, which would take a renderer reference. A Mesh is a higher level concept that the renderer doesn't have to know about, while the mesh obviously has to know about the renderer to be able to draw itself, so it should be a ...


1

glViewport lets you control the part of the screen where the output of your gl drawing commands will get rendered. It affects the gl commands that you issue after setting up the viewport. So, if you want to render the game to full screen and a minimap to a small portion, then: set glViewport to the entire screen, render game set glViewport to the minimap ...


1

I do not think that allowing clients to validate a mesh is a problem, this allows for a clean api and maintainable code. It makes it extensible for example if later you want to add some code into the validation step etc. (However the last part could also be handled with private functions and a friend class) Remark that if clients cannot validate / prepare a ...


8

The approach you've described, using locks, would be very inefficient and most likely slower than using a single thread. The other approach of keeping copies of data in each thread would probably work well "speed-wise", but with a prohibitive memory cost and code complexity to keep the copies in sync. There are several alternative approaches to this, one ...


1

sizeof(_curKeys)/sizeof(Uint8) does not give you the size of the array, because it's just a pointer from compiler's point of view. Instead of passing NULL as an argument to SDL_GetKeyboardState();, pass a pointer to an integer and the function will write the length of the array to that integer. See documentation. Use that value for both allocating _oldKeys ...


0

To get the position, assume you have a vec3 that hold the position of the ship. All what you have to do is to set the position of the bullet to that vec3 of the player.


2

AFAIK standard procedure is to have resources stored in a map-like structure with strings as keys, since it's extensible as you've seen. However, for the core game elements (especially the performance-critical ones), the resources will be explicitly linked instead of involving a key-lookup, thus skipping the lookup overhead. For example, you might have a ...


1

This is one reason why the friend keyword exists. Both Mesh and Renderer are part of the same system: You can't really use Mesh without Renderer and vice-versa. You should probably still use a getter mesh.IsValid() and setter mesh.MarkValid() in case you need to add functionality later, rather than access valid_ directly. It would be nice if C++ had ...


0

Look into "Shader Constants Buffers" on DirectX and "Uniform Buffers" on OpenGL. These allow sending shader parameters all at once to the GPU and possibly reusing them every frames without having to resend them over the bus.


2

It isn't entirely clear what you are asking. Setting shader parameters IS a bottleneck - that's why engines batch by material - textures, parameters, lights, etc. While CPUs and GPUs are efficient, in order to get the most out of rendering performance you have to think about these things.


1

For completeness, I'll document the "reinventing the wheel" approach. I recently wanted to do this too, but I wanted to do it statically (due to some code-structure decisions made before that I didn't want to break). So I didn't want to create a sensor body and World.Step, as previously suggested. Instead, I figured that a convex polygon intersects with a ...



Top 50 recent answers are included