How to draw 3D rotating Cylinder

The problem is that glBlend allows backside polygons to be seen so to stop the problem of seeing a ghost image of the back surface thru the cylinder backface culling had to be enabled – causing you to see half the cylinder. One way around that is to generate the mixed texture on a flat rectangle FIRST then copy that texture to be mapped on the cylinder later.

Step 1 generate mixed texture logoM (see new function CreateMultiTexture())

Step 2 use logoM without blending mapped onto the cylinder


// on linux with gcc: gcc main.c  -lGL -lglut -lIL -lGLEW
// on win+mingw: gcc main8.c -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32  -lglew32 -lIL -L/usr/local/lib -I/usr/local/include
// 
#include <GL/glew.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>

#include <IL/il.h>

GLfloat gAngle = 0.0;
GLUquadricObj *IDquadric;

GLuint gState = 0;

struct TextureHandle
{
  ILubyte *p;
  ILuint id;
  ILint w;
  ILint h;
  ILenum DestFormat;
  ILenum DestType;
  GLuint genID;
};

struct TextureHandle logo;
struct TextureHandle logo2;
struct TextureHandle logoM;

ILuint LoadImageDevIL (const char *szFileName, struct TextureHandle *T)
{
  ilEnable(IL_ORIGIN_SET);

  ilOriginFunc(IL_ORIGIN_LOWER_LEFT);

  ILuint ImageNameID;
  ilGenImages(1, &ImageNameID);
  ilBindImage(ImageNameID);
  if (!ilLoadImage(szFileName)) return 0;
  ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);

  T->id = ImageNameID;
  T->p = ilGetData();
  T->w = ilGetInteger(IL_IMAGE_WIDTH);
  T->h = ilGetInteger(IL_IMAGE_HEIGHT);

  T->DestFormat = ilGetInteger(IL_IMAGE_FORMAT);
  T->DestType = ilGetInteger(IL_IMAGE_TYPE);

  glGenTextures(1, &T->genID);
  glBindTexture(GL_TEXTURE_2D, T->genID);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexImage2D (GL_TEXTURE_2D, 0, T->DestFormat, T->w, T->h, 0, T->DestFormat, T->DestType, T->p);

  printf("%s %d %d %d
",szFileName,T->id,T->w,T->h);
  return 1;
}


void timer(int value)
{
  const int desiredFPS=120;
  glutTimerFunc(1000/desiredFPS, timer, ++value);
  GLfloat dt = 1./desiredFPS;

  gAngle += dt*360./8.;

  glutPostRedisplay();
}


void draw_cylinder() 
{
  glPushMatrix();
    glTranslatef(-5.,0,-100);
    glRotatef(gAngle,1.,1.,0.);
    gluCylinder(IDquadric,10.0f,10.0f,10.0f,32,32);
  glPopMatrix();
}

void display()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glMatrixMode(GL_MODELVIEW);

  if (gState) {
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR);
    //glBlendFunc (GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
    glBlendColor(.5,.5,.5,.5); // set blend constants to 0.5

    glBindTexture ( GL_TEXTURE_2D, logo.genID);
    draw_cylinder();

    glBindTexture ( GL_TEXTURE_2D, logo2.genID);
    draw_cylinder();

    glDisable(GL_BLEND);
  } else {
    glBindTexture ( GL_TEXTURE_2D, logoM.genID);
    draw_cylinder();
  }

  glutSwapBuffers();
}

void CreateMultiTexture()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  // store values to return to when done
  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();

  GLint viewport[4];
  glGetIntegerv(GL_VIEWPORT, viewport);

  // Temporarily set Viewport to Match Texture Size
  glViewport(0,0,logoM.w,logoM.h);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR);
    //glBlendFunc (GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
    glBlendColor(.5,.5,.5,.5);

    glBindTexture ( GL_TEXTURE_2D, logo.genID);
    glBegin(GL_QUADS);
     glTexCoord2f(0,0); glVertex2f(-1,-1);  
     glTexCoord2f(1,0); glVertex2f( 1,-1);  
     glTexCoord2f(1,1); glVertex2f( 1, 1);  
     glTexCoord2f(0,1); glVertex2f(-1, 1);  
    glEnd();

    glBindTexture ( GL_TEXTURE_2D, logo2.genID);
    glBegin(GL_QUADS);
     glTexCoord2f(0,0); glVertex2f(-1,-1);  
     glTexCoord2f(1,0); glVertex2f( 1,-1);  
     glTexCoord2f(1,1); glVertex2f( 1, 1);  
     glTexCoord2f(0,1); glVertex2f(-1, 1);  
    glEnd();

    glDisable(GL_BLEND);

  glBindTexture(GL_TEXTURE_2D,logoM.genID);  // Bind To The Mixed Texture

  // Copy mixed texture to logoM 
  glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, logoM.w, logoM.h, 0);
  // Finally, logoM is now 0.5*logo + 0.5*logo2

  //return to state before generating mixed texture
  glViewport(viewport[0], viewport[1], viewport[2] ,viewport[3]);
  glMatrixMode(GL_MODELVIEW);
  glPopMatrix();
  glMatrixMode(GL_PROJECTION);
  glPopMatrix();

  glutSwapBuffers();

  glutDisplayFunc(display); // now that you have mixed texture, do real display
}


void cleanupQuadric(void)
{
  gluDeleteQuadric(IDquadric);
  printf( "cleanupQuadric completed
" );
}


void init()
{
  glClearColor(0.0, 0.0, 0.0, 0.0);

  //glEnable(GL_CULL_FACE);
  glEnable(GL_DEPTH_TEST);
  glDepthFunc(GL_LEQUAL);

  IDquadric=gluNewQuadric();
  gluQuadricNormals(IDquadric, GLU_SMOOTH);
  gluQuadricTexture(IDquadric, GL_TRUE);
  atexit(cleanupQuadric);

  GLdouble Vol = 10*1.8;
  GLdouble Left=-Vol;
  GLdouble Right=Vol;
  GLdouble Bottom=-Vol;
  GLdouble Top=Vol;
  GLdouble Near=0;
  GLdouble Far=2*Vol;

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(Left, Right, Bottom, Top, Near, Far);

  GLdouble eyeX=0;
  GLdouble eyeY=0;
  GLdouble eyeZ=-100+Vol;
  GLdouble centerX=0;
  GLdouble centerY=0;
  GLdouble centerZ=-100;
  GLdouble upX=0;
  GLdouble upY=1;
  GLdouble upZ=0;

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt(eyeX,eyeY,eyeZ,
    centerX,centerY,centerZ,
    upX,upY,upZ);

  ilInit();
  //LoadImageDevIL ("/localhome/user/Temp/sample/bird.bmp", &logo);
  LoadImageDevIL ("logo.jpg", &logo);
  LoadImageDevIL ("logo.jpg", &logoM); // make room for Multi-texture
  LoadImageDevIL ("logo2.jpg", &logo2);

  glEnable (GL_TEXTURE_2D);
}


void keyboard(unsigned char key, int x, int y)
{
  switch (key)
  {
    case 27:
      exit(0);
      break;
    default:
      gState++;
      gState %= 2;
      printf("%d
",gState);
      break;
  }
}


int main(int argc, char** argv)
{
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
  glutCreateWindow("Multipass texturing Demo");
  glewInit();

  glutTimerFunc(0,timer,0);
  glutDisplayFunc(CreateMultiTexture);
  glutKeyboardFunc(keyboard);

  init();

  glutMainLoop();
  return 0;
}

Hi,

Thank you so much, This is one of the good idea for creating Multiple-texture using CreateMultiTexture() function.

The output of the above program is not clear separation of images, i think this is because of using the below function :

glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, logoM.w, logoM.h, 0);

one more is here it is placing both the images i,e logo & logo2 in logoM. i think because of this the output is not clear.

My question is :
Is it possible to divide the cylinder area into Rectangles, and placing images on that Rectangular places ?

I think this will be easy.

How to do this please ?

Please guide me.

I am thankful for any kind of reply .

glCopyTexImage2D is what actually copies the final pixels to the new texture … It is actually the blend operations that are the culprit. Try compiling the code with the glutDisplayFunc(display) commented out


void CreateMultiTexture()
{
...
  //glutDisplayFunc(display); // now that you have mixed texture, do real display
}

with that done now you can see what CreateMultiTexture() is really doing. Study the effect and so you should now see hoy one can put multiple textures at different locations as follows (ie remove the BLEND functions and set the glTexCoord2f’s)


void CreateMultiTexture()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  // store values to return to when done
  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();

  GLint viewport[4];
  glGetIntegerv(GL_VIEWPORT, viewport);

  // Temporarily set Viewport to Match Texture Size
  glViewport(0,0,logoM.w,logoM.h);

    glBindTexture ( GL_TEXTURE_2D, logo.genID);
    glBegin(GL_QUADS);
     glTexCoord2f(0,0); glVertex2f(-1,-1);  
     glTexCoord2f(1,0); glVertex2f( 0,-1);  
     glTexCoord2f(1,1); glVertex2f( 0, 0);  
     glTexCoord2f(0,1); glVertex2f(-1, 0);  
    glEnd();

    glBindTexture ( GL_TEXTURE_2D, logo2.genID);
    glBegin(GL_QUADS);
     glTexCoord2f(0,0); glVertex2f(-0,-0);  
     glTexCoord2f(1,0); glVertex2f( 1,-0);  
     glTexCoord2f(1,1); glVertex2f( 1, 1);  
     glTexCoord2f(0,1); glVertex2f(-0, 1);  
    glEnd();

  glBindTexture(GL_TEXTURE_2D,logoM.genID);  // Bind To The Mixed Texture

  // Copy mixed texture to logoM 
  glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, logoM.w, logoM.h, 0);
  // Finally, logoM is now 0.5*logo + 0.5*logo2

  //return to state before generating mixed texture
  glViewport(viewport[0], viewport[1], viewport[2] ,viewport[3]);
  glMatrixMode(GL_MODELVIEW);
  glPopMatrix();
  glMatrixMode(GL_PROJECTION);
  glPopMatrix();

  glutSwapBuffers();

  glutDisplayFunc(display); // now that you have mixed texture, do real display
}
with this approach you can tile images but they cannot overlap.


Hi,

Thank you so much for replying.

I changed the code as you told in the above post :

CODE :

#include <GL/glew.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>

#include <IL/il.h>

GLfloat gAngle = 0.0;
GLUquadricObj *IDquadric;

GLuint gState = 0;

struct TextureHandle
{
ILubyte *p;
ILuint id;
ILint w;
ILint h;
ILenum DestFormat;
ILenum DestType;
GLuint genID;
};

struct TextureHandle logo;
struct TextureHandle logo2;
struct TextureHandle logoM;

ILuint LoadImageDevIL (const char *szFileName, struct TextureHandle *T)
{
ilEnable(IL_ORIGIN_SET);

ilOriginFunc(IL_ORIGIN_LOWER_LEFT);

ILuint ImageNameID;
ilGenImages(1, &ImageNameID);
ilBindImage(ImageNameID);
if (!ilLoadImage(szFileName)) return 0;
ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);

T->id = ImageNameID;
T->p = ilGetData();
T->w = ilGetInteger(IL_IMAGE_WIDTH);
T->h = ilGetInteger(IL_IMAGE_HEIGHT);

T->DestFormat = ilGetInteger(IL_IMAGE_FORMAT);
T->DestType = ilGetInteger(IL_IMAGE_TYPE);

glGenTextures(1, &T->genID);
glBindTexture(GL_TEXTURE_2D, T->genID);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D (GL_TEXTURE_2D, 0, T->DestFormat, T->w, T->h, 0, T->DestFormat, T->DestType, T->p);

printf("%s %d %d %d
",szFileName,T->id,T->w,T->h);
return 1;
}

void timer(int value)
{
const int desiredFPS=120;
glutTimerFunc(1000/desiredFPS, timer, ++value);
GLfloat dt = 1./desiredFPS;

gAngle += dt*360./8.;

glutPostRedisplay();
}

void draw_cylinder()
{
glPushMatrix();
glTranslatef(-5.,0,-100);
glRotatef(gAngle,1.,1.,0.);
gluCylinder(IDquadric,10.0f,10.0f,10.0f,32,32);
glPopMatrix();
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
if (gState) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR);

glBlendColor(.5,.5,.5,.5);

glBindTexture ( GL_TEXTURE_2D, logo.genID);
draw_cylinder();

glBindTexture ( GL_TEXTURE_2D, logo2.genID);
draw_cylinder();

glDisable(GL_BLEND);

} else {
glBindTexture ( GL_TEXTURE_2D, logoM.genID);
draw_cylinder();
}

glutSwapBuffers();
}

void CreateMultiTexture()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);

glViewport(0,0,logoM.w,logoM.h);

glBindTexture ( GL_TEXTURE_2D, logo.genID);
glBegin(GL_QUADS);

glTexCoord2f(0,0); glVertex2f(-1,-1);
glTexCoord2f(1,0); glVertex2f( 0,-1);
glTexCoord2f(1,1); glVertex2f( 0, 0);
glTexCoord2f(0,1); glVertex2f(-1, 0);
glEnd();

glBindTexture ( GL_TEXTURE_2D, logo2.genID);
glBegin(GL_QUADS);
 glTexCoord2f(0,0); glVertex2f(-0,-0);
 glTexCoord2f(1,0); glVertex2f( 1,-0);
 glTexCoord2f(1,1); glVertex2f( 1, 1);
 glTexCoord2f(0,1); glVertex2f(-0, 1);
glEnd();

glBindTexture(GL_TEXTURE_2D,logoM.genID);

glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, logoM.w, logoM.h, 0);

glViewport(viewport[0], viewport[1], viewport[2] ,viewport[3]);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();

glutSwapBuffers();

glutDisplayFunc(display);
}

void cleanupQuadric(void)
{
gluDeleteQuadric(IDquadric);
printf( "cleanupQuadric completed
" );
}

void init()
{
glClearColor(0.0, 0.0, 0.0, 0.0);

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

IDquadric=gluNewQuadric();
gluQuadricNormals(IDquadric, GLU_SMOOTH);
gluQuadricTexture(IDquadric, GL_TRUE);
atexit(cleanupQuadric);

GLdouble Vol = 101.8;
GLdouble Left=-Vol;
GLdouble Right=Vol;
GLdouble Bottom=-Vol;
GLdouble Top=Vol;
GLdouble Near=0;
GLdouble Far=2
Vol;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(Left, Right, Bottom, Top, Near, Far);

GLdouble eyeX=0;
GLdouble eyeY=0;
GLdouble eyeZ=-100+Vol;
GLdouble centerX=0;
GLdouble centerY=0;
GLdouble centerZ=-100;
GLdouble upX=0;
GLdouble upY=1;
GLdouble upZ=0;

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eyeX,eyeY,eyeZ,
centerX,centerY,centerZ,
upX,upY,upZ);

ilInit();

LoadImageDevIL ("/localhome/user/Temp/sample/rro1.jpg", &logo);
LoadImageDevIL ("/localhome/user/Temp/sample/bird.jpg", &logoM);
LoadImageDevIL ("/localhome/user/Temp/sample/out.jpg", &logo2);

glEnable (GL_TEXTURE_2D);
}

void keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case 27:
exit(0);
break;
default:
gState++;
gState %= 2;
printf("%d
",gState);
break;
}
}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow(“Multipass texturing Demo”);
glewInit();

glutTimerFunc(0,timer,0);
glutDisplayFunc(CreateMultiTexture);
glutKeyboardFunc(keyboard);

init();

glutMainLoop();
return 0;
}

if i made a comment on below line :

glutDisplayFunc(display)

