~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "KX_BlenderCanvas.h"
34
34
#include "DNA_screen_types.h"
35
35
#include <stdio.h>
 
36
#include <assert.h>
36
37
 
37
38
 
38
39
KX_BlenderCanvas::KX_BlenderCanvas(struct wmWindow *win, RAS_Rect &rect, struct ARegion *ar) :
44
45
        // area boundaries needed for mouse coordinates in Letterbox framing mode
45
46
        m_area_left = ar->winrct.xmin;
46
47
        m_area_top = ar->winrct.ymax;
 
48
 
 
49
        glGetIntegerv(GL_VIEWPORT, (GLint *)m_viewport);
47
50
}
48
51
 
49
52
KX_BlenderCanvas::~KX_BlenderCanvas()
53
56
void KX_BlenderCanvas::Init()
54
57
{
55
58
        glDepthFunc(GL_LEQUAL);
56
 
}       
 
59
}
57
60
 
58
61
 
59
62
void KX_BlenderCanvas::SwapBuffers()
116
119
 
117
120
int KX_BlenderCanvas::GetMouseX(int x)
118
121
{
119
 
        float left = GetWindowArea().GetLeft();
120
 
        return float(x - (left - m_area_left));
 
122
        int left = GetWindowArea().GetLeft();
 
123
        return x - (left - m_area_left);
121
124
}
122
125
 
123
126
int KX_BlenderCanvas::GetMouseY(int y)
124
127
{
125
 
        float top = GetWindowArea().GetTop();
126
 
        return float(y - (m_area_top - top));
 
128
        int top = GetWindowArea().GetTop();
 
129
        return y - (m_area_top - top);
127
130
}
128
131
 
129
132
float KX_BlenderCanvas::GetMouseNormalizedX(int x)
143
146
GetWindowArea(
144
147
) {
145
148
        return m_area_rect;
146
 
}       
 
149
}
147
150
 
148
151
        void
149
152
KX_BlenderCanvas::
151
154
        int x1, int y1,
152
155
        int x2, int y2
153
156
) {
154
 
        /*      x1 and y1 are the min pixel coordinate (e.g. 0)
155
 
                x2 and y2 are the max pixel coordinate
156
 
                the width,height is calculated including both pixels
157
 
                therefore: max - min + 1
158
 
        */
 
157
        /* x1 and y1 are the min pixel coordinate (e.g. 0)
 
158
         * x2 and y2 are the max pixel coordinate
 
159
         * the width,height is calculated including both pixels
 
160
         * therefore: max - min + 1
 
161
         */
159
162
        int vp_width = (x2 - x1) + 1;
160
163
        int vp_height = (y2 - y1) + 1;
161
164
        int minx = m_frame_rect.GetLeft();
166
169
        m_area_rect.SetRight(minx + x2);
167
170
        m_area_rect.SetTop(miny + y2);
168
171
 
 
172
        m_viewport[0] = minx+x1;
 
173
        m_viewport[1] = miny+y1;
 
174
        m_viewport[2] = vp_width;
 
175
        m_viewport[3] = vp_height;
 
176
 
169
177
        glViewport(minx + x1, miny + y1, vp_width, vp_height);
170
178
        glScissor(minx + x1, miny + y1, vp_width, vp_height);
171
179
}
172
180
 
 
181
        void
 
182
KX_BlenderCanvas::
 
183
UpdateViewPort(
 
184
        int x1, int y1,
 
185
        int x2, int y2
 
186
) {
 
187
        m_viewport[0] = x1;
 
188
        m_viewport[1] = y1;
 
189
        m_viewport[2] = x2;
 
190
        m_viewport[3] = y2;
 
191
}
 
192
 
 
193
        const int*
 
194
KX_BlenderCanvas::
 
195
GetViewPort() {
 
196
#ifdef DEBUG
 
197
        // If we're in a debug build, we might as well make sure our values don't differ
 
198
        // from what the gpu thinks we have. This could lead to nasty, hard to find bugs.
 
199
        int viewport[4];
 
200
        glGetIntegerv(GL_VIEWPORT, viewport);
 
201
        assert(viewport[0] == m_viewport[0]);
 
202
        assert(viewport[1] == m_viewport[1]);
 
203
        assert(viewport[2] == m_viewport[2]);
 
204
        assert(viewport[3] == m_viewport[3]);
 
205
#endif
 
206
 
 
207
        return m_viewport;
 
208
}
173
209
 
174
210
void KX_BlenderCanvas::SetMouseState(RAS_MouseState mousestate)
175
211
{