JNR
fxShutter.cpp
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 
30 #include "stdafx.h"
31 #include "Core.h"
32 
33 fxShutter::fxShutter(void)
34 {
35  _bOn = M_FALSE;
36 
37  parameters();
38 }
39 
40 fxShutter::~fxShutter(void)
41 {
42 }
43 
44 void fxShutter::animate(laTimer &t)
45 {
46  if( (_tt.reminder() > 0.5) || (!_bOn) ) _tt.animate(t);
47 }
48 
49 #include <GL\GL.h>
50 void fxShutter::draw(laRenderer *r, laPoint3 pos)
51 {
52  PROFILE_REN(fxShutter_draw);
53 
54  double w = laSystemIntegrator::getSettings()->graphics_resolution_w;
55  double h = laSystemIntegrator::getSettings()->graphics_resolution_h;
56  double progress;
57  double alpha, size;
58 
59  if( _tt.reminder()>0.5 )
60  progress = 1 - 1*( _tt.reminder()-0.5 )*2;
61  else
62  progress = 1*( _tt.reminder() )*2;
63 
64  alpha = _color[3]* progress;
65  size = _bCinematic ? 100 * progress : 0;
66 
67  if(_bCinematic || _bCharacterEmphasis)
68  {
69  glEnable(GL_STENCIL_TEST);
70  glStencilFunc(GL_NOTEQUAL, 1/*p.id*/, 0xFFF /*-1*/);
71  glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
72  }
73 
74  r->modeDepthBuffer(M_FALSE);
75  r->modeTexture(M_FALSE);
76 
77  r->vquadsMakeXYRect(0,laPoint3(0, size), laPoint3(w, h-2*size), laPoint2(), laPoint2());
78  r->styleSet( laColor(_color.r(), _color.g(), _color.b(), (unsigned char)alpha) );
79  r->vquadsDrawSingle();
80 
81  if(_bCinematic)
82  {
83  r->vquadsMakeXYRect(0, laPoint3(), laPoint3(w, size), laPoint2(), laPoint2());
84  r->vquadsMakeXYRect(1, laPoint3(0, h-size), laPoint3(w, size), laPoint2(), laPoint2());
85 
86  r->styleSet( laColor(0, 0, 0, 255) );
87  r->vquadsDraw(2);
88  }
89 
90  if(_bCinematic || _bCharacterEmphasis) glDisable(GL_STENCIL_TEST);
91 }
virtual void modeTexture(M_BOOL bOn)=0
Enable/disable texturing.
virtual void vquadsDrawSingle(laPoint2 *ar_uv=NULL)=0
Draw a single VQ (Note this is slower than drawing an array of VQ and should be avoided) ...
2D Point
Definition: laPoint_novec.h:41
void vquadsMakeXYRect(unsigned nIndex, const laPoint3 &pos, const laPoint3 &sz, const laPoint2 &uv, const laPoint2 &uv_sz)
Makes a quad aligned to the XY plane; (handy for GUI rendering )
Definition: laRenderer.h:328
virtual void vquadsDraw(unsigned nQuads, laPoint2 *ar_uv=NULL, laColor *ar_color=NULL, M_BOOL bBillboards=M_FALSE, M_BOOL bUseColorArrays=M_FALSE)=0
Draw an array of VQ, starting with the psecified pointers (or the first VQ if null) ...
virtual void modeDepthBuffer(M_BOOL bOn)=0
Enable/disable depth buffer.
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98