Results 1 to 6 of 6

Thread: OpenGl Quickie

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    It was a long time since I used OpenGL but IIRC the trick is in the projection matrix. Can't remember how (actually I never mastered the projection matrix configuration) but I think the red or the blue book have an example.

    [edit] Beaten...
    No signature provided yet.

  2. #2
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Hmm, I've managed to sort of fix the problem. But now I have a new problem... The image is, how to put it, not garbled but..... well. check the attachment Its better but not really practical.

    To compare result is what the program looks like and Picture.png is what it should look like... Any ideas as to what I'm doing wrong? Here's my render code:

    Code:
    procedure Image.Draw(X,Y: Int64);
    var
        VxR: array [1..2] of LongInt;
        VyR: array [1..2] of LongInt;
        
        PxR: array [1..2] of Int64;
        PyR: array [1..2] of Int64;
        
    begin
        VxR[1] := 0;
        VxR[2] := Surface.W;
        VyR[1] := 0;
        VyR[2] := Surface.H;
        
        PxR[1] := X;
        PxR[2] := X + Surface.W;
        PyR[1] := Y;
        PyR[2] := Y + Surface.H;
    
        glBindTexture( GL_TEXTURE_2D, texture );
    
        glBegin( GL_QUADS );
    
        glTexCoord2i( VxR[1], VyR[2] );
        glVertex3f( PxR[1], PyR[2], 0. );
    
        glTexCoord2i( VxR[2], VyR[2] );
        glVertex3f( PxR[2], PyR[2], 0. );
    
        glTexCoord2i( VxR[2], VyR[1] );
        glVertex3f( PxR[2], PyR[1], 0. );
    
         glTexCoord2i( VxR[1], VyR[1] );
        glVertex3f( PxR[1], PyR[1], 0. );
        glEnd();
    end;
    Note that these images were originally PNG before PGD converted them to jpg....

    Edit: Almost forgot to mention: I am expecting it to go off the edge of the screen... I have a different scale procedure.
    Attached Images Attached Images
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  3. #3
    Maybe this thread can help you a bit:

    http://www.pascalgamedevelopment.com/showthread.php?6168-I-need-some-help-with-2D-drawing-libraries


    The first part is about pixel-perfect drawing.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  4. #4
    glTexCoord2i doesn't make your texture coordinates scale from 0..Width. They are still ranged from 0..1. Use glTexCoord2f with that proper range and it might solve it. Otherwise the error might be in texture loading.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •