OpenGL Texture Mapping [Equirectangular 2 Azimuthal Equidist

General discussion of map projections.
felixrulz
Posts: 7
Joined: Wed Jul 18, 2012 4:58 pm

Re: OpenGL Texture Mapping [Equirectangular 2 Azimuthal Equi

Post by felixrulz »

daan wrote:I would be interested to know what resolves your trouble.
The problem was/is a little embarrassing... it was basically me putting code in the wrong spot. I found it on the train this morning:

Code: Select all

for (i=0; i<4; i++)	{ [B]// FOR THE FOUR VERTICES OF QUAD.[/B]

		[B]// disk coordinates[/B]
		p_d[n].x = b2[i] * cos(a2[i]) + x0;
		p_d[n].y = b2[i] * sin(a2[i]) + y0;

		[B]// calcuate texture coordinates[/B]
		AziCalc (lat_p, long_p, b2[i], a2[i], p_d[n].x, R);
		p_d[n].u = 0.5 - longitude/PI2;
		p_d[n].v = latitude/PI;
				
		[B]// I HAD THE TEXTURE WRAPPING CODE HERE![/B]

		n++;
		}

		[B]// THE CODE WHOULD HAVE BEEN HERE![/B]
		// Wrap bad texture coordinates
		getmax2(n-4, n-1, &max, &index); 		//get max value for last quad
		getmin2(n-4, n-1, &min, &index); 		//get min value for last quad
		while (max - min > 0.5){ 				// if texture coordinates too far apart
			p_d[index].u += 1; 				//wrap coordinates
			getmax2(n-4, n-1, &min, &index); 	//get max value for last quad
			getmin2(n-4, n-1, &min, &index); 	//get min value for last quad
		}
}
The program now works well. Here is the fixed version: http://dl.dropbox.com/u/49415695/Deskto ... king%5D.7z
(I compiled this version as 'Release' as this should hopfully get rid of some dll dependencies - not sure though)
Controls:
Arrow Keys: Adjust the centre of projection
'T': toggles the texture
'F': changes filters
I wanted to thank you dann for the help you have given me. Hopfully you like the program!
Post Reply