Results 1 to 4 of 4

Thread: need urgent help with textures

  1. #1
    Guest

    need urgent help with textures

    I've posted another topec but got no answer any help with this ehings would b appreiated !
    Here's the code !
    {$M 1000000 8000000}
    Uses tex,wingraph,crt,gl,glu,glut;
    const poly1=1;
    var poly:array[1..100]of GLuint;
    img:texture;
    texctrl:GLInt;
    buf:PGLByte;
    Procedure Init;
    Begin
    SetOpenGlMode(DirectOn);

    GLMatrixMode(GL_PROJECTION);
    GLBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    TexLoad('mop.tex',img);
    getmem(Buf,mx*my*3);
    Buf:=@img;

    GLClearColor(0,0,0,0);
    GLClear (GL_Color_Buffer_bit OR gl_dEPTH_buffer_bit);
    glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);

    GlEnable(GL_TEXTURE_2D);

    GLGenTextures(1,@texctrl);
    glBindTexture(GL_TEXTURE_2D,texctrl);

    glTexImage2D(GL_TEXTURE_2D, 0 , GL_RGB, mx, my, 0, GL_RGB, GL_byte, @buf);

    glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL _REPEAT);
    glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL _REPEAT);
    GLTexEnvF(GL_Texture_ENV,GL_TEXTURE_ENV_MODE,GL_DE CAL);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_Linear);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

    end;
    Procedure Draw;
    Begin
    GLNewList(poly1,GL_Compile);
    GLENABLE(GL_TEXTURE_2D);
    GLBegin(GL_POLYGON);
    GLColor4f(1.0,1.0,1.0,1.0);
    GLTexCoord2D(0,1);GLVertex3f(0.25,0.25,0.0);
    GLTexCoord2D(1,1);GLVertex3f(0.75,0.25,0.0);
    GLTexCoord2D(1,0);GLVertex3f(0.75,0.75,0.0);
    GLTexCoord2D(0,0);GLVertex3f(0.25,0.75,0.0);
    GLEnd();
    GLEndList;
    GLFlush();
    GLDISABLE(GL_TEXTURE_2D);
    end;
    Begin
    InitGraph(d8bit,m640x480,'TEXTURE TEST 1');
    init;
    draw;
    GLCallList(Poly1);
    updategraph(updatenow);
    closegraph;
    end;
    end.

    variable img is an [0..256,0..256,0..2]
    It seems that I can't make it work !
    HELP ME PLS !
    the result is at www.testimg.20m.com
    10x !

  2. #2
    Junior Member Newbie
    Join Date
    Aug 2005
    Location
    home
    Posts
    4

    Re: need urgent help with textures

    I'm sorry for that I was really angry at that moment !
    ok i'll explain to you what is the problem !
    the program should be very simple it should show an polygon with a texture ! but instead of showing it, shows only a few pixels !
    an image is at http://www.testimg.20m.com/
    test.bmp !
    and by the way i've tried lots of methods but still doesen't work and I don't think of you like you are my personal debuggers I've been tryng to pot a texture ont that poly for 3 days and I can't do it !
    Sorry again !

  3. #3
    Senior Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    913

    Re: need urgent help with textures

    I have last programmed in Pascal before too many years so I have forgot many things and I am not familiar with the units you are using so I may be entirely wrong in my gues.

    Is polygon drawn correctly when texturing is not used? If it is i would assume that your texture initialization code is wrong and you are passing incorrect pointer into TexImage2D.

    There are several things that are suspects to me:
    Code :
    getmem(Buf,mx*my*3);
    Buf:=@img;
    Here you are allocating memory yet you are on next line changing pointer to allocated memory to pointer to img variable. This looks to me as memory leak.

    Code :
    Buf:=@img
    I do not know what a texture type is however because Pascal does have strong type checking i would assume that it is array of GLbyte or something like that so this can be correct and you are not taking pointer to somethng other than texture data.

    Code :
    glTexImage2D(GL_TEXTURE_2D, 0 , GL_RGB, mx, my, 0, GL_RGB, GL_byte, @buf);
    This looks to me as the cause of the trouble. TexImage2D expects as last parameter the pointer to data to load into texture however you use @buf which is pointer to pointer to data. Because of this instead of uploading texture image you are uploading some part of the memory in which buf variable is stored, try to remove the adress operator @ from this line.

    One additional thing, while it is not bug i would expect that if you use glEnable inside display list, you will also add corresponding glDisable into that list which your Draw procedure does not.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2005
    Posts
    20

    Re: need urgent help with textures

    from what i have found it is a good idea to include images of whats happening. i do aggree on the @buf, which is mentioned above. it took me a while to get texturing to work also.

Similar Threads

  1. Help me pls...very urgent...thanks very much...
    By scorpio79 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-07-2005, 07:58 PM
  2. URGENT, Help
    By alvin in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-22-2003, 06:32 PM
  3. Urgent dll
    By Contact in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-18-2002, 03:11 PM
  4. Help Please-Urgent
    By devchandc in forum OpenGL: User Software
    Replies: 0
    Last Post: 01-09-2002, 11:52 AM
  5. vtk, TCL?urgent!!!
    By wendy_lw in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-13-2000, 11:11 AM

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