LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-16-2009, 08:20 AM   #1
POW R TOC H
Member
 
Registered: Mar 2008
Location: Serbia
Distribution: Fedora
Posts: 37

Rep: Reputation: 15
A question about glDrawArrays (OpenGL newbie)


I'm writing a 2d particle engine using OpenGL, and I use points, lines and point sprites to represent particles. I'm using glBegin()-glEnd() way of drawing. I'd like to use glDrawArrays(), but I have a problem with that : every particle has it's own size, but glDrawArrays() doesn't allow me to draw primitives/point sprites of different sizes, as far as I know. Is there any way I can do this?

Thanks in advance
 
Old 01-16-2009, 10:11 AM   #2
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
It looks like there is no standard way to set point size in array for glDrawArrays.
Also I don't think this would give serious performance boost since particle data changes frequently (every frame).

I think you should be able to do same thing by writing simple shader (GLSL (OpenGL 2.0), or any other). In this case, though, you'll have to use triangles to build sprites and textures to make points look round. Shader will deform triangles according to point size and texture coordinates of vertex. In this case you will be able to feed per-vertex data using glVertexAttribPointer (OpenGL 2.0) or any similar function available through extensions.

If that is too much for you, then just stick to glBegin-glEnd method, until particle system will produce serious slowdown.
 
Old 01-16-2009, 10:59 AM   #3
POW R TOC H
Member
 
Registered: Mar 2008
Location: Serbia
Distribution: Fedora
Posts: 37

Original Poster
Rep: Reputation: 15
Somehow it seems to me that I the small boost I will get from using the array method will be lost if I use shaders and triangles. Well, I'll stick to this for now. It's going to be an open source project (when I make it useable and embed Lua), so someone will hopefully improve on my code.

Last edited by POW R TOC H; 01-16-2009 at 12:21 PM.
 
Old 01-16-2009, 02:57 PM   #4
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by POW R TOC H View Post
Somehow it seems to me that I the small boost I will get from using the array method will be lost if I use shaders and triangles.
Well, it won't be lost (you'll need just vertex shader, not pixel), but this system will need a lot of redundant data to work.
I implemented such thing on DirecX many years ago when I've run into troubles with pointsprites (maximum size limit, no rotation, etc) in 3D particle system.
Implementing what I've described makes sense only if you need large quantites (over 1000) of really large (possibly larger than screen), rotating, perspective-corrected textured sprites acting as particles. If you are using points and they are sufficient for your task, then writing this will be (probably) a waste of time.
 
  


Reply

Tags
opengl, point, size, sprites



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie to opengl/glut true_atlantis Programming 3 08-28-2005 08:39 PM
OpenGL terminology question shilo Slackware 6 03-02-2005 08:00 PM
OpenGL Question fatherg Programming 1 08-04-2004 02:17 PM
opengl question phil123 General 0 02-26-2004 01:08 AM
OpenGL Programming Question EviLBoX Programming 2 10-18-2002 11:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration