Skip to content

Instantly share code, notes, and snippets.

@mariusz
Created January 21, 2009 11:21
Show Gist options
  • Select an option

  • Save mariusz/49941 to your computer and use it in GitHub Desktop.

Select an option

Save mariusz/49941 to your computer and use it in GitHub Desktop.
private void CreateModel()
{
if (mesh != null)
{
NormalizeMesh();
this.model = GL.glGenLists(1);
GL.glNewList(this.model, GL.GL_COMPILE_AND_EXECUTE);
for (int i = 0; i < mesh.Length - 1; i++)
{
for (int j = 0; j < mesh[i].Length - 1; j++)
{
float r, g, b;
GL.glShadeModel(GL.GL_SMOOTH);
GL.glBegin(GL.GL_POLYGON);
getColor(mesh[i][j][2], out r, out g, out b);
GL.glColor3f(r, g, b);
GL.glVertex3d(mesh[i][j][0], mesh[i][j][1], 1.0);
getColor(mesh[i][j + 1][2], out r, out g, out b);
GL.glColor3f(r, g, b);
GL.glVertex3d(mesh[i][j + 1][0], mesh[i][j + 1][1], 1.0);
getColor(mesh[i + 1][j][2], out r, out g, out b);
GL.glColor3f(r, g, b);
GL.glVertex3d(mesh[i + 1][j][0], mesh[i + 1][j][1], 1.0);
GL.glEnd();
GL.glBegin(GL.GL_POLYGON);
getColor(mesh[i + 1][j][2], out r, out g, out b);
GL.glColor3f(r, g, b);
GL.glVertex3d(mesh[i + 1][j][0], mesh[i + 1][j][1], 1.0);
getColor(mesh[i + 1][j + 1][2], out r, out g, out b);
GL.glColor3f(r, g, b);
GL.glVertex3d(mesh[i + 1][j + 1][0], mesh[i + 1][j + 1][1], 1.0);
getColor(mesh[i][j + 1][2], out r, out g, out b);
GL.glColor3f(r, g, b);
GL.glVertex3d(mesh[i][j + 1][0], mesh[i][j + 1][1], 1.0);
GL.glEnd();
}
}
for (int i = 0; i < 100; i++)
{
float r, g, b;
GL.glShadeModel(GL.GL_SMOOTH);
GL.glBegin(GL.GL_POLYGON);
getColor(i * 0.01, out r, out g, out b);
GL.glColor3f(r, g, b);
GL.glVertex3d(1.3, i * 0.01, 1.0);
GL.glVertex3d(1.3 + 0.1, i * 0.01, 1.0);
getColor((i+1) * 0.01, out r, out g, out b);
GL.glColor3f(r, g, b);
GL.glVertex3d(1.3 + 0.1, (i + 1) * 0.01, 1.0);
GL.glVertex3d(1.3, (i + 1) * 0.01, 1.0);
GL.glEnd();
}
GL.glEndList();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment