Greg Dolley’s Weblog

A Blog about Graphics Programming, Game Programming, Tips and Tricks

Archive for the ‘OpenGL’ Category

OpenGL Texture Filter Parameters Explained

Posted by gregd1024 on January 17, 2008

As promised by a previous post entitled, “How to Turn Off Bilinear Filtering in OpenGL,” I’m going to explain the various texture filtering combinations behind these two very common OpenGL calls:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, <texture shrinkage filter>);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, <texture expansion filter>);

The value of parameter number three depends on whether you are setting a GL_TEXTURE_MIN_FILTER variable or a GL_TEXTURE_MAG_FILTER variable. Here are the possible combinations:

  1. When the second parameter is GL_TEXTURE_MIN_FILTER, parameter three can be:
    6. GL_LINEAR
  2. When the second parameter is GL_TEXTURE_MAG_FILTER, parameter three can be:
    1. GL_LINEAR

The filter value set for GL_TEXTURE_MIN_FILTER is used whenever a surface is rendered with smaller dimensions than its corresponding texture bitmap (far away objects). Whereas the filter value for GL_TEXTURE_MAG_FILTER is used in the exact opposite case – a surface is bigger than the texture being applied (near objects).

There are more options for the min filter because it can potentially have mipmapping. However, it wouldn’t make sense to apply mipmapping to the mag filter since close-up objects don’t need it in the first place. Here’s a list of all the possible combinations and how they impact what is rendered (first constant in the left-most column is the near object filter [mag]; second constant is the far object filter [min]):

Filter Combination (MAG_FILTER/MIN_FILTER) Bilinear Filtering (Near) Bilinear Filtering (Far) Mipmapping
GL_NEAREST / GL_NEAREST_MIPMAP_LINEAR Off Off Use trilinear filtering
GL_NEAREST / GL_LINEAR_MIPMAP_LINEAR Off On Use trilinear filtering
GL_LINEAR / GL_NEAREST_MIPMAP_LINEAR On Off Use trilinear filtering
GL_LINEAR / GL_LINEAR_MIPMAP_LINEAR On On Use trilinear filtering


Not all of these combinations make sense to use. For example, there’s no point in applying GL_NEAREST with GL_LINEAR_MIPMAP_LINEAR because you’ll still see a sharp “break” between the trilinear filtered portion of a surface and the non-filtered portion. You should use whichever combination makes sense visually without compromising performance.

-Greg Dolley

*Get new posts automatically! Subscribe via RSS here . Want email updates instead? Click here.


Posted in 3D Graphics, OpenGL | 6 Comments »

What’s the Difference Between Bilinear and Trilinear Filtering?

Posted by gregd1024 on January 16, 2008

I’m not sure how many gamers, who aren’t 3D programmers, know what bilinear filtering means; however, I see it in the options of many games. It can be summarized by textures looking blurry up close and eliminating the “blocky pixel” effect which was so common back in the day of pure software-rendered 3D graphics engines. See one of my previous posts entitled, “How to Turn Off Bilinear Filtering in OpenGL” for a few screenshots.

In this post I’ll be explaining what “trilinear filtering” means and how it differs from bilinear. We see an option for trilinear filtering in virtually every game on the market today (although some call it by a different name), and depending on your 3D hardware, it may even be turned on by default. However, most gamers don’t know what trilinear filtering really is (unless they’re graphics programmers) or how it affects the visual characteristics of a game.

In a nutshell, just like bilinear filtering attempts to smooth out blocky pixels via interpolating between one texel and its surrounding four neighbors, trilinear filtering attempts to smooth out mipmapping gradients that are most commonly noticed when the camera is at a narrow angle relative to a wall (or any surface where the texture is very oblique to the point of view). Now, I’d really like to provide a screenshot of what this gradient looks like, but with the high resolution used in today’s games the effect becomes hard to see in a still screenshot. However, the effect is very noticeable when the camera is moving forward or backward.

The effect manifests itself by a sharp break between blurriness levels as a polygon recedes into the distance. At first, the polygon’s texture looks normal (the part closest to the camera). Then as you trace along the polygon’s surface all of sudden the texture loses half its resolution. If you continue tracing, you notice another break where again the resolution is cut in half. In most games this pattern is noticeable about four or five times before the polygon becomes too small to notice.

Trilinear filtering attempts to eliminate this sharp break by dynamically interpolating between different mipmap resolutions at every pixel. For example, instead of choosing between a mipmap resolution 1:1 or 1:2, it dynamically calculates a smooth gradient of mipmap levels between 1:1 and 1:2.

In the end trilinear filtering does a very good job eliminating abrupt changes in texture resolution. In some cases it is hard to tell mipmapping is even being used.

Sometime later in the week or next week, I’m going to cover something known as anisotropic filtering – which is meant to be a step better than trilinear filtering.

If you want to be updated on new posts automatically you can subscribe via RSS here, or if you prefer email updates click here.

-Greg Dolley

Posted in 3D Graphics, DirectX, OpenGL | Leave a Comment »

How to Turn Off Bilinear Filtering in OpenGL

Posted by gregd1024 on January 14, 2008

