GteWindow2.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <GTWindows.h>
12 
13 // The 2D application support is for GTEngine samples and is not a
14 // general-purpose 2D windowing layer. The window resizing is disabled
15 // to avoid the complications of resizing the overlay texture and
16 // redrawing objects that were initially defined in the original window
17 // coordinates.
18 
19 namespace gte
20 {
21 
22 class GTE_IMPEXP Window2 : public Window
23 {
24 protected:
25  // Abstract base class. The window creation requires parameters.allowResize
26  // to be 'false'; otherwise, the creation fails.
27  Window2(Parameters& parameters);
28 
29 public:
30  // Display functions. The OnResize function always returns 'false';
31  // that is, you cannot resize the window. The DrawScreenOverlay function
32  // is called after the screen texture is drawn but before the swap-buffers
33  // call is made. This allows you to draw text or GUI elements on top of
34  // the screen texture.
35  virtual bool OnResize(int xSize, int ySize) override;
36  virtual void OnDisplay() override;
37  virtual void DrawScreenOverlay();
38 
39  // Drawing functions. Each color is packed as R8G8B8A8 with the alpha
40  // channel the most significant bits and red the least significant bits.
41  // For example, (r,g,b,a) = (1,2,3,4) is 0x04030201.
42 
43  // Set all pixels to the specified color.
44  void ClearScreen(unsigned int color);
45 
46  // Set the pixel at location (x,y) to the specified color.
47  void SetPixel(int x, int y, unsigned int color);
48 
49  // Get the pixel color at location (x,y).
50  unsigned int GetPixel(int x, int y);
51 
52  // Set the pixels (x',y') for x-thick <= x' <= x+thick and
53  // y-thick <= y' <= y+thick.
54  void DrawThickPixel(int x, int y, int thick, unsigned int color);
55 
56  // Use Bresenham's algorithm to draw the line from (x0,y0) to (x1,y1)
57  // using the specified color for the drawn pixels. The algorithm is
58  // biased in that the pixels set by DrawLine(x0,y0,x1,y1) are not
59  // necessarily the same as those set by DrawLine(x1,y1,x0,y0).
60  // TODO: Implement the midpoint algorithm to avoid the bias.
61  void DrawLine(int x0, int y0, int x1, int y1, unsigned int color);
62 
63  // Draw an axis-aligned rectangle using the specified color. The
64  // 'solid' parameter indicates whether or not to fill the rectangle.
65  void DrawRectangle(int xMin, int yMin, int xMax, int yMax, unsigned int color, bool solid);
66 
67  // Use Bresenham's algorithm to draw the circle centered at
68  // (xCenter,yCenter) with the specified 'radius' and using the
69  // specified color. The 'solid' parameter indicates whether or not
70  // to fill the circle.
71  void DrawCircle(int xCenter, int yCenter, int radius, unsigned int color, bool solid);
72 
73  // Use Bresenham's algorithm to draw the axis-aligned ellipse
74  // ((x-xc)/a)^2 + ((y-yc)/b)^2 = 1, where xCenter is xc, yCenter is yc,
75  // xExtent is a, and yExtent is b.
76  void DrawEllipse(int xCenter, int yCenter, int xExtent, int yExtent, unsigned int color);
77 
78  // Flood-fill a region whose pixels are of color 'backColor' by
79  // changing their color to 'foreColor'. The fill treats the screen
80  // as 4-connected; that is, after (x,y) is visited, then (x-1,y),
81  // (x+1,y), (x,y-1), and (x,y+1) are visited (as long as they are in
82  // the screen boundary). The function simulates recursion by using
83  // stacks, which avoids the expense of true recursion and the potential
84  // to overflow the calling stack.
85  void DrawFloodFill4(int x, int y, unsigned int foreColor, unsigned int backColor);
86 
87 protected:
88  std::shared_ptr<OverlayEffect> mOverlay;
89  std::shared_ptr<Texture2> mScreenTexture;
90  std::shared_ptr<DepthStencilState> mNoDepthStencilState;
91  std::function<void(int, int)> mDrawPixel;
92  unsigned int mPixelColor;
94  bool mDoFlip;
96 };
97 
98 }
GLuint color
Definition: glcorearb.h:1256
GLint GLenum GLint x
Definition: glcorearb.h:404
bool mDoFlip
Definition: GteWindow2.h:94
std::shared_ptr< Texture2 > mScreenTexture
Definition: GteWindow2.h:89
std::function< void(int, int)> mDrawPixel
Definition: GteWindow2.h:91
unsigned int mPixelColor
Definition: GteWindow2.h:92
GLfixed y1
Definition: glext.h:4952
std::shared_ptr< DepthStencilState > mNoDepthStencilState
Definition: GteWindow2.h:90
bool mClampToWindow
Definition: GteWindow2.h:93
bool mScreenTextureNeedsUpdate
Definition: GteWindow2.h:95
GLuint GLfloat x0
Definition: glext.h:9013
std::shared_ptr< OverlayEffect > mOverlay
Definition: GteWindow2.h:88
GLuint GLfloat GLfloat GLfloat x1
Definition: glext.h:9013
GLuint GLfloat GLfloat y0
Definition: glext.h:9013
GLint y
Definition: glcorearb.h:98
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:02