Jump to content

  • Log In with Google      Sign In   
  • Create Account

Zaoshi Kaba

Member Since 04 Nov 2012
Offline Last Active Yesterday, 01:02 PM

#5172351 DXGI leak warnings

Posted by Zaoshi Kaba on 08 August 2014 - 03:24 PM

Refcount of 0 means object has been released but not destroyed yet. It'll happen sometime later, don't worry about these.

IntRef of >= 1 means object is bound (PSSetShader, etc), shouldn't worry about these either, they'll get destroyed once possible.


Though you have some objects with massive amount references:

Live ID3D11RasterizerState at 0x009E872C, Refcount: 2337

Live Object at 0x00BCC7BC, Refcount: 448.


Are you sure you don't have regular memory leaks leading to objects not being destroyed?

Do you destroy all ComPtr before releasing device?

#5172130 Inertia Causing Extremely odd effects.

Posted by Zaoshi Kaba on 07 August 2014 - 03:03 PM

That's weird. Could you try to replace your main / WinMain method with this code just to test whether you get correct results with minimal code?

And of course you'll need to fix Bullet paths.

#include <iostream>
using std::cout;
#include <DirectXMath.h>
using DirectX::XMFLOAT3;
#include "../Bullet Physics/btBulletCollisionCommon.h"
#include "../Bullet Physics/btBulletDynamicsCommon.h"
#pragma comment(lib, "../x64/Debug/Bullet Physics.lib")

btRigidBody* addRigidSpehere(float rad, XMFLOAT3 position)
	btTransform t;
	t.setOrigin(btVector3(position.x, position.y, position.z));

	btSphereShape* sphere = new btSphereShape(rad);

	//calculate inertia
	btVector3 inertia(0.0, 0.0, 0.0);
	sphere->calculateLocalInertia(1.0, inertia);

	btMotionState* motionState = new btDefaultMotionState(t);
	btRigidBody::btRigidBodyConstructionInfo info(1.0, motionState, sphere, inertia);
	btRigidBody* sphereBody = new btRigidBody(info);

	return sphereBody;