it is displaying only two images i,e rro1.jpg & out.jpg,These two images are in diagonal axis, but the image bird.jpg is not displaying.

if i remove the comment on above line i am getting the cylinder with only two images and those are also not so clear images.

Is it necessary to Resize the images to visible clearly on the cylinder surface.

Please Help me.

I am thankful for your help.

if i made a comment on below line :

glutDisplayFunc(display)

it is displaying only two images i,e rro1.jpg & out.jpg,These two images are in diagonal axis, but the image bird.jpg is not displaying.

That is correct – what you are seeing is the logoM texture that you created by adding the two logo + logo2 textures. The position of those textures (diagonals) is set by the four call pairs “glTexCoord2f(); glVertex2f();” Try plotting those points on paper and see how they correspond to the diagonals.

if i remove the comment on above line i am getting the cylinder with only two images and those are also not so clear images.

You misunderstand what CreateMultiTexture() is doing – it is OVEWRITING the texture logoM whatever you used in the line “LoadImageDevIL (”/localhome/user/Temp/sample/bird.jpg", &logoM);" This line is a trick to get a block of memory for writing to with a “good” pixel size. Just create a blank image file with a size; width=width of logo + width of logo2 and height = height of logo + height of logo2. Notice that by calling “glutDisplayFunc(display);” its then only when the multitextured logoM is applied to the cylinder!

Is it necessary to Resize the images to visible clearly on the cylinder surface.

glViewport(0,0,logoM.w,logoM.h);
is setting the size of the viewport in pixels to be match the “blank” image you first loaded “LoadImageDevIL (”/localhome/user/Temp/sample/bird.jpg", &logoM);" – the idea is to make a blank image with a reasonable large size. A better name is “blank.jpg” instead of “bird.jpg”. If you want a third image on the cylinder, add a third texture to the drawing like


void CreateMultiTexture()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);


glViewport(0,0,logoM.w,logoM.h);

//lower left 
glBindTexture ( GL_TEXTURE_2D, logo.genID);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2f(-1,-1);
glTexCoord2f(1,0); glVertex2f( 0,-1);
glTexCoord2f(1,1); glVertex2f( 0, 0);
glTexCoord2f(0,1); glVertex2f(-1, 0);
glEnd();

//upper right
glBindTexture ( GL_TEXTURE_2D, logo2.genID);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2f(-0,-0);
glTexCoord2f(1,0); glVertex2f( 1,-0);
glTexCoord2f(1,1); glVertex2f( 1, 1);
glTexCoord2f(0,1); glVertex2f(-0, 1);
glEnd();

//upper left
glBindTexture ( GL_TEXTURE_2D, logo3.genID);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2f(-1,-0);
glTexCoord2f(1,0); glVertex2f( 0,-0);
glTexCoord2f(1,1); glVertex2f( 0, 1);
glTexCoord2f(0,1); glVertex2f(-1, 1);
glEnd();

glBindTexture(GL_TEXTURE_2D,logoM.genID);


glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, logoM.w, logoM.h, 0);



glViewport(viewport[0], viewport[1], viewport[2] ,viewport[3]);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();

glutSwapBuffers();

glutDisplayFunc(display);
}

Hi,

I am really happy to see 4 images on cylinder with little bit good clarity.You Helped me a lot, Thank you so much.

I placed one more image by placing lower right coordinates as below :

//lower Right

glBindTexture ( GL_TEXTURE_2D, logo4.genID);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2f(-0,-0);
glTexCoord2f(1,0); glVertex2f( 1,0);
glTexCoord2f(1,1); glVertex2f( 1,-1);
glTexCoord2f(0,1); glVertex2f(0,-1);
glEnd();

so total 4 different images can placed on the cylinder using above code.

Is it possible to place more than 4 images ?

and one more is color of images are quite poor.

Now we are placing images one below the other.
Is it possible to place images one after the other on the cylinder ?

i think it is possible to place images one after the other only for two images with coordinates which you gave in post 268610

i need to place more images one after the other.

Please guide me.

I am thankful for your reply.

Thats great you added a fourth image.

Yes, you can have as many images as you like – try changing the X and Y values for the the glVertex2f(X,Y);. For each image you want you add a block of


glBindTexture ( GL_TEXTURE_2D, logoN.genID);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2f(X1,Y1);
glTexCoord2f(1,0); glVertex2f(X2,Y2);
glTexCoord2f(1,1); glVertex2f(X3,Y3);
glTexCoord2f(0,1); glVertex2f(X4,Y4);
glEnd();

And set X,Y pairs to position and size it within a square with origin at 0,0 and the upper corner at 1,1.

Can you post an image somehow of the poor colors you are seeing?

Now we are placing images one below the other.
Is it possible to place images one after the other on the cylinder ?

YOu have control again just set the X,Y values as you please in each glVertex* call.

Hi,
Thank you so much for helping me,

Is it possible to give values for (X1,Y1)(X2,Y2)(X3,Y3)(X4,Y4) as (1,1)(-1,1)(-1,-1)(1,-1) for first image and (2,1)(1,1)(1,-1)(2,-1)for second image placing right to first image using below code which you gave :

glBindTexture ( GL_TEXTURE_2D, logoN.genID);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2f(X1,Y1);
glTexCoord2f(1,0); glVertex2f(X2,Y2);
glTexCoord2f(1,1); glVertex2f(X3,Y3);
glTexCoord2f(0,1); glVertex2f(X4,Y4);
glEnd();

