Results 1 to 2 of 2

Thread: problem on scaling the image

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2008

    problem on scaling the image

    Hi experts,
    I am loading an image using OpenGL texturing in MDI CView in VC++.I am displaying an image using the Command
    glTranslatef(0.0f,0.0f,-250.0f). Now I want to Enlarge the i change the zvalue of the glTranslatef like glTranslatef(0.0f,0.0f,-350.0f).
    so, the image enlarged.But, I want to enlarge the image using glScalef().if i give glScalef it didn't work.
    what can i do? any help.

    coding is following :

    void CLoadMapView::OnPaint()
    CPaintDC dc(this);
    glClearColor(0.0, 0.0, 0.0, 0) ;
    glEnable(GL_TEXTURE_2D) ;
    glPushMatrix() ;
    glTranslatef( 0.0f,0.0f,-250.0f) ;
    glBindTexture(GL_TEXTURE_2D, m_textureID);
    glTexCoord2f(1.0,0.0) ;
    glVertex3f((GLdouble)m_width/8 ,(GLdouble)-m_height/8,-0.5) ;
    glTexCoord2f(0.0,0.0) ;
    glVertex3f((GLdouble)-m_width/8,(GLdouble) -m_height/8,-0.5) ;
    glTexCoord2f(0.0,1.0) ;
    glVertex3f((GLdouble)-m_width/8,(GLdouble) m_height/8,-0.5) ;
    glTexCoord2f(1.0,1.0) ;
    glVertex3f((GLdouble)m_width/8, (GLdouble)m_height/8,-0.5) ;
    glEnd() ;
    glPopMatrix() ;
    glDisable(GL_TEXTURE_2D) ;
    SwapBuffers(dc) ;
    void CLoadMapView::OnSize(UINT nType, int cx, int cy)
    CView::OnSize(nType, cx, cy) ;
    GLdouble fAspect ;
    fAspect = 1.0f ;
    HWND hWnd = GetSafeHwnd() ;
    HDC hDc = ::GetDC(hWnd) ;
    wglMakeCurrent(hDc, m_hGLContext) ;
    m_width = cx ;
    m_height = cy ;
    fAspect = (GLdouble)m_width /(GLdouble)m_height ;
    if(m_width== 0 || m_width == 0)
    return ;
    glMatrixMode (GL_PROJECTION) ;
    glLoadIdentity() ;
    gluPerspective(40.0f, fAspect, 1.0f, 500.0f) ;
    glViewport (0, 0, m_width, m_height) ;
    glMatrixMode(GL_MODELVIEW) ;
    glLoadIdentity() ;

  2. #2
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006

    Re: problem on scaling the image

    First, one precision, glTranslate is not for display, as its name says, it just applies a translation on the current selected matrix (In this case, the modelview one).
    All what glTranslate does here is moving the rendered quad along the Z-axis, the one perpendicular to the screen in this case. So as far as you translate the quad toward negative Z the quad will get smaller.
    IMO, this is not a good solution to rescale the quad, (since you cannot push z at the infinite, the quad will be clipped after the far clipping plane). As you said it is better to use glScale and it should work for what you want to do. Now if you want us to help you, you should show us how you use glScalef in your code.

Similar Threads

  1. auto-scaling grayscale image possible?
    By samvdj in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-10-2013, 07:38 AM
  2. Fast image scaling
    By Randel in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-04-2010, 01:02 PM
  3. Fast image scaling
    By Treehouse in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 09-04-2009, 05:39 AM
  4. Nearest Neighbour image scaling
    By Mihail121 in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 04-26-2003, 12:55 PM
  5. glScalef as it applies to scaling of a pixel image
    By sillst in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-16-2001, 10:15 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