Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
I've always used timeGetTime, and whatever caveats that entails. You need to use timeBeginPeriod to raise its precision though.

Adbot
ADBOT LOVES YOU

ZorbaTHut
May 5, 2005

wake me when the world is saved

ehnus posted:

You just never know, sometimes it just slips peoples minds when it comes to calling expensive functions, sometimes people just don't know the cost of functions. There is an alternative in __rdtsc() as it's really fast but unfortunately it's not reliable on multiple core machines so it can be ruled out for most cases.

Not reliable on singlecore laptops either, from what I hear :v: It's just sort of bad in general.

GringoGrande
Jul 27, 2001
Nah...

Chris Awful posted:

I'm working on a 2D isometric map in Python using Pygame. Creating a map at 640x480 with 32x32 tiles which comes out to 300 map tiles for just the first Z axis. However, I need 16 Z axises. So that is 4800 tiles which each contain an image. With such a giant list(array), FPS is sluggish.

I noticed that changing the resolution to 352x352 improves FPS to an ideal frame rate, but isn't the ideal resolution I'm looking for. Does anyone have any recommendations for increasing FPS?

Also, I use formula to convert a list position into (x, y, z) positions, could this have a substantial impact on the frame rate?


Here is the source, without data files. (It won't run.)
It's overkill to store the image in each individual cell. Load all the images into a list and then create method for the cell objects to return the image data that should be blitted.

ehnus
Apr 16, 2003

Now you're thinking with portals!

ZorbaTHut posted:

Not reliable on singlecore laptops either, from what I hear :v: It's just sort of bad in general.

It's reliable, you just don't read the clock frequency at program startup and never check it again ;). The problem with rdtsc is when multiple core processors enter power save mode and their internal counters skew -- if you read the timebase on one core and the thread migrates before you can read it again you may see your computer going back in time.

Chris Awful
Oct 2, 2005

Tell your friends they don't have to be scared or hungry anymore comrades.

GringoGrande posted:

It's overkill to store the image in each individual cell. Load all the images into a list and then create method for the cell objects to return the image data that should be blitted.

Thanks. Increased frame rate and the program startup is faster. Also, I noticed that scrolling pixel for pixel was taking 150k cycles. Knocked that down to 38k cycles by scrolling each 4 pixels.

Chris Awful fucked around with this message at 20:21 on May 26, 2008

GringoGrande
Jul 27, 2001
Nah...

Chris Awful posted:

Thanks. Increased frame rate and the program startup is faster. Also, I noticed that scrolling pixel for pixel was taking 150k cycles. Knocked that down to 38k cycles by scrolling each 4 pixels.
Scrolling is just displacement of a static image, so you should be able to just blit it upon it self, with a slight adjustment.

If you want to speed up the game even more, you should only draw the map when the state has changed somehow, and then you could even try and narrow it down so you only redraw the affected tiles.

American Psychonauts
Dec 27, 2005

...but inside doesn't matter
I've been working on this Flash game in my free time and I'd like to get some feedback about just about anything. I've made some big changes lately so I wanna see how people feel about them.
Most of the levels look crude because I just whipped them up in a day to try a new kind of gameplay style.

http://hatu.biz/whifBeta/

Try out the powers too, most people seem to forget them. I personally like 1 the best

TSDK
Nov 24, 2003

I got a wooden uploading this one

OneEightHundred posted:

FBX and COLLADA both contain a shitload of information, I'm really not sure what more you'd want out of them.
Lots of things. Compression options for textures, scripted node tagging, manual layering for non-sorted alpha objects etc... It just depends if you're using them purely for the modelling stage, or if they're an integral part of the toolchain.

The whole Maya/Max interchange thing has come up very recently on another project as well, and neither FBX nor COLLADA manage to preserve the materials properly between packages.

Luminous
May 19, 2004

Girls
Games
Gains

American Psychonauts posted:

I've been working on this Flash game in my free time and I'd like to get some feedback about just about anything. I've made some big changes lately so I wanna see how people feel about them.
Most of the levels look crude because I just whipped them up in a day to try a new kind of gameplay style.

http://hatu.biz/whifBeta/

Try out the powers too, most people seem to forget them. I personally like 1 the best

