# SDL\_GL Performance problem

**URL:** <https://discourse.libsdl.org/t/sdl-gl-performance-problem/9157>\
**Category:** SDL Development\
**Created:** [August 13, 2003, 4:09pm UTC](https://discourse.libsdl.org/t/sdl-gl-performance-problem/9157 "2003-08-13T16:09:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olof\_Bjarnason](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/olof_bjarnason/32/256_2.png) [@Olof\_Bjarnason](https://discourse.libsdl.org/u/Olof_Bjarnason)\
**Post date:** [August 13, 2003, 4:09pm UTC](https://discourse.libsdl.org/t/sdl-gl-performance-problem/9157/1 "2003-08-13T16:09:02Z")

</div>

Hi there.

I am currently developing a Slicks’n’slide inspired  
bird-view car racing game called CrunchRace. It  
uses SDL\_GL-functionality to render all graphics  
and SDL\_mixer for sound effects.

I am targeting Windows (specifically WinXP right now  
since that’s the only platfrom that I am able to  
test it on). Here is the URL:

[http://www.mdstud.chalmers.se/~objarni/crunchrace/index.html](http://www.mdstud.chalmers.se/~objarni/crunchrace/index.html)

It is in video mode 320x240, 32 bit, to get the right  
retro feeling. 🙂

I am experiencing quite a dramatic slowdown when the  
cars simultaneously “make trails” ie. slides over  
eg. ice. I gather this comes from the gl command  
glTexSubImage2D which I use to update the background  
texture.

The rendering is done like this:

clear background using glClear  
draw background texture glBindTexture, glBegin …  
draw car textures same

… and whenever a car makes a trail I use  
glTexSubImage2D to update the background texture using  
only a 1x1 subimage – code which is placed in the car’s  
game logic procedure.

I have read at several occasions on this mailing list  
that _reading_ AGP memory is prohibitively slow, but  
I am not reading but writing to gfx-mem, am I? And  
quite a little also: 1x1 pixels in 32 bit format  
should be 4 bytes, correct? Even when four cars slide  
with every tire, it would be 4_4_4 = 64 bytes, a  
raindrop in hell so to speak, even if there is some  
overhead in this texture update procedure, which brings  
it up to a [small] multiple of 64 bytes to send from  
system memory to graphics memory.

Is there something I am missing here? I have queried  
SDL for hardware acceleration information, which gives  
me the following output, so it does not seem to be  
a [driver-related] configuration problem: (me textures  
are stored in RGB (24bit) format in AGP, and the video  
mode is 32 bit as mentioned above, a no-cost difference  
I hope)

Hardware acceleration information \*\*\*  
Available video memory: 30448  
Hardware surfaces createable: Yes  
Hardware-\>hardware blit: Yes  
Hardware-\>hardware colorkey blit: Yes  
Hardware-\>hardware alpha blit: No  
Software-\>hardware blit: Yes  
Software-\>hardware colorkey blit: Yes  
Software-\>hardware alpha blit: No  
Solid rectangle draw: Yes

Also, asking gl if my textures are resident (ie.  
placed on AGP chip mem, not system memory in gl lingua)  
prints:

Blue car resident: yes  
Green car resident: yes  
Pink car resident: yes  
Background resident: yes

Thankful for any help,

/Olof

---

<div class="post-metadata">

**Author:** ![Matthias\_Bach](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/matthias_bach/32/197_2.png) [@Matthias\_Bach](https://discourse.libsdl.org/u/Matthias_Bach)\
**Post date:** [August 13, 2003, 11:33pm UTC](https://discourse.libsdl.org/t/sdl-gl-performance-problem/9157/2 "2003-08-13T23:33:01Z")

</div>

Hi!

Am Donnerstag, 14 August 2003 schrieben Sie:

> I am experiencing quite a dramatic slowdown when the  
> cars simultaneously “make trails” ie. slides over  
> eg. ice. I gather this comes from the gl command  
> glTexSubImage2D which I use to update the background  
> texture.

Hi,  
actually i couldn’t see the slowdown because in the version you have  
for download there is only one car racing. And I did not find a way  
to get any other cars started.

BTW, there seems to be a bug in your input handling code. For the  
accelleration key you only seem to be tracking keydown events instead  
of keydown for “accelerate” and keyup for “stop accelerion”.

Matthias

---

<div class="post-metadata">

**Author:** ![Olof\_Bjarnason](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/olof_bjarnason/32/256_2.png) [@Olof\_Bjarnason](https://discourse.libsdl.org/u/Olof_Bjarnason)\
**Post date:** [August 14, 2003, 3:00am UTC](https://discourse.libsdl.org/t/sdl-gl-performance-problem/9157/3 "2003-08-14T03:00:01Z")

</div>

My mistake, should’ve described the controls in case you would try to  
see the slowdown!

To begin with, the controls are somewhat obscure or at least  
inconsequent right now, due to my fanatic strive to minimize keyboard  
usage (hate keyboards when it comes to many-players-on-one-computer!  
Why don’t we all have two game pads hooked to our PCs?)

You turn on/off the gas by pushing arrow up.  
If you have no gas, arrow down means reverse.  
If you have gas, arrow down means handbrake.  
Left/right at last is used the way you would  
normally think they were used 🙂

The same goes for the other two cars:

1: gas on/off  
2: reverse/handbrake  
a/d: left/right

g: gas on/off  
h: reverse/handbrake  
j/l: left/right

Btw. I am on a AMD700 with a GeForce2, if you have much newer I guess  
you would find it hard to mimic the behaviour I describe. And if you  
have a joystick, one of the car will (hopefully) be controlled by it,  
skipping one of the above keyboard controls.

/Olof

### Matthias Bach: “Re: [SDL] SDL\_GL Performance problem” (2003-08-14 08:28)

#Hi!#  
#Am Donnerstag, 14 August 2003 schrieben Sie:

# 

#\> I am experiencing quite a dramatic slowdown when the  
#\> cars simultaneously “make trails” ie. slides over  
#\> eg. ice. I gather this comes from the gl command  
#\> glTexSubImage2D which I use to update the background  
#\> texture.

# 

#Hi,  
#actually i couldn’t see the slowdown because in the version you have  
#for download there is only one car racing. And I did not find a way  
#to get any other cars started.

# 

#BTW, there seems to be a bug in your input handling code. For the  
#accelleration key you only seem to be tracking keydown events instead  
#of keydown for “accelerate” and keyup for “stop accelerion”.

# 

#Matthias

# 

# 

# 

# 

# 

# 

# 

#\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
#SDL mailing list  
#SDL at [libsdl.org](http://libsdl.org)  
#[http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)

#
