Skip to content

Commit

Permalink
Added DGL_Scissor alternative with the region specified as RectRaw
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jan 28, 2012
1 parent 980234f commit 775c95f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
7 changes: 6 additions & 1 deletion doomsday/engine/api/dd_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ float DGL_GetFloat(int name);
boolean DGL_SetFloat(int name, float value);

void DGL_Ortho(float left, float top, float right, float bottom, float znear, float zfar);
void DGL_Scissor(int x, int y, int width, int height);

/**
* @note Coordinates are in viewport space.
*/
void DGL_Scissor(const RectRaw* rect);
void DGL_Scissor2(int x, int y, int width, int height);

void DGL_MatrixMode(int mode);
void DGL_PushMatrix(void);
Expand Down
3 changes: 2 additions & 1 deletion doomsday/engine/api/doomsday.def
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,8 @@ EXPORTS
DGL_PopMatrix @361 NONAME
DGL_LoadIdentity @362 NONAME
DGL_Ortho @390 NONAME
DGL_Scissor @404 NONAME
DGL_Scissor @340 NONAME
DGL_Scissor2 @404 NONAME
DGL_Bind @396 NONAME
DGL_DeleteTextures @403 NONAME
DGL_Begin @363 NONAME
Expand Down
21 changes: 16 additions & 5 deletions doomsday/engine/portable/src/dgl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,26 @@ void GL_SetMultisample(boolean on)
#endif
}

void DGL_Scissor(int x, int y, int width, int height)
void DGL_Scissor(const RectRaw* rect)
{
glScissor(x, FLIP(y + height - 1), width, height);
if(!rect) return;
glScissor(rect->origin.x, FLIP(rect->origin.y + rect->size.height - 1), rect->size.width, rect->size.height);
}

boolean DGL_GetIntegerv(int name, int *v)
void DGL_Scissor2(int x, int y, int width, int height)
{
int i;
float color[4];
RectRaw rect;
rect.origin.x = x;
rect.origin.y = y;
rect.size.width = width;
rect.size.height = height;
DGL_Scissor(&rect);
}

boolean DGL_GetIntegerv(int name, int* v)
{
float color[4];
int i;

switch(name)
{
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/portable/src/gl_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void GL_BeginBorderedProjection(borderedprojectionstate_t* bp)
int w = .5f + (bp->availWidth - bp->width * bp->scaleFactor) / 2;
DGL_GetIntegerv(DGL_SCISSOR_TEST, bp->scissorState);
DGL_GetIntegerv(DGL_SCISSOR_BOX, bp->scissorState + 1);
DGL_Scissor(w, 0, bp->width * bp->scaleFactor, bp->availHeight);
DGL_Scissor2(w, 0, bp->width * bp->scaleFactor, bp->availHeight);
DGL_Enable(DGL_SCISSOR_TEST);
}

Expand All @@ -402,7 +402,7 @@ void GL_BeginBorderedProjection(borderedprojectionstate_t* bp)
int h = .5f + (bp->availHeight - bp->height * bp->scaleFactor) / 2;
DGL_GetIntegerv(DGL_SCISSOR_TEST, bp->scissorState);
DGL_GetIntegerv(DGL_SCISSOR_BOX, bp->scissorState + 1);
DGL_Scissor(0, h, bp->availWidth, bp->height * bp->scaleFactor);
DGL_Scissor2(0, h, bp->availWidth, bp->height * bp->scaleFactor);
DGL_Enable(DGL_SCISSOR_TEST);
}

Expand Down Expand Up @@ -433,7 +433,7 @@ void GL_EndBorderedProjection(borderedprojectionstate_t* bp)
{
if(!bp->scissorState[0])
DGL_Disable(DGL_SCISSOR_TEST);
DGL_Scissor(bp->scissorState[1], bp->scissorState[2], bp->scissorState[3], bp->scissorState[4]);
DGL_Scissor2(bp->scissorState[1], bp->scissorState[2], bp->scissorState[3], bp->scissorState[4]);
}

if(bp->flags & BPF_OVERDRAW_MASK)
Expand Down

0 comments on commit 775c95f

Please sign in to comment.