Results 1 to 4 of 4

Thread: problem with texture

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    6

    problem with texture

    Hello, I'm a new user. I have a problem with the inclusion of texture. I added texture but it when I move the camera moves itself. how can I lock the texture?
    thank you very much.

    Mary

  2. #2
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    6

    Re: problem with texture

    sorry,
    I forgot to say that my programming language is C++
    thanks

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Karachi, Pakistan
    Posts
    810

    Re: problem with texture

    Could u post your code so that we may tell u what u r doing wrong?
    Regards,
    Mobeen

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    6

    Re: problem with texture

    well the code is as follows
    In the function display've enabled automatic generation of texture.

    Code :
    void display()
    {
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     
    	glMatrixMode(GL_MODELVIEW);
     
     
    	glDisable(GL_TEXTURE_GEN_S);
    	glDisable(GL_TEXTURE_GEN_T);
    	glDisable(GL_TEXTURE_GEN_R);
    	glMatrixMode(GL_MODELVIEW);
     
     
     
     
    	glLoadIdentity();
    	gluLookAt(pos[0], pos[1], pos[2], at[0], at[1], at[2], up[0], up[1], up[2]);
     
    	glColor3f(1.0, 1.0, 1.0);
    	for(int i=0;i<100;i++)
    	{
    		for(int j=0;j<100;j++)
    		{
    			glPushMatrix();
    			float x = -50 + i;  
    			float z = -100 + j;
    			glTranslatef(x, 0, z);
    			glScalef(1.0, 0.0, 1.0);	
    			glutWireCube(4.0);
    			glPopMatrix();
    		}
    	}
     
     
    	glEnable(GL_TEXTURE_GEN_S);
    	glEnable(GL_TEXTURE_GEN_T);
    	glEnable(GL_TEXTURE_GEN_R);
    	glMatrixMode(GL_MODELVIEW);
     
     
    	for(int i=0; i<list.counter; i++){		
    		list.data[i];
    		draw(list.data[i]);		
    	}
    	glFlush ();
    	glutSwapBuffers();
    }
     
     
     
    void draw(objectcad objcad){
    	GLfloat xobj = objcad.xpos;
    	GLfloat yobj = objcad.ypos;
    	GLfloat zobj = objcad.zpos;
    	GLfloat alphaObj = objcad.alpha;
    	GLfloat xScaleObj = objcad.xscale;
    	GLfloat yScaleObj = objcad.yscale;
    	GLfloat zScaleObj = objcad.zscale;
    	int idColor = objcad.color;
    	int index = objcad.indexObject;
     
    	glBindTexture(GL_TEXTURE_2D, texNames[objcad.idTexture]);
     
    	glPushMatrix();
    	glColor3fv(colors[idColore]);
    	glTranslatef(xobj, yobj, zobj);
    	glScalef(xScaleObj, yScaleObj, zScaleObj);
    	glRotatef(alphaObj, 0.0, 1.0, 0.0);
    	glLoadName(objcad.picking);
    	if(wire_solid==true){
    		drawSolid(index);
    	}else{
    		drawWire(index);
    	}
     
    	glPopMatrix();
    }
     
     
     
    GLuint loadTexture(const char *filename){
    	GLuint idTexture;
     
    	FREE_IMAGE_FORMAT fifmt = FreeImage_GetFileType(filename, 0);
     
     
    	FIBITMAP *dib = FreeImage_Load(fifmt, filename,0);
     
     
    	dib = FreeImage_ConvertTo24Bits(dib);
     
    	if( dib != NULL )
    	{
    		glGenTextures( 1, &amp;idTexture );
    		glBindTexture( GL_TEXTURE_2D, idTexture );
     
     
    		BYTE *pixels = (BYTE*)FreeImage_GetBits(dib);
     
     
    		glTexImage2D( GL_TEXTURE_2D, 0, 3, 
    			FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), 0,
    			GL_BGR_EXT, GL_UNSIGNED_BYTE, pixels );
     
    		glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST );
    		glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST );
    		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
     
    		FreeImage_Unload(dib);
    		return idTexture;
    	}
    	return -1;
    }
     
    int main(int argc, char **argv){
    	.....
    	texNames[0]=loadTexture("t1.jpg");
    	texNames[1]=loadTexture("t2.jpg");
    	texNames[2]=loadTexture("t3.jpg");
    	texNames[3]=loadTexture("t4.jpg");
    }

    thanks

    mary

Similar Threads

  1. Render to texture problem or problem in approach
    By Taimoorak in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-07-2018, 06:04 AM
  2. Replies: 1
    Last Post: 01-10-2005, 09:50 AM
  3. Replies: 0
    Last Post: 01-09-2005, 06:01 PM
  4. Replies: 0
    Last Post: 01-09-2005, 05:53 PM
  5. Replies: 1
    Last Post: 01-09-2005, 05:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean