FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

OpenGL Performance

 
Post new topic   Reply to topic     Forum Index -> ArcLib
View previous topic :: View next topic  
Author Message
BorisTheBrave



Joined: 27 Jun 2009
Posts: 4

PostPosted: Sat Jun 27, 2009 6:48 pm    Post subject: OpenGL Performance Reply with quote

Hi, I'm just trying out arclib and D in general. So far experiences are excellent - arclib wraps openGL enough that it doesn't make me want to throw my computer against a wall.

But now I would like to draw a polygon with a texture, which seems to be beyond the current API. No problem, I investigated the Texture class:
Code:

//Once
auto tex = solid = Texture("solid.png");

//Per polygon
glBindTexture(GL_TEXTURE_2D, tex.getID);
glEnable(GL_TEXTURE_2D);
glColor4f(1.0,1.0,1.0,1.0);
glBegin(GL_TRIANGLE_FAN);
foreach(local; poly.vertices)
{
    auto world = bzMul(xform,local);
    glTexCoord2f(world.x/30,world.y/30);
    auto p = asPoint(world);
    glVertex2f(p.x,p.y);
}
glEnd();


(this is using Blaze btw, so polygons are convex).

I've stripped my program of everything except drawing 4 rectangles in this form, but I'm still seeing a huge framerate drop - from the (limiter) value of 40 to 25 or so, and then to 15 if I double up the rectangles. But when I use arc.draw.shape.drawPolygon, the cost is negligible.

Surely it's not that expensive to draw textures? Is Arclib messing with OpenGL in some way? Or am I just missing something? Or is my somewhat aged laptop just way underspecced?

I'm also getting a persistent stuttering, where a frame takes hundreds of ms instead of tens. Is that the GC?

Details:
D1. DMD/Vista 32bit.
Code:
>dsss installed
arc_core
derelictal
derelictft
derelictgl
derelictglu
derelictogg
derelictsdl
derelictsdlimage
derelictutil
derelictvorbis
dsss

Render Type: OpenGL (Hardware)
Vendor     : Microsoft Corporation
Renderer   : GDI Generic
Version    : 1.1.0
Extensions : GL_WIN_swap_hint GL_EXT_bgra GL_EXT_paletted_texture
Back to top
View user's profile Send private message
BorisTheBrave



Joined: 27 Jun 2009
Posts: 4

PostPosted: Sun Jun 28, 2009 3:45 am    Post subject: Reply with quote

Um, ok. Having hibernated my laptop and restored all problems seem to have vanished. Still, any explanation?
Back to top
View user's profile Send private message
aliloko



Joined: 31 Jan 2008
Posts: 15

PostPosted: Mon Jun 29, 2009 1:17 pm    Post subject: Reply with quote

Seems like your graphic card drivers were not installed.
You should have way more extensions and OpenGL 1.1 driver is the generic one accompanying Windows.
Back to top
View user's profile Send private message
BorisTheBrave



Joined: 27 Jun 2009
Posts: 4

PostPosted: Mon Jun 29, 2009 4:12 pm    Post subject: Reply with quote

Yes, I'm aware of that. I'm a lazy man. As rationalization for this, I think it's probably a smart move - I cannot accidentally stray into unsupported territory. The majority of windows users (presumably) also have OGL 1.1. I am not anticipating complicated use of OpenGL - I was really hoping to avoid straying outside Arclibs API.

Anyway, would this actually cause performance issues? I guess that's reason enough to upgrade.
Back to top
View user's profile Send private message
aliloko



Joined: 31 Jan 2008
Posts: 15

PostPosted: Mon Jun 29, 2009 5:33 pm    Post subject: Reply with quote

This does affect performance.

Plus, you could almost assume everybody has OpenGL 2.0+ now.
You'll get shaders and plenty of useful OpenGL extensions.
Back to top
View user's profile Send private message
aliloko



Joined: 31 Jan 2008
Posts: 15

PostPosted: Mon Jun 29, 2009 5:34 pm    Post subject: Reply with quote

EDIT : duplicate message
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Fri Nov 06, 2009 10:47 am    Post subject: Reply with quote

Hi,

I'm really not sure what the point is of trying to draw a polygon with a texture.

Can't you just drawImage(), and then overlap your polygon over the image?
Back to top
View user's profile Send private message AIM Address
BorisTheBrave



Joined: 27 Jun 2009
Posts: 4

PostPosted: Sun Nov 08, 2009 10:14 am    Post subject: Reply with quote

I don't know what you mean. I have a repeating texture, and various arbitrary polygons to draw with it. Like "texture fill".
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Mon Nov 09, 2009 12:57 pm    Post subject: Reply with quote

I've never (yet) have had the need for this feature, so here's what I can tell you.

1. Try to define your variables outside the for loop.

2. ArcLib isn't really messing with OpenGL, but it just makes OpenGL calls. If you are having performance problems with D, I'm really not too sure what's going on.

3. If you want to design a function "drawPolygonFill(Texture t, Point[] poly, etc.)" I can add it to the API, and perhaps if there are still problems they could be fixed at a later date.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> ArcLib All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group