Results 1 to 6 of 6

Thread: Ortho ?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Aug 2009
    Posts
    126

    Ortho ?

    Hi, I'm using glOrtho to setup my Screen.

    So how can I set which objects are drawn in front of others ?

    And how can I set which color should be the transparent color ?
    That must be magenta...

    Please help!!


    ^^


  2. #2
    Senior Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008
    Location
    Thailand
    Posts
    555

    Re: Ortho ?

    Not sure what you are actually doing as you don't provide details.. Is this a HUD type Ortho view or are you dealing with lots of sprites?

    In any case I would suggest sorting your objects back to front and then drawing them in that order with depth testing off.

    Also can you elaborate more on what your transparent colour is doing?

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Ortho ?

    A tutorial for single color masking :
    http://jerome.jouvie.free.fr/OpenGl/...Tutorial21.php
    This should explain the basics.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Aug 2009
    Posts
    126

    Re: Ortho ?

    I am working with C++.

    I just want to know how I can make, that all magenta pixels of my (3D)sprites are transparent. I'am loading BMPs, but others would also be OK.


    ^^


  5. #5
    Member Contributor
    Join Date
    Jul 2009
    Location
    Buenos Aires
    Posts
    67

    Re: Ortho ?

    That is called chroma-keying and as far as I know OpenGL has no built-in support for it. You should expand your texture by adding an alpha channel, and set alpha to be 1 (255) everywhere and 0 on the pixels that are magenta. I would consider also replacing magenta with black to avoid artifacts when textures are filtered, otherwise you'll get magenta borders.

    Finally you have to enable alpha blending before rendering your transparent sprites:

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

    // Draw transparent sprites

    glDisable(GL_BLEND);

  6. #6
    Senior Member Regular Contributor
    Join Date
    Aug 2009
    Posts
    126

    Re: Ortho ?

    Thanks, solved it.
    Now using PNGs.


    ^^


Similar Threads

  1. Replies: 2
    Last Post: 06-06-2015, 07:35 AM
  2. ortho + perspective + ortho
    By mithun_daa in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-09-2004, 07:54 AM
  3. getting the Ortho
    By satya in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-28-2004, 10:36 AM
  4. getting the Ortho
    By satya in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 04-21-2004, 08:38 PM
  5. Ortho help!
    By pran1 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-29-2004, 04:45 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