I don’t know which video game popularized bilinear filtering (or trilinear filtering for that matter) for close-up objects but I personally hate the effect. The only time I can accept the look of filtering textures in this manner is if the texture’s resolution is massively high (so I don’t see the blur). Note: for this post when I say “bilinear filtering” I’m also referring to “trilinear filtering” – both have the same blurring effects.

Let me show you what I mean and then I’ll explain how to turn it off. The effects of bilinear filtering are best seen on textures that contain straight lines. Therefore, I put a simple checkerboard-like texture on a wall and moved the camera close to it:


Notice how the edges of the alternating dark-green / light-green squares are clear and crisp. Now, let’s look at the exact same thing but with bilinear filtering turned on:


The edges are not clear and crisp anymore. The whole texture looks a bit blurry. If we move closer to the wall, it gets even worse:


The screenshot above looks much worse in its original size; click on the picture to enlarge. Now if we didn’t use bilinear filtering it would look like this:


Hence the reason why I don’t like bilinear filtering. It just makes things too blurry. However, I have yet to see any game programming tutorial or OpenGL tutorial explain how to turn it off.

Actually it’s very simple to turn off. After loading a texture you need to make the following two function calls:



Most code examples already have these calls except the values for parameter three are different. The value for that parameter depends on parameter two. Here are possible combinations:

  1. When the second parameter is GL_TEXTURE_MIN_FILTER, parameter three can be:
    6. GL_LINEAR
  2. When the second parameter is GL_TEXTURE_MAG_FILTER, parameter three can be:
    1. GL_LINEAR

I don’t want to stray off topic and explain each parameter combination, but don’t worry, I’ll write another post on that topic soon. For now, just know that most examples use GL_LINEAR_MIPMAP_NEAREST for min filter and GL_LINEAR for mag filter. This combination sets up typical bilinear filtering used in most games. Trilinear filtering is almost the same except GL_LINEAR_MIPMAP_LINEAR is used instead of GL_LINEAR_MIPMAP_NEAREST.

When you set both parameters to GL_NEAREST it tells OpenGL to not interpolate any of the texel color values. It takes the calculated (u, v) coordinates, finds the texel nearest to that point in the source bitmap, and uses that color. So essentially it is just like old software rendering engines before everybody started using bilinear filtering.

-Greg Dolley

*Get new posts automatically! Subscribe via RSS here . Want email updates instead? Click here.

Posted in 3D Graphics, OpenGL | 14 Comments »

How to Find Which OpenGL Version You’re Running

Posted by gregd1024 on December 16, 2007

Have you ever needed to check which OpenGL version you’re running? Ever need to see which OpenGL extensions are supported by your card and/or video driver? Well, look no further! This post has the answers along with how to get some very useful information about your video driver.

Start by downloading an application called GL View by Realtech VR. You can get it from the following link:

I’ve used this program forever on many different cards / configurations and it’s never failed. Not only will it give you information on what OpenGL version you’re running, it can also give you information on the generic software emulation driver.

When you run the program your screen may do some weird things (go blank, flash, etc.). Don’t worry, this is completely normal – it will stop after about 15 seconds. After this auto-detect cycle is complete, you’ll see a dialog similar to the one below:


The first tab shows you some system information and a list of all OpenGL versions. For each version it shows how many functions are supported by your card’s driver. Look for the highest version number with “100%” support that also has “100%” marked for all versions prior to it. Whichever version you found was greatest is the actual OpenGL version installed on your machine. It’s possible to have “gaps” in your OpenGL support where the driver doesn’t implement all the functions of one version but does implement everything in a higher version. For drivers written by ATI and Nvidia, this would be very unlikely. In fact, I don’t see any reason it would happen. However, for third-party drivers, it’s definitely possible. See one of my previous articles: Certain Notebook ATI Video Card Drivers Not Supporting OpenGL 2.0.

Next, there is the “Extensions” tab:


The “extensions” tab gives you a list of extensions supported by your driver along with capabilities and limitations of your video card. The prefixes of each extension tell you which company originally created it:

  1. ATI – ATI (now AMD)
  2. NV – Nvidia
  3. ARB – Architecture Review Board (the group that maintains the OpenGL specification)
  4. EXT – vendor neutral extensions approved by the ARB
  5. HP – Hewlett-Packard
  6. IBM – International Business Machines
  7. KTX – Kinetix (original maker of 3D Studio Max)
  8. INTEL – Intel
  9. MESA – Mesa OpenGL project
  10. SGI/SGIS – Silicon Graphics
  11. SIGX – experimental Silicon Graphics extensions
  12. SUN – Sun Microsystems
  13. WIN – Microsoft

The next three tabs are pretty self-explanatory. “Display Modes” lists all the different video modes your card supports. “Pixel formats” shows the available pixel formats you can choose when programming with OpenGL. “Report” allows you to print out some of the pertinent information you’ve seen in the other tabs.

You can use the Test tab to run actual OpenGL rendering tests and benchmarks. This is useful if you want to check performance of your card or you suspect a hardware malfunction. Note: for benchmarking, be sure to click the “benchmark” box near the bottom of the dialog:


The final tab worth mentioning is the Registry tab:


