Running out of VRAM on OS X

OpenGL on OS X virtualizes texture memory. This means you can allocate an almost unlimited amount of textures, and the OS will keep them in system memory, and only copy them up to the graphics card when they're needed. This is a lot better than the old model of keeping all textures only in VRAM, and texture creation failing once you run out of memory there. But there's still cases where you have to worry about how much VRAM is available.

Continue reading "Running out of VRAM on OS X"

| Comments (1)

Debugging OpenGL on OS X

It's tough to debug OpenGL problems, especially with pixel shaders. I'll cover some tips for any platform, and then some of the OS X built-in tools that can help.

Continue reading "Debugging OpenGL on OS X"

| Comments (2)

Fragment Program Utilities

Here's a couple of functions to check that a fragment program can be run, and to load it and return the ID. The code is inline below, or you can download it.

Continue reading "Fragment Program Utilities"

| Comments (2)

Fragment Program Reference

The OpenGL Extensions Guide has a great chapter on the ARB fragment program language, I recommend buying it, but there aren't many good references online. The most useful is the official spec, but it's designed as an exhaustive guide, not a quick reference for programmers. Here's a rundown of the instruction set, and some tips and tricks.

Continue reading "Fragment Program Reference"

| Comments (0)

Mac PBuffers

If you ever need to do more image processing than you can with a single fragment program pass, you'll need to render to a texture. The best way to do that on OS X is using a pbuffer, here's some example code for creating and using them.

I've included the code inline below, or you can get a zip of the code from PBufferUtils.zip here

Continue reading "Mac PBuffers"

| Comments (0)

Emulating Bilinear Filtering

Most graphics cards that support float textures can't bilinear filter them. We can use a fragment program to do the filtering for us, but it's tricky to get right. Here's an example of how to do it:

Continue reading "Emulating Bilinear Filtering"

| Comments (0)

GPU Optical Flow

Optical flow analysis is heavily used by video and film processing apps, to retime images smoothly, apply motion blur as a post-process, and guide the application of other processes. It's traditionally a slow operation, I wanted to see if a GPU version was possible.

Continue reading "GPU Optical Flow"

| Comments (0)

Random Numbers in Fragment Programs

It's hard to write a fragment program that will calculate pseudo-random numbers. The usual random number algorithms need two things that we don't have on our GPU's:

Continue reading "Random Numbers in Fragment Programs"

| Comments (1)

Quick and Dirty Vectorization

There aren't many fast techniques for vectorizing an image into polygons that approximate the original, or that take advantage of 3d hardware, so here's one I've used.

Continue reading "Quick and Dirty Vectorization"

| Comments (0)

Fragment Program Snippets

Here's some instruction sequences for common operations:

Continue reading "Fragment Program Snippets"

| Comments (0)

Fragment Programs-ATI R3xx vs NVidia NV34

ATI and NVidia cards have some differences it's important to know about when you're writing fragment programs to run on both.

Continue reading "Fragment Programs-ATI R3xx vs NVidia NV34"

| Comments (0)

Mac OpenGL contexts

A context is a container for the GL state information, things like the current color, transformation matrix, texture ID and anything else that needs to be remembered by OpenGL.

Continue reading "Mac OpenGL contexts"

| Comments (0)

Straight Alpha and Bilinear Filtering

There's a subtle problem using graphics hardware to do bilinear filtering on straight alpha images.

Continue reading "Straight Alpha and Bilinear Filtering"

| Comments (0)

Animating Worley Noise

Texturing and Modelling has a chapter by Steve Worley on using Voronoi diagrams to create a procedural noise pattern. I needed to find a way to animate and render this on a 2D plane using OpenGL.

Continue reading "Animating Worley Noise"

| Comments (0)