void main() {
	auto bulletConfiguration = new btDefaultCollisionConfiguration();
	auto bulletDispatcher = new btCollisionDispatcher(bulletConfiguration);
	auto bulletBroadPhaseInterface = new btDbvtBroadphase();
	auto bulletSolver = new btSequentialImpulseConstraintSolver();

	auto bulletWorld = new btDiscreteDynamicsWorld(bulletDispatcher, bulletBroadPhaseInterface, bulletSolver, bulletConfiguration);
	bulletWorld->setGravity(btVector3(0, -10, 0));

	btTransform t;
	t.setOrigin(btVector3(0, 0, 0));

	btStaticPlaneShape* plane = new btStaticPlaneShape(btVector3(0, 1, 0), 0.0);
	btMotionState* motionStatePlane = new btDefaultMotionState(t);
	btRigidBody::btRigidBodyConstructionInfo info(0.0, motionStatePlane, plane);
	btRigidBody* planeBody = new btRigidBody(info);


	auto sphere = addRigidSpehere(1, XMFLOAT3(0, 3, 0));

	while(1) {
		bulletWorld->stepSimulation(1.0 / 60.0);
		cout << sphere->getWorldTransform().getOrigin().getX() << ", ";
		cout << sphere->getWorldTransform().getOrigin().getY() << ", ";
		cout << sphere->getWorldTransform().getOrigin().getZ() << "\n";

#5172100 Inertia Causing Extremely odd effects.

Posted by Zaoshi Kaba on 07 August 2014 - 01:13 PM

I probably have 2.82 too. Are you sure you're not modifying it somewhere accidently; like force, velocity, or position?

I used this loop and a debugger to inspect values:

	while(1) {
		bulletWorld->stepSimulation(1.0 / 60.0);
		OutputDebugString(L", ");
		OutputDebugString(L", ");

First few values are 3.0 and lower, but eventually it stops at 0.000000, 1.000000, 0.000000 and just spams that.

(seems debugger and outputting to debug console gives different numbers; rounding?).

#5172090 Inertia Causing Extremely odd effects.

Posted by Zaoshi Kaba on 07 August 2014 - 12:27 PM

I am unable to reproduce this problem. I copy pasted your code and sphere stops at position {0.000000000, 0.999999821, 0.000000000, 0.000000000}.

#5171808 Interrupt handling very slow

Posted by Zaoshi Kaba on 06 August 2014 - 03:03 AM

I noticed a lot of people make mistake of using if(PeekMessage(&message, 0, 0, 0, PM_REMOVE)) instead of while(...) inside game loop, this might be source of the problem.

#5170975 Isn't "delete" so pesky to type? Wish there was a better way?

Posted by Zaoshi Kaba on 01 August 2014 - 03:54 PM

I am disturbed by how legit this thread sounds.

#5170613 [Questions] First RenderLoop with Fixed Time-Step and Animations ...

Posted by Zaoshi Kaba on 31 July 2014 - 09:23 AM

Basically I want to make sure my RenderLoop runs properly

Define properly. Most would say you need to use fixed time step to have proper game loop. There's a link in your code, and if that isn't sufficient I can also suggest this article.


running at the Time I've intended them to run independent of the FPS

You just measure time since last frame and move everything by that much. For example, your character moves 2 m/s, so you multiply that by time elapsed in seconds and you get distance character moved since last frame. This will happen in your Update() function.


However, if you are using fixed time step then elapsed time in Update() function will be constant, ex. 0.03(3) seconds if you want 30 UPS (updates per second). Then your Render() function interpolates between last position and current position (it's explained in the article I linked earlier).

#5170576 [Questions] First RenderLoop with Fixed Time-Step and Animations ...

Posted by Zaoshi Kaba on 31 July 2014 - 06:14 AM

I might be the only one, but so far I cannot understand what you're trying to do or what is your question.


So far I can only try to answer first question in original post.

The code you posted:

FrameTime = (double)_StopWatch.ElapsedTicks / (Stopwatch.Frequency / 1000);

Stopwatch.Frequency is number of ticks per second, therefore I fail to understand why you divide by 1000 (esp. why integer).

If you want time passed in seconds then you should be doing this:

FrameTime = (double)_StopWatch.ElapsedTicks / (double)Stopwatch.Frequency;

However there's one more thing I'd like to mention:

public void Frame()
	_StopWatch.Stop(); // time stops

	FrameTime = (double)_StopWatch.ElapsedTicks / (double)Stopwatch.Frequency;
	LastUpdated = Stopwatch.GetTimestamp();

	_StopWatch.Restart(); // time restarts
	// but did it count time that passed between Stop and Restart calls?

#5169723 Drawing fullscreen triangle without vertex buffers

Posted by Zaoshi Kaba on 28 July 2014 - 06:24 AM

  1. Is black your clear color?
  2. You return alpha of 0.0f, depending on blending settings which we cannot see your pixels might do nothing;
  3. Set correct primitive topology (TRIANGLESTRIP);
  4. You need to draw 4 vertices to make a quad, at the moment you have only 3;
  5. It doesn't seem you need depth buffer at all; don't bind it.

#5168017 looping through struct array

Posted by Zaoshi Kaba on 20 July 2014 - 03:42 PM

Well that's more or less correct thinking.

Use vector<string> which doesn't have size limit and you can retrieve number of items without making own extra variable.

#5167995 Why Java games do not need installation

Posted by Zaoshi Kaba on 20 July 2014 - 02:24 PM

Java applications do not run without Java runtime installed, it just happens that most users have it installed. On top of that all resources get packaged into .jar file, so you don't need any external files.


Same can be achieved with .exe files, but you wouldn't like 20 GB .exe file, would you?

#5167372 What's the next step after LZ77?

Posted by Zaoshi Kaba on 17 July 2014 - 05:46 AM

LZMA is an improved LZ77 algorithm, you could try using it. I think on average it compresses better than WinRAR.

It's in public domain so you don't need any licenses (I'm not an expert) and could use SDK:


#5165786 Device or Context lost. Should I bother?

Posted by Zaoshi Kaba on 09 July 2014 - 05:53 AM

Device and Context cannot be lost, but Swap Chain can be (though you have to reinstall driver or physically remove GPU). Read more here: http://msdn.microsoft.com/en-us/library/windows/apps/dn458383.aspx

#5163818 very strange bug (when runing c basic arrays code)

Posted by Zaoshi Kaba on 30 June 2014 - 06:51 AM

100*1000 is 100,000 elements, 6 such arrays make 600,000 elements 4 bytes each, that's 2,400,000 bytes or over 2 MB. That's bigger than default stack size, that's why you get crash. Use new[] operator for those arrays and it'll work just fine.

#5162072 Why do we need to iterate data structures as they are already in RAM

Posted by Zaoshi Kaba on 22 June 2014 - 06:29 AM

I'm not sure I understand correctly. Are you asking why we have to look at all values in the array while searching for the one we need?

Imagine with stack of paper pages with just 1 word on each and you need to find page with specific word. You cannot take it out on first try, so you look at all pages 1 by 1 until you find what you need. Same principle is here.