This tab lists experimental OpenGL extensions that are turned off by default. Use this tab to turn them back on. Beware, these extensions are turned off for a reason – use them at your own risk!

The last part you should check out is the “Renderer” menu option. This menu lists the OpenGL driver(s) installed on your machine. It should show two options, 1) “GDI Generic” and 2) the name of your video card and/or driver. If it only shows “GDI Generic” then something is wrong with your driver installation. “OpenGL Generic” is Microsoft’s generic software emulation driver. It’s only used when no real OpenGL driver is installed on a system.

-Greg Dolley

Posted in OpenGL | 9 Comments »

Certain Notebook ATI Video Card Drivers Not Supporting OpenGL 2.0 / How to Update Mobility Radeon Drivers

Posted by gregd1024 on November 17, 2007

Let me guess, you got here because you’re trying to find an updated driver for a notebook containing an ATI video card? Are you trying to find a driver that supports OpenGL 2.0? If you were like me — spent a chunk of change on a nice new laptop with an awesome video card, only to find that the driver only supported OpenGL 1.0 (or some version below 1.4) — then you were probably shocked to find that ATI, at the time of this writing, only released Mobility drivers up to the X1800 card. I have the ATI Mobility Radeon 2600 HD running on a Fujitsu N6460 and as you can imagine I was expecting full OpenGL 2.0 support when I bought it (after all, that’s what ATI advertises for this card), but nope, instead I was stuck with only OpenGL 1.0 fully supported and some functions of v1.1 supported. Needless to say, after the discovery of poor OpenGL support, I began searching ATI’s site for an updated driver — there was none. I searched forums, blogs, etc. for an updated driver written by ATI (third party drivers would have been my last resort), but still couldn’t find one. After searching what seemed to be the entire Internet, I found the solution. But first, let me give you a little background on why there are no updated ATI drivers out there.

The whole problem stems from a stupid policy OEM’s have toward ATI (Nvidia is not immune either — see the message on their website after you try selecting a “GeForce Go” model driver for downloading). In a nutshell, OEM’s pressure ATI not to provide support for their device in the Catalyst Mobility driver. This is really stupid. The concern of the OEM’s is that they themselves have their own support system in place and don’t want customers downloading reference drivers from ATI’s website. In my opinion, the type of computer users who know how drivers work and like to install their own are not the type of user that would call the OEM’s technical support line anyway. Terry Makedon, AMD manager for Software Product Management Graphics Product Group gave this statement to Driver Heaven ( in April of 2007:

AMD (formerly ATI) introduced the concept of Catalyst Mobility which is a generic driver that works decently for most laptops. The only way we are able to do this is through permission by a laptop manufacturer (OEM) to include their device in the Catalyst Mobility. We were the first company to provide graphics drivers for laptops to the general public, and we believe there is great value in this. At this point we only have permission from a few vendors and I personally wish more of them would let us. My suggestion is you contact your manufacturer and ask them to have your laptop included in Catalyst Mobility. As for Vista specifically we do not have permissions yet, but as soon as we do we look forward to releasing Vista drivers for laptops.

OK, enough history. So what’s the solution? Easy, you need to download the desktop version of the driver for the card that is in your laptop (so for a Mobility Radeon 2600 HD, you would use the Radeon 2600 HD Series), run a program called Mobility Modder which modifies the desktop driver install files so they work with a notebook, and then simply run the modified setup. This version of the setup runs like any other driver install. When done you’ll have all the desktop driver features running on your laptop! You can get Mobility Modder and detailed installation instructions here:

This program worked like a miracle for me! It saved me from returning my notebook (why would you buy a “gaming” laptop when almost all the games you play use OpenGL and now you can’t play them?). I really like Fujitsu notebooks in all respects, but the fact that they wrote what I believe to be an incomplete video driver and then have the audacity to release it as a “gaming” laptop is just beyond my comprehension. More than half the popular games out there use OpenGL, not Direct 3D! How can it be a gaming laptop if half the games won’t even run properly?! Most will run but will buckle down to using the software-rendered MCD driver for all OpenGL calls not supported by the ICD — an ICD (Installable Client Driver)  is the regular driver written for the video card (DOOM 3 looks very “interesting” running in almost 100% software mode). What were they thinking?! This is my third Fujitsu notebook and the two others I’ve owned supported the latest version of OpenGL that was available at the time of manufacturing. Why didn’t they do the same thing with the N6460 model?!?!?! Ugh!

OK, enough ranting. In case you’re wondering what my notebook specs are, here you go:

  • Intel Core 2 Duo Processor, T7100 @ 1.8GHz
  • 2GB RAM
  • Windows Vista 32-bit
  • ATI Mobility Radeon 2600 HD with 512MB HyperMemory (256MB dedicated, 256MB shared)

And here’s a screenshot of my Catalyst Control Center after updating the driver:


I don’t know why it displays the card as being an X2600 (it should be the regular 2600), but hey, everything works perfectly so I’m not worrying about it.

Anyway, I hope this article has saved you from pulling your hair out and I hope the solution works for you too.

-Greg Dolley

Posted in OpenGL | 11 Comments »