Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Leroy1891

Render To Texture Problem

This topic is 5331 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a texture class i wrote that can load an image as a texture and also project it to the screen in 2D. It is also able to create a blank texture for rendering to and take care of the render to texture process itself. When I have one texture with an image loaded into it and one setup as the same size i can draw the first texture and render it''s contents to the second no problem. but when i try to draw the first texture and render the exact area of the screen it''s being drawn to into the very same texture it slowly blurs and you can see it shift to the right as it does. does anyone have any idea why this is happening? The function that draws the tex is this //==================================================== void Textures::Draw2D(int X,int Y,Vectors3f Rotation,Vectors3f Scale) { if(Data == NULL) return; // AUX_RGBImageRec for storing int HalfWidth=Data->sizeX/2; int HalfHeight=Data->sizeY/2; Vectors3f Center,UpperLeft,UpperRight,LowerLeft,LowerRight; GLint Viewport[4]; GLdouble ModelView[16]; GLdouble Projection[16]; GLdouble dX,dY,dZ; glPushMatrix(); glLoadIdentity(); glGetDoublev(GL_MODELVIEW_MATRIX,ModelView); glPopMatrix(); glGetDoublev(GL_PROJECTION_MATRIX,Projection); glGetIntegerv(GL_VIEWPORT,Viewport); gluUnProject((GLdouble)X,(GLdouble)Y,(GLdouble)0.9,ModelView,Projection,Viewport,&dX,&dY,&dZ); Center.Set(dX,dY,dZ); gluUnProject((GLdouble)X-HalfWidth,(GLdouble)Y+HalfHeight,(GLdouble)0.9,ModelView,Projection,Viewport,&dX,&dY,&dZ); UpperLeft.Set(dX,dY,dZ); gluUnProject((GLdouble)X+HalfWidth,(GLdouble)Y+HalfHeight,(GLdouble)0.9,ModelView,Projection,Viewport,&dX,&dY,&dZ); UpperRight.Set(dX,dY,dZ); gluUnProject((GLdouble)X-HalfWidth,(GLdouble)Y-HalfHeight,(GLdouble)0.9,ModelView,Projection,Viewport,&dX,&dY,&dZ); LowerLeft.Set(dX,dY,dZ); gluUnProject((GLdouble)X+HalfWidth,(GLdouble)Y-HalfHeight,(GLdouble)0.9,ModelView,Projection,Viewport,&dX,&dY,&dZ); LowerRight.Set(dX,dY,dZ); glTranslatef(Center.X,Center.Y,Center.Z); if(Scale != 1) glScalef(Scale.X,Scale.Y,Scale.Z); if(Rotation != 0) { glRotatef(Rotation.X,1.0,0.0,0.0); glRotatef(Rotation.Y,0.0,1.0,0.0); glRotatef(Rotation.Z,0.0,0.0,1.0); } glTranslatef(-Center.X,-Center.Y,-Center.Z); glBindTexture(GL_TEXTURE_2D,TexName); glBegin(GL_QUADS); glTexCoord2f(0.0,0.0); glVertex3f(LowerLeft.X,LowerLeft.Y,LowerLeft.Z); glTexCoord2f(1.0,0.0); glVertex3f(LowerRight.X,LowerRight.Y,LowerRight.Z); glTexCoord2f(1.0,1.0); glVertex3f(UpperRight.X,UpperRight.Y,UpperRight.Z); glTexCoord2f(0.0,1.0); glVertex3f(UpperLeft.X,UpperLeft.Y,UpperLeft.Z); glEnd(); } //============================================================== this is the code that renders from the screen void Textures::GetScreen(int X,int Y,int width,int height) { glBindTexture(GL_TEXTURE_2D,TexName); glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB,X,Y,width,height,0); }

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!