How to fix the center-point on the cylinder ?

How it possible to post images on the forum, i dont know Please help me, i will show you the output .

About adding figures to this forum see upper right corner of this page which is FAQ. About the tenth item down labelled “How do I add an image to my message?” is the one to read. While there you may want to also read “What UBBCode can I use in my posts?” especially the part for inserting “code”.

Is it possible to give values for (X1,Y1)(X2,Y2)(X3,Y3)(X4,Y4) as (1,1)(-1,1)(-1,-1)(1,-1) for first image and (2,1)(1,1)(1,-1)(2,-1)for second image placing right to first image using below code which you gave :

Yes, but you have to use the MODELVIEW matrix ie add a “glOrtho(-2,2,-2,2, -1,1 )” in CreateMultiTexture()



void CreateMultiTexture()
{
...
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glOrtho(-2,2,-2,2, -1,1 );
...

How to fix the center-point on the cylinder ?

This one I am not certain the best way to do this. One option is to use TEXTURE MATRIX stack when its time to draw your cylinder


void draw_cylinder()
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(-5.,0,-100);
glRotatef(gAngle,1.,1.,0.);

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(ds,dt,0); // you need to set dt,ds to move the texture origin

gluCylinder(IDquadric,10.0f,10.0f,10.0f,32,32);

glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}

This is one question that someone else may have a definitive answer to – think of my answer above as a hint! Read up on TEXTURE matrix in Redbook or possibly start another thread post to get others opinions on moving a texture on a gluQuadric geometry. Here’s an example of a NON-rotating cylinder but the origin of the texture is being moved with each new frame (ds is changing)


#include <GL/glew.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>

#include <IL/il.h>

GLfloat gAngle = 0.0;
GLUquadricObj *IDquadric;

GLuint gState = 0;

struct TextureHandle
{
  ILubyte *p;
  ILuint id;
  ILint w;
  ILint h;
  ILenum DestFormat;
  ILenum DestType;
  GLuint genID;
};

struct TextureHandle logo;
struct TextureHandle logo2;
struct TextureHandle logoM;

ILuint LoadImageDevIL (const char *szFileName, struct TextureHandle *T)
{
  ilEnable(IL_ORIGIN_SET);

  ilOriginFunc(IL_ORIGIN_LOWER_LEFT);

  ILuint ImageNameID;
  ilGenImages(1, &ImageNameID);
  ilBindImage(ImageNameID);
  if (!ilLoadImage(szFileName)) return 0;
  ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);

  T->id = ImageNameID;
  T->p = ilGetData();
  T->w = ilGetInteger(IL_IMAGE_WIDTH);
  T->h = ilGetInteger(IL_IMAGE_HEIGHT);

  T->DestFormat = ilGetInteger(IL_IMAGE_FORMAT);
  T->DestType = ilGetInteger(IL_IMAGE_TYPE);

  glGenTextures(1, &T->genID);
  glBindTexture(GL_TEXTURE_2D, T->genID);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexImage2D (GL_TEXTURE_2D, 0, T->DestFormat, T->w, T->h, 0, T->DestFormat, T->DestType, T->p);

  printf("%s %d %d %d
",szFileName,T->id,T->w,T->h);
  return 1;
}


void timer(int value)
{
  const int desiredFPS=120;
  glutTimerFunc(1000/desiredFPS, timer, ++value);
  GLfloat dt = 1./desiredFPS;

  gAngle += dt*360./8.;

  glutPostRedisplay();
}


void draw_cylinder()
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(-5.,0,-100);
glRotatef(45,1.,1.,0.);

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.,gAngle/100.,0); // you need to set dt,ds to move the texture origin

gluCylinder(IDquadric,10.0f,10.0f,10.0f,32,32);

glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}

void display()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glMatrixMode(GL_MODELVIEW);

  if (gState) {
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR);
    //glBlendFunc (GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
    glBlendColor(.5,.5,.5,.5); // set blend constants to 0.5

    glBindTexture ( GL_TEXTURE_2D, logo.genID);
    draw_cylinder();

    glBindTexture ( GL_TEXTURE_2D, logo2.genID);
    draw_cylinder();

    glDisable(GL_BLEND);
  } else {
    glBindTexture ( GL_TEXTURE_2D, logoM.genID);
    draw_cylinder();
  }

  glutSwapBuffers();
}

void CreateMultiTexture()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  // store values to return to when done
  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();
