Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Sep 2013
Offline Last Active Oct 20 2014 11:12 PM

Topics I've Started

SDL2 vs SDL2/OpenGL

20 October 2014 - 08:15 PM

Hey everyone, I've kind of come to a dilemma and I was wondering if I could get some opinions weighed in


I started to look at SDL 2.0 today. Ran through some Lazy Foo tutorials and could not help feel like I should just learn go ahead and start learning openGL again. Coming from learning openGL and directX on and off in the past, it feels wrong when I see some of the SDL API calls. I mean am just blowing things out of proportion?


I know SDL does a lot of other things like mouse and keyboard, but strictly looking at graphics is pure no openGL SDL enough?


The game I would like to develop would only be 2D, have particle effects, 2D lighting, 2D water, and maybe a few other things along those lines


What are your guy's thoughts?



ActionScript 3, Timesteps, and the fixed time step

22 December 2013 - 08:45 PM

Hey everyone, I'm looking into creating a AS3 game and I am back to the place where things kind of fall apart
The Game Loop


This critical component has crippled me. I'm attempting to implement a fixed timestep game loop, but for some reason I have a very noticeable jitter/jerk moment

I have read this this article http://www.koonsolo.com/news/dewitters-gameloop/ and http://gafferongames.com/game-physic...your-timestep/

And a bunch of other things, but no matter what I unfortunately can't seem to get it 'working'.


On the above links, I have tried both approachs. It seems as if something has gone horribly wrong with my interpolation or set up of the loop.

Currently I'm am attempting to use Gafferon's approach again but...


My graphic ( a 32x32 square ) jitters constantly. It hiccups when moving and then twitchs in place when standing still. Even with interpolation


Can someone please point out wheat I'm doing wrong? biggrin.png

/* Above load in the image, set up other items, set the stage framerate to 60 */

public var fixedDelta:Number = 1 / 60;
public var minDelta:Number = 1 / 30;
public var accumulator:Number = 0.0;
public var ratio:Number;

//Called on ENTER FRAME
private function mainLoop(e:Event):void

	//Get the time and calc delta time in seconds
	now = getTimer();
	deltaTime = (now - last) * .001;
	if (deltaTime > minDelta)
		deltaTime = minDelta;
	last = now;

	//Add on to the accumulator
	accumulator += deltaTime;

	//While we need to update; Update
	while (accumulator >= fixedDelta)
		//Update with out fixed DT
		accumulator -= fixedDelta;

	//Calc the interpolation ratio
	ratio = accumulator / fixedDelta;

//Main update function
public function update(dt:Number):void

//Main render function
public function render(ratio:Number):void
	canvas.fillRect(canvas.rect, 0x000000FF);

//============== Square update and draw

//Square update
public function update(dt:Number):void
	prevPosition.x = position.x;
	prevPosition.y = position.y;
		position.x += 300 * dt;
		position.x -= 300 * dt;

//Square draw function
public function draw(ratio:Number):void
	renderPosition.x = int(position.x * ratio + prevPosition.x * (1 - ratio));
	renderPosition.y = int(position.y * ratio + prevPosition.y * (1 - ratio));
	Main.canvas.copyPixels(image, image.rect, renderPosition);

Good Performance test?

08 December 2013 - 06:21 PM

So I have finally got a batcher going using a Vertex and Index buffer

But the real question in my head is... how good is it? Is there a good method of testing this?


It is only rendering untextured Quads that are 32 x 32 (no rotation or etc)

And my buffers can hold exactly 10000 Quads

	for(int i = 0; i < 10000; i++)
		batcher->draw((rand()%700) + 10, (rand()%500) + 10, 32.0f, 32.0f);

If my dev specs are:

Core Duo 2 2.66 GHz

4.0 Gb Ram

Ati Mobility Radeon HD 4670


And I have a dt time of ~0.036 to 0.037 seconds how am I doing?

D3D11 DrawIndexed confusion

07 December 2013 - 08:28 PM

I'm working on using a vertex and index buffer to draw some quads to the screen, but I'm running into some issues with some flickering. It seems that I'm not drawing all of the quads I need every frame.


For testing, my vertex and index buffer can only hold a max of 3 quads. Once 3 quads of data are in the buffer I call DISCARD to get a new buffer to use. Currently, I'm attempting to draw 4 quads, but for some reason I only draw 3 of the 4 quads for two frames. Meaning I draw all 4 quads, then only draw 3, draw 3 again, then draw all 4.

What is weird to me is that my first quad is the one that is at fault. It gets placed into the buffer, but it seems like it gets skipped when I do the draw call.


The only thing I can think of is that I am not using the StartIndexLocation and BaseVertexLocation parameters properly for the DrawIndexed call.

My Index Buffer is 16-bit and uses USHORTs. My draw call looks like:

//indexDrawCount (UINT): Number of indices used in the draw call
//indexOffset (UINT): Where to start in the index buffer
//drawnVertexCount (int): Where to start in the vertex buffer
batchContext->DrawIndexed(indexDrawCount, indexOffset, drawnVertexCount);

Here is my whole method: http://pastebin.com/XeMzX0WF


Could someone please shed some light on what is going on?


Present call 1 [ All quads draw; Buffer is fresh ]

Attached File  frame1.png   27.18KB   2 downloads


Present Call 2 [Only draws the last 3; Buffer had 1 Quad of data in it at start]

Attached File  frame2.PNG   34.44KB   4 downloads


Present Call 3 is the same as Call 2 [Only draws the last 3; Buffer had 2 Quads of data in it at start]

Present Call 4 is the same as Call 1 [Draws all 4 quads; Buffer had no data in it at start]


Render method in Main.cpp

void render()
	systemX11.deviceContext->ClearRenderTargetView(systemX11.backBufferRenderTarget, D3DXCOLOR(0.0f, 0.2f, 0.4f, 1.0f));

	batcher->draw(0.0f, 0.0f, 32.0f, 32.0f);
	batcher->draw(50.0f, 0.0f, 32.0f, 32.0f);
	batcher->draw(100.0f, 0.0f, 32.0f, 32.0f);
	batcher->draw(150.0f, 0.0f, 32.0f, 32.0f);



D3D11 Placing data directly into Map Resource?

06 December 2013 - 06:18 PM

I was wondering, is it possible to place index data directly into a Map Resouce without using memcpy?


I'm working on a sprite batcher and right now I use memcpy to place the vertex data from my Quad struct into the vertex Map Resouce. But I don't really think I need use memcopy for my index data, since I can just base the index I need off the current vertex buffer position. In D3D9 I was able to do this by doing

//Load the indices in the index buffer
indices[currentIndexBufferPosition] = currentVertexBufferPosition;
indices[currentIndexBufferPosition + 1] = currentVertexBufferPosition + 1;
indices[currentIndexBufferPosition + 2] = currentVertexBufferPosition + 2;
indices[currentIndexBufferPosition + 3] = currentVertexBufferPosition + 3;
indices[currentIndexBufferPosition + 4] = currentVertexBufferPosition;
indices[currentIndexBufferPosition + 5] = currentVertexBufferPosition + 2;

Is this possible with Map Resources and D3D11? Or will I need to make a tiny index array just so I can use memcpy?