Applying texture

Hi guys,

I just want to texture an object that is created by reading vertices from a data file. I read the file for vertices load the vertices to my glDraw function but when I try to apply a texture to my generated object , I don’t quite get what I want as an output.
The output is my object with my texture on it but in “slices”. It’s as if my object is generated from a lot of cones where the sum of each cone’s circumference represents the outer surface of my object. So my texture is applied to each cone and not to the whole object, uniformally.
I have tried using automatic texture generation as well but the output remains the same.

Right now I’m guessing that the vertices that i put into the glVertex function should be manipulated somehow (glVertex(sin(x),cos(y),sin(z)).

Another (general this time) question, how can I upload to the forum a picture from file (not from a URL) so that you all can see what I’m talking about.

Maybe I can do what I want with bezier curves?

Any ideas guys?
Here is the latest source:

 public override void glDraw()
			GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);// Clear The Screen And The Depth Buffer
			GL.glLoadIdentity();										// Reset The View
			GL.glBindTexture(GL.GL_TEXTURE_2D, textures[0]);
			GL.glTranslatef(cx, cy, cz);								// Translate The The Current Position To Start Drawing
			GL.glRotatef(xrot, 1, 0, 0);								// Rotate On The X Axis By xrot
			GL.glRotatef(yrot, 0, 1, 0);								// Rotate On The Y Axis By yrot
			GL.glRotatef(zrot, 0, 0, 1);								// Rotate On The Z Axis By zrot

			xrot += xspeed;
			yrot += yspeed;
			zrot += zspeed;									// Increase xrot, yrot & zrot by xspeed, yspeed & zspeed
			float tx, ty, tz;								// Temp X, Y & Z Variables
			Vertex q;										// Holds Returned Calculated Values For One Vertex

			float[] t=new float[2];
			float[] xyz=new float[3];
			for (int i=0; i < morph1.verts; i++)		
				if (morph)
					q = calculate(i);
				q.x = q.y = q.z = 0;					// If morph Is True Calculate Movement Otherwise Movement=0
				helper.points[i].x -= q.x;					// Subtract q.x Units From helper.points[i].x (Move On X Axis)
				helper.points[i].y -= q.y;					// Subtract q.y Units From helper.points[i].y (Move On Y Axis)
				helper.points[i].z -= q.z;					// Subtract q.z Units From helper.points[i].z (Move On Z Axis)
				tx = helper.points[i].x;					// Make Temp X Variable Equal To Helper's X Variable
				ty = helper.points[i].y;					// Make Temp Y Variable Equal To Helper's Y Variable
				tz = helper.points[i].z;					// Make Temp Z Variable Equal To Helper's Z Variable	


			uint error = GL.glGetError();
			if(error != GL.GL_NO_ERROR) 
			else {Console.WriteLine("No error occured");}

why dont you use quads or triangles to draw it? also try dividing the texture coords

If I want to use triangles or quads, I think that I have to define the order that I want them to be appeared on screen, right?

What do you mean by dividing the texCoords?

divide it between the amount of slices

Hm, that did not seem to work.

How can I apply one picture as a texture? Now I keep getting an object consiting of small pieces of that picture. I want to have one picture stretched through my object, not a lot of instances of that picture tiled to the object.

Also how can I make my object have detail? When I apply texture to my object i cannot recognise which side of the object I am looking at.

any ideas?


for example if the polygon you want to texture is composed of 4 squares, you divide the texcoords between 4 say: glTexCoord2f(x/4,y/4);
read nehes lesson 11 to see what im talking about.
and to your other question you might want to write something on the texture to help you identify which side is up :stuck_out_tongue: or when using glvertex and texcoords go clockwise