glOrtho(-2,2,-2,2, -1,1 );


  GLint viewport[4];
  glGetIntegerv(GL_VIEWPORT, viewport);

  // Temporarily set Viewport to Match Texture Size
  glViewport(0,0,logoM.w,logoM.h);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR);
    //glBlendFunc (GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
    glBlendColor(.5,.5,.5,.5);

    glBindTexture ( GL_TEXTURE_2D, logo.genID);
    glBegin(GL_QUADS);
     glTexCoord2f(0,0); glVertex2f(-1,-1);  
     glTexCoord2f(1,0); glVertex2f( 1,-1);  
     glTexCoord2f(1,1); glVertex2f( 1, 1);  
     glTexCoord2f(0,1); glVertex2f(-1, 1);  
    glEnd();

    glBindTexture ( GL_TEXTURE_2D, logo2.genID);
    glBegin(GL_QUADS);
     glTexCoord2f(0,0); glVertex2f(-1,-1);  
     glTexCoord2f(1,0); glVertex2f( 1,-1);  
     glTexCoord2f(1,1); glVertex2f( 1, 1);  
     glTexCoord2f(0,1); glVertex2f(-1, 1);  
    glEnd();

    glDisable(GL_BLEND);

  glBindTexture(GL_TEXTURE_2D,logoM.genID);  // Bind To The Mixed Texture

  // Copy mixed texture to logoM 
  glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, logoM.w, logoM.h, 0);
  // Finally, logoM is now 0.5*logo + 0.5*logo2

  //return to state before generating mixed texture
  glViewport(viewport[0], viewport[1], viewport[2] ,viewport[3]);
  glMatrixMode(GL_MODELVIEW);
  glPopMatrix();
  glMatrixMode(GL_PROJECTION);
  glPopMatrix();

  glutSwapBuffers();

  glutDisplayFunc(display); // now that you have mixed texture, do real display
}


void cleanupQuadric(void)
{
  gluDeleteQuadric(IDquadric);
  printf( "cleanupQuadric completed
" );
}


void init()
{
  glClearColor(0.0, 0.0, 0.0, 0.0);

  //glEnable(GL_CULL_FACE);
  glEnable(GL_DEPTH_TEST);
  glDepthFunc(GL_LEQUAL);

  IDquadric=gluNewQuadric();
  gluQuadricNormals(IDquadric, GLU_SMOOTH);
  gluQuadricTexture(IDquadric, GL_TRUE);
  atexit(cleanupQuadric);

  GLdouble Vol = 10*1.8;
  GLdouble Left=-Vol;
  GLdouble Right=Vol;
  GLdouble Bottom=-Vol;
  GLdouble Top=Vol;
  GLdouble Near=0;
  GLdouble Far=2*Vol;

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(Left, Right, Bottom, Top, Near, Far);

  GLdouble eyeX=0;
  GLdouble eyeY=0;
  GLdouble eyeZ=-100+Vol;
  GLdouble centerX=0;
  GLdouble centerY=0;
  GLdouble centerZ=-100;
  GLdouble upX=0;
  GLdouble upY=1;
  GLdouble upZ=0;

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt(eyeX,eyeY,eyeZ,
    centerX,centerY,centerZ,
    upX,upY,upZ);

  ilInit();
  //LoadImageDevIL ("/localhome/user/Temp/sample/bird.bmp", &logo);
  LoadImageDevIL ("logo.jpg", &logo);
  LoadImageDevIL ("logo.jpg", &logoM); // make room for Multi-texture
  LoadImageDevIL ("logo2.jpg", &logo2);

  glEnable (GL_TEXTURE_2D);
}


void keyboard(unsigned char key, int x, int y)
{
  switch (key)
  {
    case 27:
      exit(0);
      break;
    default:
      gState++;
      gState %= 2;
      printf("%d
",gState);
      break;
  }
}


int main(int argc, char** argv)
{
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
  glutCreateWindow("Multipass texturing Demo");
  glewInit();

  glutTimerFunc(0,timer,0);
  glutDisplayFunc(CreateMultiTexture);
  glutKeyboardFunc(keyboard);

  init();

  glutMainLoop();
  return 0;
}

Hi,

Thank you so much.i got the idea how to place images one after the other.

The above code is placing the images one after the other. But the thing is those two images are overlapping while displaying because of same parameter in function glVertex2f() for both logo & logo2 i think.

Different types of displaying images which you told :

1)Cylinder with images which are placed one below the other. Code is in post 268799.

2)we have seen cylinder with images which are placed one after the other. Code is in post 268893.

One more, Is it possible to place images side by side(Like pages in the book) on the Non-rotating Cylinder, but images should rotate to display next image which is side to currently displaying image ?

Please guide me.

i am thankful for your reply.

The above code is placing the images one after the other. But the thing is those two images are overlapping while displaying because of same parameter in function glVertex2f() for both logo & logo2 i think.

Yes, you have to choose values/numbers that make sense to what you want in all the glVertex2f() calls

Points 1 an 2: You have a code now that shows you how to position as many textures as you like on the cylinder and shows you how to move the texture around on that cylinder. That is complete flexibility to do what you describe (place as many images on the cylinder as you like, place images in any order left or right - top-to-bottom).

In terms of pages in a book – you can do this in openGL yes. But that is beyond the scope of this post. Once you understand this code above a new post would be a good place to start to understand a more 3D book like structure.

ps I will be out of the office for the next two weeks on vacation. You have a working code. Try to read through it and understand especially the GL_MODELVIEW and GL_TEXTURE matrix stack.

Hi,

Thank you very very much for your ideas. i got more information from you.

Happy Vacation.

Hi,

Thank you so much for your help.

i need to scale texture images which are there on the cylinder surface.i,e the image which is on the viewer side should be look like larger and the remaining images on the other side should be smaller in size compare to one which i am watching currently.

please reply after finishing your vacation. from now i am on leave for 10 days.

Happy Vacation.

i am thankful for your reply.

Hi,

I happy for completing vacation… i pasted the above problem in advance forums, but i dint the replies . so please help me from this problem .

I am thankful for your reply.

Happy New Year :slight_smile:

The following code shows how to place a texture in a particular location in an MxN grid of textures … study function “placeTexture” function starting at line 101.

