4 Replies - 684 Views - Last Post: 13 August 2012 - 01:08 AM Rate Topic: -----

#1 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,149
  • Joined: 07-September 06

OpenGL masking

Posted 08 August 2012 - 05:38 PM

I am currently attempting to create a window-style system in OpenGL and am having trouble masking the portions of the windows I am creating.

Basically, I don't want a window to be able to draw anything outside of its rectangle (specified by an x, y, width and height). I figured the best way to accomplish this would be to mask the section that I am drawing so only things within the masked region are visible.

I found this tutorial online:
http://nehe.gamedev..../masking/15006/

It goes over the basics of masking (blending) and how it works, but appears to be used more as a blending method than a masking ont. I have (at this point) been unable to get it working with simply removing anything outside of a box.

The code I am using is, at this point, fairly similar to that provided by the tutorial (I can post it later, it is on a different machine), but it appears to do an additive blending between the colors which isn't what I am going for.

I figure that this is probably an easy problem to get around if you know what you are doing, but I haven't figured it out as of yet. So any thoughts would be appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: OpenGL masking

#2 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 999
  • View blog
  • Posts: 4,177
  • Joined: 14-February 08

Re: OpenGL masking

Posted 09 August 2012 - 01:15 AM

Have you thought about using the stencil buffer? It will probably work for what you want to do.
Was This Post Helpful? 1
  • +
  • -

#3 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,149
  • Joined: 07-September 06

Re: OpenGL masking

Posted 10 August 2012 - 06:21 AM

Okay, thanks. It figures that there would be a different name for it in OpenGL than what the rest of the graphics world uses. I'll look into that.
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,149
  • Joined: 07-September 06

Re: OpenGL masking

Posted 12 August 2012 - 04:47 PM

Update: It took quite a while to find an example that actually appeared to work, but I finally found one with a nice explanation:
http://en.wikibooks..../Stencil_buffer

It went through and cut my framerate in half for only stenciling three "windows" per frame, but it works nicely and has the desired effect.
Was This Post Helpful? 0
  • +
  • -

#5 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 999
  • View blog
  • Posts: 4,177
  • Joined: 14-February 08

Re: OpenGL masking

Posted 13 August 2012 - 01:08 AM

Awesome, nice work! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1