So I have an FPS game, I dont really but lets say i do, My algorithims are all shiny, nice and clean. I have Mesh Detail Rendering, Meaning the futhur away from the object the less polygons rendered. But it Still Runs like shit, It Is C++ OpenGL With SDL Libraries. How Do I Optimise it?
First you need to know where the program is spending its time, which you do by profiling. Since it's a game you'll need to profile both the CPU and the GPU, and understand how they interact. Either the CPU or the GPU could be the performance bottleneck, which is called being "CPU-limited" or "GPU-limited".
If you haven't already, you'll want to add GPU and CPU frame time measurement to your engine. For the CPU you can use
QueryPerformanceCounter on Windows, or
clock_gettime on Linux. I wrote a blog post on GPU profiling awhile back that shows how to add GPU timer queries to your frame. It's written about D3D11, but the same concepts apply to OpenGL, using the
Having built-in realtime performance data in your engine is nice for getting an overview of what's going on, or moving around in the game and seeing how performance changes in different places or situations. For going deeper, there are external tools like AMD's CodeXL (what used to be CodeAnalyst) for detailed CPU profiling, and for OpenGL graphics profiling there's gDEBugger. These tools work by capturing detailed performance data about a single frame or a few frames of your game, then letting you browse and analyze that data to see, for instance, which functions in your code are taking the most time, or which draw calls are taking longest to render on the GPU.
Once you've done the profiling and figured out what's slow about your game, the next step is to make it faster...but that's a whole other topic, and this post has gone on long enough.