Try commenting out different lines between 147 and 152 to see how to choose a particular grid location where the texture is located. Notice that the 0,1 slot is commented out initially hence nothing is drawn at the leftmost middle slot.

Once you are comfortable with placing an arbritrary texture anywhere in the grid then you can texture the cylinder by removing the comment on line 170 (glutDisplayFunc(display):wink:


#include <GL/glew.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>

#include <IL/il.h>

GLfloat gTexOffset = 0.0;
GLUquadricObj *IDquadric;

struct TextureHandle
{
  ILubyte *p;
  ILuint id;
  ILint w;
  ILint h;
  ILenum DestFormat;
  ILenum DestType;
  GLuint genID;
};

struct TextureHandle logo;
struct TextureHandle logo2;
struct TextureHandle logoM;

ILuint LoadImageDevIL (const char *szFileName, struct TextureHandle *T)
{
  ilEnable(IL_ORIGIN_SET);

  ilOriginFunc(IL_ORIGIN_LOWER_LEFT);

  ILuint ImageNameID;
  ilGenImages(1, &ImageNameID);
  ilBindImage(ImageNameID);
  if (!ilLoadImage(szFileName)) return 0;
  ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);

  T->id = ImageNameID;
  T->p = ilGetData();
  T->w = ilGetInteger(IL_IMAGE_WIDTH);
  T->h = ilGetInteger(IL_IMAGE_HEIGHT);

  T->DestFormat = ilGetInteger(IL_IMAGE_FORMAT);
  T->DestType = ilGetInteger(IL_IMAGE_TYPE);

  glGenTextures(1, &T->genID);
  glBindTexture(GL_TEXTURE_2D, T->genID);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexImage2D (GL_TEXTURE_2D, 0, T->DestFormat, T->w, T->h, 0, T->DestFormat, T->DestType, T->p);

  printf("%s %d %d %d
",szFileName,T->id,T->w,T->h);
  return 1;
}


void timer(int value)
{
  const int desiredFPS=120;
  glutTimerFunc(1000/desiredFPS, timer, ++value);
  GLfloat dt = 1./desiredFPS;

  //gTexOffset += dt*360./8.;

  glutPostRedisplay();
}


void draw_cylinder()
{
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glTranslatef(-5.,0,-100);
  glRotatef(45,1.,1.,0.);

  glMatrixMode(GL_TEXTURE);
  glLoadIdentity();
                                 // you need to set dt,ds to move the texture origin
  glTranslatef(0.,gTexOffset/100.,0);

  gluCylinder(IDquadric,10.0f,10.0f,10.0f,32,32);

  glMatrixMode(GL_MODELVIEW);
  glPopMatrix();
}


void display()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glBindTexture ( GL_TEXTURE_2D, logoM.genID);
  draw_cylinder();

  glutSwapBuffers();
}


void placeTexture(GLuint M, GLuint N, GLuint i, GLuint j, GLuint genID)
{
  // M is number of slots in horizonatal direction
  // choose i = 0,1, ... M-1
  // N is number of slots in vertical direction
  // choose j = 0,1, ... N-1
  // genID is texture ID

  GLfloat X1 = (GLfloat) i / (GLfloat) M;
  GLfloat X2 = X1 + (GLfloat) 1 / (GLfloat) M;
  GLfloat Y1 = (GLfloat) j / (GLfloat) N;
  GLfloat Y2 = Y1 + (GLfloat) 1 / (GLfloat) N;

  glBindTexture ( GL_TEXTURE_2D, genID);
  glBegin(GL_QUADS);
  glTexCoord2f(0,0); glVertex2f(X1,Y1);
  glTexCoord2f(1,0); glVertex2f(X2,Y1);
  glTexCoord2f(1,1); glVertex2f(X2,Y2);
  glTexCoord2f(0,1); glVertex2f(X1,Y2);
  glEnd();
}


void CreateMultiTexture()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  // store values to return to when done
  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();
  glOrtho(0,1, 0,1, -1,1 );

  GLint viewport[4];
  glGetIntegerv(GL_VIEWPORT, viewport);

  // Temporarily set Viewport to Match Texture Size
  glViewport(0,0,logoM.w,logoM.h);

  // setup grid of 2x3 textures
  GLuint M = 2;
  GLuint N = 3;
  placeTexture(M,N, 0,0, logo.genID);  // place texture in 0,0 slot
  placeTexture(M,N, 1,0, logo2.genID); // place texture in 1,0 slot
  //placeTexture(M,N, 0,1, logo.genID); // place texture in 0,1 slot
  placeTexture(M,N, 1,1, logo2.genID); // place texture in 1,1 slot
  placeTexture(M,N, 0,2, logo.genID);  // place texture in 0,2 slot 
  placeTexture(M,N, 1,2, logo2.genID); // place texture in 1,2 slot

  // Bind To The Mixed Texture
  glBindTexture(GL_TEXTURE_2D,logoM.genID);

  // Copy mixed texture to logoM
  glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, logoM.w, logoM.h, 0);
  // Finally, logoM is now grid of placed textures!

  //return to state before generating mixed texture
  glViewport(viewport[0], viewport[1], viewport[2] ,viewport[3]);
  glMatrixMode(GL_MODELVIEW);
  glPopMatrix();
  glMatrixMode(GL_PROJECTION);
  glPopMatrix();

  glutSwapBuffers();

  //glutDisplayFunc(display);      // now that you have mixed texture, do real display
}


void cleanupQuadric(void)
{
  gluDeleteQuadric(IDquadric);
  printf( "cleanupQuadric completed
" );
}


void init()
{
  glClearColor(0.0, 0.0, 0.0, 0.0);

  //glEnable(GL_CULL_FACE);
  glEnable(GL_DEPTH_TEST);
  glDepthFunc(GL_LEQUAL);

  IDquadric=gluNewQuadric();
  gluQuadricNormals(IDquadric, GLU_SMOOTH);
  gluQuadricTexture(IDquadric, GL_TRUE);
  atexit(cleanupQuadric);

  GLdouble Vol = 10*1.8;
  GLdouble Left=-Vol;
  GLdouble Right=Vol;
  GLdouble Bottom=-Vol;
  GLdouble Top=Vol;
  GLdouble Near=0;
  GLdouble Far=2*Vol;

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(Left, Right, Bottom, Top, Near, Far);

  GLdouble eyeX=0;
  GLdouble eyeY=0;
  GLdouble eyeZ=-100+Vol;
  GLdouble centerX=0;
  GLdouble centerY=0;
  GLdouble centerZ=-100;
  GLdouble upX=0;
  GLdouble upY=1;
  GLdouble upZ=0;

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt(eyeX,eyeY,eyeZ,
    centerX,centerY,centerZ,
    upX,upY,upZ);

  ilInit();
  //LoadImageDevIL ("/localhome/user/Temp/sample/bird.bmp", &logo);
  LoadImageDevIL ("logo.jpg", &logo);
  LoadImageDevIL ("logo2.jpg", &logo2);

  LoadImageDevIL ("logoM.jpg", &logoM); // make room for Multi-texture grid 

  glEnable (GL_TEXTURE_2D);
}


void keyboard(unsigned char key, int x, int y)
{
  switch (key)
  {
    case 27:
      exit(0);
      break;
    default:
      break;
  }
}


int main(int argc, char** argv)
{
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
  glutCreateWindow("Multipass texturing Demo");
  glewInit();

  glutTimerFunc(0,timer,0);
  glutDisplayFunc(CreateMultiTexture);
  glutKeyboardFunc(keyboard);

  init();
  glutReshapeWindow(logoM.w,logoM.h); 

  glutMainLoop();
  return 0;
}


Hi,

Thank you so much for your reply.

I executed the above code by removing all the commands except the below :

//LoadImageDevIL ("/localhome/user/Temp/sample/bird.bmp", &logo);

But the code showing the run time error as below :


user@lxdevenv:~/Desktop$ ./rect5
freeglut (./rect5): Unable to create direct context rendering for window 'Multipass texturing Demo'
This may hurt performance.
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  12 (X_ConfigureWindow)
  Value in failed request:  0x0
  Serial number of failed request:  38
  Current serial number in output stream:  39
cleanupQuadric completed



if i made comment which you made in the above code. giving the same error but changing the numbers in the place of 38 and 39.

what will be the problem ?

I am thankful for your reply

I suspect this error is due to the size of your texture. What are the exact pixel sizes of all the textures you are using?

I really need a way to debug with your actual textures – Take a look at Post269192 to see how to use Dropbox to share files. Once you have your account and uploaded your textures tell me which links using the notation without the quotes "

"your url link"[/code"]" and I will be able to downlaod your images. See   [forum FAQ](http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=faq) section "What UBBCode can I use in my posts?" to explain what you can format in these openGL forums.

Hi,

Thank you so much for your reply.

I am sending the link where i uploaded my textures as below :

[http://img40.imageshack.us/gal.php?g=aptp.jpg](http://img40.imageshack.us/gal.php?g=aptp.jpg)

I am thankful for your reply …

When I download from your link I get the files


aptp.jpg  logo2sk.jpg  logofni.jpg  logomn.jpg

Why are the names so different from “logo.jpg, logo2.jpg, logoM.jpg” that the C-code references? Also you mentiojned that you had a problem with a “LoadImageDevIL (”/localhome/user/Temp/sample/bird.bmp", &logo);" in a previous post – where is the “bird.bmp” file for download? Do you mean for me to use “aptp.jpg” instead of “bird.bmp”?

do the pixel dimensions make sense for the following downloaded files?


> identify ravikishore/*
ravikishore/aptp.jpg JPEG 154x100 154x100+0+0 8-bit DirectClass 2.26kb 
ravikishore/logo2sk.jpg[1] JPEG 154x100 154x100+0+0 8-bit DirectClass 2.3kb 
ravikishore/logofni.jpg[2] JPEG 150x100 150x100+0+0 8-bit DirectClass 2.23kb 
ravikishore/logomn.jpg[3] JPEG 400x500 400x500+0+0 8-bit DirectClass 3.76kb 

Hi,

Thank you for replying.

I uploaded the images as logo.jpg, logo2.jpg, logoM.jpg , but after uploading to imageShack, the names of the files are getting changed while downloading. i checked this by once again uploading the images and checked by downloading them.

But the image names i included in the program and image names in my folder are same .

and all the dimensions in the above mentioned images are same, they dint get changed.

Yes your are right instead of bird.bmp use apt.jpg.

other then image names is there any other problem ?

I am thankful for your reply.