Looks like a good start! Did you mean to leave the mega ball (debug) in? Because, that thing rules ;) This is mindlessly fun :p but I ran out of levels :( I also had -468/200 HP?

Luminous fucked around with this message at 17:53 on May 27, 2008

Gary the Llama
Mar 16, 2007
SHIGERU MIYAMOTO IS MY ILLEGITIMATE FATHER!!!

Paradoxish posted:

Edit- Just realized that I completely missed part of your question. Your delta is your frametime, which is the inverse of your framerate. Taking your average framerate is easy and something you can do trivially in your update function:

code:
static const float interval = 1.f;
static float numFrames = 0.f;
static float timeElapsed = 0.f;

numFrames += 1.f; // each time through your update function one frame has been rendered
timeElapsed += delta; // and delta time has passed

if (timeElapsed >= interval)
{
    // the number of frames rendered since the last time interval passed by is your average framerate
    // over 1 second, in this case
    fps = numFrames;
    timeElapsed = 0.f;
    numFrames = 0.f;
}

My delta is always higher than interval.

Delta is usually something like 1.6761907e-006, so it's never even entering the inside of the if statement. Any thoughts on what I'm doing wrong?

deadjb
Aug 11, 2002

I'm looking into implementing a templated fixed point class in C++, but before I go reinventing the wheel, does anybody know of an existing one available for download? Most of the ones I've come across don't really cut it.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

SkankerX posted:

I'm looking into implementing a templated fixed point class in C++, but before I go reinventing the wheel, does anybody know of an existing one available for download? Most of the ones I've come across don't really cut it.

I don't, but I'm curious as you what you want to use it for. The consensus I had always heard was that fixed point calculations were pretty much un-necessary after the Pentium, due to the relative speed- and accessibility of floating point co-processors. I suppose it might be useful for data packing?

deadjb
Aug 11, 2002

Nuke Mexico posted:

I don't, but I'm curious as you what you want to use it for. The consensus I had always heard was that fixed point calculations were pretty much un-necessary after the Pentium, due to the relative speed- and accessibility of floating point co-processors. I suppose it might be useful for data packing?

Fixed point is still necessary for most portables, including the iPhone (for OpenGL ES) and for the DS (for everything). Having a nice, type safe fixed point class which overloads the standard mathematical operators would go a long way in keeping other dependent code platform agnostic (typedef real numbers as float or fixed, depending).

That Turkey Story
Mar 30, 2003

SkankerX posted:

I'm looking into implementing a templated fixed point class in C++, but before I go reinventing the wheel, does anybody know of an existing one available for download? Most of the ones I've come across don't really cut it.

There is a C extension for fixed-point math that some compilers support which you can use unless you really just want a template version. I have a template library for fixed-point math partially implemented but I don't have it up anywhere and I doubt I will finish it anytime soon.

Nuke Mexico posted:

I don't, but I'm curious as you what you want to use it for. The consensus I had always heard was that fixed point calculations were pretty much un-necessary after the Pentium, due to the relative speed- and accessibility of floating point co-processors. I suppose it might be useful for data packing?

As was pointed out, floating point is not always available, but aside from that, sometimes you just genuinely want a fixed granularity between your values as opposed to a scientific notation form of storage. I.E. A fixed-point decimal representation taken to 2 decimal places is often perfect for representing a value of some quantity in dollars. For these types of data, a floating point representation, decimal or not, is generally just asking for trouble.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

SkankerX posted:

Fixed point is still necessary for most portables, including the iPhone (for OpenGL ES) and for the DS (for everything). Having a nice, type safe fixed point class which overloads the standard mathematical operators would go a long way in keeping other dependent code platform agnostic (typedef real numbers as float or fixed, depending).

ahh, that completely makes sense

deadjb
Aug 11, 2002

That Turkey Story posted:

There is a C extension for fixed-point math that some compilers support which you can use unless you really just want a template version. I have a template library for fixed-point math partially implemented but I don't have it up anywhere and I doubt I will finish it anytime soon.

If you're willing to share, I'd appreciate it. If I add anything to it I'll contribute it back upstream.

Jo
Jan 24, 2005

:allears:
Soiled Meat
Okay, static lighting is working like a champ. I'm going to push dynamic lighting to see if I can't come up with anything.

First question:
I'm thinking about placing the shadow-casting objects in a quadtree, but I'm not sure at what object count the speed benefits will be apparent. My other alternative is to build a list of shadow casters and discard all objects outside the light sphere rectangle. If I use an early out algorithm for detection, can I expect a significant performance improvement in a map with 60-70 shadow casters?

Second question:
What kind of overhead does building a render list entail? I'd like to build one every time a dynamic light is moved so performance will be snappy when they're still. Is this a silly thing to do?

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Jo posted:

If I use an early out algorithm for detection, can I expect a significant performance improvement in a map with 60-70 shadow casters?
As long as you are actually culling a good portion of the potential set, it is generally a good idea to use cheap calculations to skip complex ones.

quote:

My other alternative is to build a list of shadow casters and discard all objects outside the light sphere rectangle.
Can you do both? i.e. cull off shadow casters to build the list? If you're ever going to do calculations on the shadow list multiple times, it's probably a good idea to store the shadow caster list because it scales a lot better.

quote:

Second question:
What kind of overhead does building a render list entail? I'd like to build one every time a dynamic light is moved so performance will be snappy when they're still. Is this a silly thing to do?
It depends what you're doing. Best thing to do is have two algorithms, one which generates shadow information that minimizes rendering time by culling out unneeded shadowing information (for still lights, done once), one which processes the shadow casters faster but renders slower (for dynamic lights, done repeatedly).

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

Jo posted:

First question:
I'm thinking about placing the shadow-casting objects in a quadtree, but I'm not sure at what object count the speed benefits will be apparent. My other alternative is to build a list of shadow casters and discard all objects outside the light sphere rectangle. If I use an early out algorithm for detection, can I expect a significant performance improvement in a map with 60-70 shadow casters?

It really depends all on how balanced your pipeline is and where your bottlenecks are. For my money, I'd say an oct-/quad-/bin-tree is a great solution to this. For my money, what you ACTUALLY want to do is to keep TWO spatial hierarchies -- one has all the dynamic lights in it, one has all the dynamic objects in it. When one moves, it intersects it's "bounds" (size of the objects, distance-to-90% attenuation or something for the lights) with the tree for the other class of object, triggering any updates as needed.

gibbed
Apr 10, 2006

Havok announced a few months ago that they would be releasing the core library for Havok to the public, looks like they finally got around to it:

http://www.havok.com/tryhavok

quote:

The No-Charge Havok PC download is a binary-only bundle that includes all of the standard features and functionality of both the Havok™ Physics and Havok™ Animation products. The download includes Havok SDK libraries, samples, and technical documentation for software developers; as well as Havok's Content Tools for preparation and export of physical assets and characters directly from recent versions of popular 3D modeling and animation tools.

Looks like they are being friendly to cheapo game developers too:

quote:

If you plan to sell your commercial PC Game above a retail value of $10 USD, (or equivalent amount in other currencies based on prevailing exchange rates at the time of launch), you must first request a no-charge PC Game distribution license from Havok at https://www.havok.com/PCgamedistribution, prior to retail release of your game. This PC Game distribution agreement is required to ensure you have complied with Havok logo, copyright, and attribution requirements, and that your application is a PC game (commercial non-game application distribution is not allowed). There will be no fee associated with this because the license fee has been covered by Intel under a commercial agreement with Havok.

SDK download is ~230MB.

heeen
May 14, 2005

CAT NEVER STOPS

gibbed posted:

Havok announced a few months ago that they would be releasing the core library for Havok to the public, looks like they finally got around to it:
http://www.havok.com/tryhavok
Looks like they are being friendly to cheapo game developers too:
SDK download is ~230MB.

Excellent I have been waiting for this. Now I wonder wether I should try Havok or PhysX first. Can anyone compare the two?

ValhallaSmith
Aug 16, 2005

heeen posted:

Excellent I have been waiting for this. Now I wonder wether I should try Havok or PhysX first. Can anyone compare the two?

PhysX was bought by Nvidia. They also promise GPU support in the near future. The free version of havok doesn't have all GPU enabled stuff.

On the other hand havok's animation tool set is top notch. So I guess it depends on what you need from the physics engine.

vanjalolz
Oct 31, 2006

Ha Ha Ha HaHa Ha
Which one is better development wise? Eg. easier to start with?

Do either of them have xna/c# bindings?

Paradoxish
Dec 19, 2003

Will you stop going crazy in there?

Gary the Llama posted:

My delta is always higher than interval.

Delta is usually something like 1.6761907e-006, so it's never even entering the inside of the if statement. Any thoughts on what I'm doing wrong?

Ack, I've been kind of busy for the last week so I totally forgot about this thread. If you're still having problems would you mind posting the full code you're using? You're multiplying the time delta from querying the performance counter by the frequency of the counter, right? Otherwise you'll just end up with the difference in ticks, which is going to be significantly larger than the difference in seconds.

This is the exact code I'm using for my game dev competition entry in games. I didn't want to copy this directly before because there's extra crap in there that gets in the way of the timing code, but I figured it might be useful if you're having issues:

code:

        __int64 ticksPerSec = 0;
	QueryPerformanceFrequency((LARGE_INTEGER*)&ticksPerSec);
	float ticksPerCnt = 1.0f / (float)ticksPerSec;

	__int64 prevTimeStamp = 0;
	QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);

	// Pump any received messages and transfer control over to the game logic and
	// rendering code when there aren't any
	while(msg.message != WM_QUIT)
	{
		if (PeekMessage ( &msg, 0, 0, 0, PM_REMOVE ))
		{
			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}
		else
		{
			if ( isPaused() )
			{
				Sleep(20);
				continue;
			}

			if ( !deviceLost() && !mAppClosed )
			{
				__int64 currTimeStamp = 0;
				QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
				float dt = (currTimeStamp - prevTimeStamp) * ticksPerCnt;
				
				updateScene(dt);

				if (!mAppClosed)
				{
					renderScene();
				}

				prevTimeStamp = currTimeStamp;
			}
		}
	}

