Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Problem with textures in 2D game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Elastoman   Members   -  Reputation: 107

Like
0Likes
Like

Posted 28 July 2012 - 05:48 PM

I'm writing a 2D game, which involves drawing a lot of sprites. They are stored in one big image, which I load to texture.

I used GL_TEXTURE_RECTANGLE_NV, as described here http://www.gamedev.net/page/resources/_/technical/opengl/rendering-efficient-2d-sprites-in-opengl-using-r2429

It worked great on my desktop (although I have ATI videocard), but when I tried it on my laptop - nothing was painted.

So I tried GL_TEXTURE_2D and got the picture, but it's rendered too slow.

Can somebody give a hint how to make it work properly? All I need is drawing small rectangular pictures, but quite a lot of them.

Sponsor:

#2 JTippetts   Moderators   -  Reputation: 8579

Like
0Likes
Like

Posted 29 July 2012 - 09:19 AM

You can use glGetString(GL_EXTENSIONS) to return a string listing all of the extensions supported by the video driver. If the string "GL_NV_texture_rectangle" isn't in the list anywhere, then you can't use GL_TEXTURE_RECTANGLE_NV. Note that this, of course, is only relevant for deprecated GL (pre 3.0) which, judging by the code at the link you are trying to use, I assume is the case.

Also, if rendering using GL_TEXTURE_2D is slow, then you might want to call glGetString(GL_VENDOR). If the vendor string returned is for Microsoft, then your drivers are the software-only drivers installed by default with Windows, and you'll need to install updated drivers from your card manufacturer. This is often the culprit when performance of even simple tasks seems unreasonably slow. This would also possibly result in your desired extension not being supported, since the default Microsoft GL implementation doesn't support many extensions.

#3 Elastoman   Members   -  Reputation: 107

Like
0Likes
Like

Posted 29 July 2012 - 04:55 PM

It appeared to be an issue with laptop drivers described here: http://gregs-blog.com/2007/11/17/certain-notebook-ati-video-card-drivers-not-supporting-opengl-20-how-to-update-mobility-radeon-drivers/

I was able to upgrade OpenGL version from 1.1 to 3.3, and now both methods work well.

But I'm interested which is better to use so my game is supported by as many machines as possible. It's just a simple 2D game after all.

#4 mattdesl   Members   -  Reputation: 176

Like
0Likes
Like

Posted 30 July 2012 - 11:05 AM

Generally you will want to use GL_TEXTURE_2D and two triangles (or a quad).

GL_TEXTURE_RECTANGLE was originally used for a means of achieving non-power-of-two textures; now most modern hardware supports NPOT textures with GL_TEXTURE_2D.

#5 Geometrian   Crossbones+   -  Reputation: 1579

Like
0Likes
Like

Posted 30 July 2012 - 10:03 PM

GL_TEXTURE_RECTANGLE was originally used for a means of achieving non-power-of-two textures; now most modern hardware supports NPOT textures with GL_TEXTURE_2D.

. . . and most hardware that doesn't, isn't worth your time to write demanding applications for, anyway.

Also remember to be careful of certain state changes, particularly binding. If you're binding a separate texture for each sprite, for instance, you can get substantial slowdowns anywhere, no matter what kind of texture or sampler you're using.
And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS