Results 1 to 8 of 8

Thread: How can I use glDrawTexOES()

  1. #1
    Junior Member
    Join Date
    Oct 2006
    Posts
    28

    How can I use glDrawTexOES()

    I'd like to use glDrawTexOES().
    If i want to map the texture to glDrawTexOES()
    How can i do?
    The ES manual indicates that glDrawTexOES calculates uv coordinates automately.
    so I guess It's not need glTexCoordPointer()
    my code is
    glBindTexture(GL_TEXTURE_2D, m_TexID);
    glEnable(GL_TEXTURE_2D);
    glDrawTexiOES(0,0,0,200,200);
    But I's not work correctly;
    Only From 0,0 to 200,200 screen coord rectangle be shown without texture image.
    How can i map the texture to glDrawTexOES()?

    Can I get some example code about glDrawTexOES()??
    help me.

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353
    You need to set the texture crop rectangle which determines the part of the texture mapped to the drawn rectangle.

    int cropRect[4] = { 0, 0, 256, 256 }; // crop rectangle in texels (u, v, width, height)
    glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect);
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3
    Junior Member
    Join Date
    Oct 2006
    Posts
    28
    i didn't know GL_TEXTURE_CROP_RECT_OES.
    Thanks a lot Xmas.

  4. #4
    Junior Member
    Join Date
    Oct 2006
    Posts
    28
    When this flag GL_COORD_REPLACE_OES is needed??
    opengl es 1.1 manual is not memtioned.

    I used bitmap for mapping texture directly, it's tured over...pData is bitmap data.

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, WIN_WIDTH, WIN_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, pData);

    int cropRect[4] = {0,0,800,480};
    glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect);
    glDrawTexiOES(0,0,0, 800,480);

    anything else's solution?? without memcpy().?

  5. #5
    Senior Member
    Join Date
    May 2006
    Posts
    353
    Quote Originally Posted by danielkim
    When this flag GL_COORD_REPLACE_OES is needed??
    opengl es 1.1 manual is not memtioned.
    It belongs to the OES_point_sprite extension and does not affect DrawTex.

    I used bitmap for mapping texture directly, it's tured over...pData is bitmap data.
    Not sure if it is what you mean, but if the image is vertically flipped, you can try inverting the crop rectangle:
    int cropRect[4] = {0,480,800,-480};

    Remember that in OpenGL (ES) the origin of images is the lower left corner.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  6. #6
    Junior Member
    Join Date
    Oct 2006
    Posts
    28
    you can try inverting the crop rectangle:
    int cropRect[4] = {0,480,800,-480};

    Remember that in OpenGL (ES) the origin of images is the lower left corner.
    You are right. I wasn't good at using cropRect .
    Thanks a lot Xmas.

  7. #7

    Re: How can I use glDrawTexOES()

    I followed the above discussion, but i still see a blank screen.
    Am i missing something in the below code?

    extern const UB tex_image[256][256 * 4]; //RGBA
    int cropRect[4] = { 0, 0, 256, 256 };

    glEnable(GL_TEXTURE_2D);
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_image);
    glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect);
    glDrawTexiOES (0, 0, 0, 256, 256);

  8. #8
    Junior Member
    Join Date
    Dec 2008
    Location
    Oslo, Norway
    Posts
    25

    Re: How can I use glDrawTexOES()

    Quote Originally Posted by Newbie
    I followed the above discussion, but i still see a blank screen.
    Am i missing something in the below code?
    I can at least tell that you're texturing with an incomplete texture. The default min-filter for a texture object requires mipmaps, and you only upload the base-level. This means that the texturing stage is disabled. Usually, this leads to a draw-call only drawing fragments of a constant color, but might differ based on a lot of different state.
    Erik "kusma" Faye-Lund

Similar Threads

  1. glDrawTexOES
    By akhil in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 08-20-2007, 03:30 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
  •