Paradoxish fucked around with this message at 16:24 on Jun 3, 2008

ValhallaSmith
Aug 16, 2005

vanjalolz posted:

Which one is better development wise? Eg. easier to start with?

Do either of them have xna/c# bindings?

I think physx has XNA bindings. Havok isn't really that well supported by the amateur community yet. But if you need an animation system for your game then Havok is probably a good choice. I would say neither of the engines is overly difficult, though they both have their own quirks.

snack soul
Jul 6, 2005

It may be worth mentioning that there are stability issues with QueryPerformanceCounter on certain hardware. For my own projects, I use something similar to the example in the following article to check for leaps or negative elapsed time.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q274323

Heisenberg1276
Apr 13, 2007
What would you guys recommend for getting into games development (to enter the game dev competitions for example).

I'm not new to programming, I know Java and PHP well and have a working knowledge of Ruby (for use with Rails mostly) however I've done very little game development in the past. Really I'm looking for an engine which will cover lots of the stuff for me while letting me be creative.

I've looked at blitzmax but can't find any decent information on how to get started.

Also I'm on OSX so can't use anything Windows only such as that XNA.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

DBFT posted:

What would you guys recommend for getting into games development (to enter the game dev competitions for example).

I'm not new to programming, I know Java and PHP well and have a working knowledge of Ruby (for use with Rails mostly) however I've done very little game development in the past. Really I'm looking for an engine which will cover lots of the stuff for me while letting me be creative.

