Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# OpenGL graphics
I am looking to apply Texture to an already compiled OpenGL List.
Is it possible to apply texture to a GL List? Please let me know how to do it.
My OpenGL list contains TRIANGLE STRIPS (defined with gl.Normal3d & gl.Vertex3d)

Typically my code would be generating a GL List as below. To this List I want to apply some texture.
 
gl.NewList(GLListTag, gl.COMPILE);
 {
   gl.Begin(gl.TRIANGLE_STRIP);
   for (int i = 0; i< PointsCount; i++)
  {
 
   gl.Normal3d(x,y,z)
   gl.Vertex3d(a,b,c)
   }
   gl.End();
}
gl.EndList();
 
Note: I have already asked the same question in the Graphics discussion forum
Posted 21-Sep-12 1:32am
Edited 21-Sep-12 1:34am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to set the texture coordinates (using gl.TexCoords if I remember right) at the same time as you set the vertex normal and location.
  Permalink  
Comments
Anand Vadivel at 24-Sep-12 0:08am
   
I cannot do that as I have to re-use the compiled list with different Colours & Textures.
 
I am able to apply Color to a Compiled GL List and render but not able to do the same way for Texture mapping.
BobJanova at 24-Sep-12 4:52am
   
I don't think that is possible, as the texture coordinates are attached to a vertex just like its spatial coordinates.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

gl.NewList(GLListTag, gl.COMPILE);
 {
   gl.Begin(gl.TRIANGLE_STRIP);
   for (int i = 0; i< PointsCount; i++)
  {
   gl.TexCoord2f(u, v); // Texture coordinate of the vertex.
   gl.Normal3d(x,y,z)
   gl.Vertex3d(a,b,c)
   }
   gl.End();
}
gl.EndList();
 
http://nehe.gamedev.net/tutorial/display_lists/15003/[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 851
1 OriginalGriff 390
2 CPallini 265
3 George Jonsson 191
4 Kishore Pogaru 160
0 OriginalGriff 5,450
1 Sergey Alexandrovich Kryukov 4,532
2 CPallini 4,500
3 George Jonsson 3,102
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100