473,325 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

[OpenGL] Depth sort particles stored as a linked list

Hi all, I need to depth-sort around 5000 alpha-blended particles stored inside a linked list (not the std one); blending is not additive, glAlphaFunc() is not a option obviously and depth buffer tricks help a bit but don't work in many situations.

I've spent hours looking on the web for informations about this topic but I couldn't find any clear explanation or tutorial about depth sorting techniques or what is the best technique to do this.

Any help will be really appreciated.

Thanks a lot,

Michele
Oct 31 '07 #1
6 3176
sicarie
4,677 Expert Mod 4TB
I'm going to go ahead and move this over to the C/C++ Forum (instead of the Articles section), where you're more likely to get a response.
Oct 31 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
I have never used a depth sort, but I found this.

I don't know if it's a help or not.

If not, post again with more info.
Oct 31 '07 #3
sicarie: Thanks for moving it, sorry I placed it in the wrong section by mistake.

weaknessforcats: That's what I'm looking for, basically all I need is to figure out "Step 1:Sort objects from near to far (smallest to largest z coordinate)."

What's the easier and most efficient in terms of complexity (linear time? logaritmic complexity?) way to sort a list of objects based on the square distance from the camera.

I've been suggested a couple of techniques at gamedev, like radix sort, quicksort, std::sort, etc.
Oct 31 '07 #4
RRick
463 Expert 256MB
Sorting ints or doubles from smallest to largest has been done a lot. Each of the specific sorts, have their average time (typically n*log(n)) but can degrade depending on the order of the elements. 5000 is not a lot, so I would't worry too much about the specific types of sorts.

Your problem is that the container is a linked list. Many of the sort algorithms depend on random access within the container. You don't have that with a linked list. The STL does supply a linked list sorter but will probably not work with your linked list. You might find it easiest to create an array of z-depth values and pointers to data. Most sorts can handle that type of container.
Nov 1 '07 #5
Yep sounds like a good idea. Thanks a lot!
Nov 1 '07 #6
weaknessforcats
9,208 Expert Mod 8TB
You might find it easiest to create an array of z-depth values and pointers to data. Most sorts can handle that type of container.
That could be done using a vector since vector is an array. The sort would be the std::sort().
Nov 1 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: alex_peri | last post by:
Hello, I am looking for a good way to permanently sort a table in Access. The way i have below works but i was wondering if there is a better and faster way. Kind regards, Alex ...
10
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy...
1
by: Booser | last post by:
// Merge sort using circular linked list // By Jason Hall <booser108@yahoo.com> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> //#define debug
3
by: chellappa | last post by:
hi this simple sorting , but it not running...please correect error for sorting using pointer or linked list sorting , i did value sorting in linkedlist please correct error #include<stdio.h>...
1
by: Scott Chang | last post by:
Hi All I tried to use the attached OpenGL code to draw a Star-shaped figure on my Microsoft Visual C++ .NET 2002-Windows XP Pro PC. When I did 'Build' in Debug Mode, I got an error C2065:...
11
by: Leon | last post by:
I have six textbox controls on my webform that allows the user to enter any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them...
6
by: Julia | last post by:
I am trying to sort a linked list using insertion sort. I have seen a lot of ways to get around this problem but no time-efficient and space-efficient solution. This is what I have so far: ...
0
iknc4miles
by: iknc4miles | last post by:
Hi all, I'm writing a Windows Form .NET Application in C++ and would like to open a second window for OpenGL Display. My code compiles fine and runs with no problems except that the 2nd window...
2
by: nvinhphu | last post by:
Hello everyone, I am writing a simulation program in C++. The data includes a set of spheres packing in a 3D box. So, I have the coordinates and the radius of the spheres. My question is how...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.