I've looked at blitzmax but can't find any decent information on how to get started.

Also I'm on OSX so can't use anything Windows only such as that XNA.

I always consider writing a Tetris clone to be the "Hello World" of a new game system (graphics library/framework, language, etc).

Depending on what you're doing, I'd suggest either SDL+OpenGL or Ogre3D. If you're starting with a simple game, then do the SDL+OpenGL route because Ogre3D would be a bit of Overkill

Ferg
May 6, 2007

Lipstick Apathy

Nuke Mexico posted:

I always consider writing a Tetris clone to be the "Hello World" of a new game system (graphics library/framework, language, etc).

Depending on what you're doing, I'd suggest either SDL+OpenGL or Ogre3D. If you're starting with a simple game, then do the SDL+OpenGL route because Ogre3D would be a bit of Overkill

I'll vouch for passing over Ogre3D as your first try. I tried diving head first into that with a solid knowledge of C++ and it ended up being way too much for a beginner.

Heisenberg1276
Apr 13, 2007
Fair enough. I Guess I'll go with SDL+OpenGL.

I have some knowledge of C so I guess I'll use C and try to fill in the blanks in my knowledge as I go. Does anyone have any recommendations for tutorials/books for beginning with SDL+OpenGL?

more falafel please
Feb 26, 2005

forums poster

ValhallaSmith posted:

I think physx has XNA bindings. Havok isn't really that well supported by the amateur community yet. But if you need an animation system for your game then Havok is probably a good choice. I would say neither of the engines is overly difficult, though they both have their own quirks.

Havok rules :c00lbert:

shodanjr_gr
Nov 20, 2007

DBFT posted:

I have some knowledge of C so I guess I'll use C and try to fill in the blanks in my knowledge as I go. Does anyone have any recommendations for tutorials/books for beginning with SDL+OpenGL?


I havent worked with SDL, but as far as OGL goes, you cant go wrong with The Red Book. That, plus the tutorials by NeHe on Gamedev should set you well on your way.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

DBFT posted:

Fair enough. I Guess I'll go with SDL+OpenGL.

I have some knowledge of C so I guess I'll use C and try to fill in the blanks in my knowledge as I go. Does anyone have any recommendations for tutorials/books for beginning with SDL+OpenGL?

NeHe's for scrubs.. Nate Robins is where it's at http://www.xmission.com/~nate/tutors.html

Gary the Llama
Mar 16, 2007
SHIGERU MIYAMOTO IS MY ILLEGITIMATE FATHER!!!

Paradoxish posted:

Ack, I've been kind of busy for the last week so I totally forgot about this thread. If you're still having problems would you mind posting the full code you're using? You're multiplying the time delta from querying the performance counter by the frequency of the counter, right? Otherwise you'll just end up with the difference in ticks, which is going to be significantly larger than the difference in seconds.

This is the exact code I'm using for my game dev competition entry in games. I didn't want to copy this directly before because there's extra crap in there that gets in the way of the timing code, but I figured it might be useful if you're having issues:

code:

        __int64 ticksPerSec = 0;
	QueryPerformanceFrequency((LARGE_INTEGER*)&ticksPerSec);
	float ticksPerCnt = 1.0f / (float)ticksPerSec;

	__int64 prevTimeStamp = 0;
	QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);

	// Pump any received messages and transfer control over to the game logic and
	// rendering code when there aren't any
	while(msg.message != WM_QUIT)
	{
		if (PeekMessage ( &msg, 0, 0, 0, PM_REMOVE ))
		{
			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}
		else
		{
			if ( isPaused() )
			{
				Sleep(20);
				continue;
			}

			if ( !deviceLost() && !mAppClosed )
			{
				__int64 currTimeStamp = 0;
				QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
				float dt = (currTimeStamp - prevTimeStamp) * ticksPerCnt;
				
				updateScene(dt);

				if (!mAppClosed)
				{
					renderScene();
				}

				prevTimeStamp = currTimeStamp;
			}
		}
	}

My code is pretty much exactly that.

Mind showing me your updateScene() function?

vanjalolz
Oct 31, 2006

Ha Ha Ha HaHa Ha

more falafel please posted:

Havok rules :c00lbert:

Elaborate!!

Nuke Mexico posted:

NeHe's for scrubs.. Nate Robins is where it's at http://www.xmission.com/~nate/tutors.html

I hear that NeHe is bad, but there is a LOT more stuff on there than Nate's website.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

vanjalolz posted:

Elaborate!!


I hear that NeHe is bad, but there is a LOT more stuff on there than Nate's website.

Yeah, but honestly your average Tutorial on GameDev.net is probably about as good anyways

Crash Bandicoot
Feb 23, 2007

by T. Fine
I am trying to display data in the BLP Format on screen in a Managed DirectX application coded in C#. If you've no idea what BLP is that's fine, because the gist is that I have a chunk of image data compressed as DXT1 stored in a stream. What I want to do is draw that image onto the screen.

I've spent the evening reading and searching half the internet for more information, but I can't for the life of me figure out how to turn that DXT1 data into a Texture. Does DirectX support the format natively somehow or am I going to have to write my own function to decompress the data into a Bitmap? I've got very limited experience working with DirectX or real time rendering in general, so I've no idea where to even start looking for more information.

I've tried creating a new texture using the following constructor:
code:
Texture(Device device, int width, int height, int numLevels, 
        Usage usage, Format format, Pool pool)
This constructor access Format as an argument, which is an enum, and one of its values is Format.DXT1. Unfortunately once the Texture is instantiated I am not sure how to pass it the actual image data.
Another constructor accepts a Stream of data as an argument, but attempting to use this method generates a "Parameter is not valid." error, presumably because the Stream is not a bitmap.

So, yeah, I'm confused and not sure what to try next :(

Crash Bandicoot fucked around with this message at 22:50 on Jun 8, 2008

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Crash Bandicoot posted:

Unfortunately once the Texture is instantiated I am not sure how to pass it the actual image data.
If it works anything like the C++ version, then the Texture is an interface which has a method called LockRect which will let you access a portion of the texture (including writing to it). Call UnlockRect when you're done with it.

EDIT -- In MD3D they're called LockRectangle and UnlockRectangle respectively. Apparently the MSDN pages for them are broken and the only documentation for them are in Japanese, so good luck.
http://msdn.microsoft.com/en-us/library/bb152978(VS.85).aspx

OneEightHundred fucked around with this message at 23:20 on Jun 8, 2008

Floor is lava
May 14, 2007

Fallen Rib
How would you get around having opengl textures that are not 64, 128, or 256 pixels in width/height?

Adbot
ADBOT LOVES YOU

krysmopompas
Jan 17, 2004
hi

dsage posted:

How would you get around having opengl textures that are not 64, 128, or 256 pixels in width/height?
ARB_texture_non_power_of_two

Otherwise, round up and waste the extra space (or find a creative use for it.)

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply