本文整理汇总了C++中WindowApplication::GetYPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowApplication::GetYPosition方法的具体用法?C++ WindowApplication::GetYPosition怎么用?C++ WindowApplication::GetYPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindowApplication
的用法示例。
在下文中一共展示了WindowApplication::GetYPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Main
//----------------------------------------------------------------------------
int WindowApplication::Main (int numArguments, char** arguments)
{
// Initialize the extra data. TODO: Port the extra-data system of WM4
// to WM5.
memset(gsExtraData, 0, APP_EXTRA_DATA_QUANTITY*sizeof(char));
WindowApplication* theApp = (WindowApplication*)TheApplication;
theApp->KEY_TERMINATE = KEY_ESCAPE;
// OpenGL uses a projection matrix for depth in [-1,1].
Camera::SetDefaultDepthType(Camera::PM_DEPTH_MINUS_ONE_TO_ONE);
// Allow work to be done before the window is created.
if (!theApp->OnPrecreate())
{
return -1;
}
// Connect to the X server.
const char* displayName = 0;
Display* display = XOpenDisplay(displayName);
if (!display)
{
return -2;
}
// Make sure the X server has OpenGL GLX extensions.
int errorBase, eventBase;
Bool success = glXQueryExtension(display, &errorBase, &eventBase);
assertion(success == True, "GLX extensions not found.\n");
if (!success)
{
return -3;
}
// Partial construction of a GLX renderer. The window for the renderer
// is not yet constructed. When it is, the window identifier is supplied
// to the renderer to complete its construction.
RendererInput input;
input.mDisplay = display;
input.mVisual = 0;
input.mContext = 0;
mRenderer = new0 Renderer(input, theApp->GetWidth(), theApp->GetHeight(),
mColorFormat, mDepthStencilFormat, mNumMultisamples);
if (!input.mVisual || !input.mContext)
{
return -4;
}
// Create an X Window with the visual information created by the renderer
// constructor. The visual information might not be the default, so
// create an X colormap to use.
Window rootWindow = RootWindow(display, input.mVisual->screen);
Colormap cMap = XCreateColormap(display, rootWindow,
input.mVisual->visual, AllocNone);
// Set the event mask to include exposure (paint), button presses (mouse),
// and key presses (keyboard).
XSetWindowAttributes windowAttributes;
windowAttributes.colormap = cMap;
windowAttributes.border_pixel = 0;
windowAttributes.event_mask =
ButtonPressMask |
ButtonReleaseMask |
PointerMotionMask |
Button1MotionMask |
Button2MotionMask |
Button3MotionMask |
KeyPressMask |
KeyReleaseMask |
ExposureMask |
StructureNotifyMask;
int xPos = theApp->GetXPosition();
int yPos = theApp->GetYPosition();
unsigned int width = (unsigned int)theApp->GetWidth();
unsigned int height = (unsigned int)theApp->GetHeight();
unsigned int borderWidth = 0;
unsigned long valueMask = CWBorderPixel | CWColormap | CWEventMask;
Window window = XCreateWindow(display, rootWindow, xPos, yPos, width,
height, borderWidth, input.mVisual->depth, InputOutput,
input.mVisual->visual, valueMask, &windowAttributes);
XSizeHints hints;
hints.flags = PPosition | PSize;
hints.x = xPos;
hints.y = yPos;
hints.width = width;
hints.height = height;
XSetNormalHints(display, window, &hints);
const char* iconName = theApp->GetWindowTitle();
Pixmap iconPixmap = None;
XSetStandardProperties(display, window, theApp->GetWindowTitle(),
iconName, iconPixmap, arguments, numArguments, &hints);
// Intercept the close-window event when the user selects the
// window close button. The event is a "client message".
Atom wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", False);
//.........这里部分代码省略.........
示例2: Main
//----------------------------------------------------------------------------
int WindowApplication::Main (int, char**)
{
WindowApplication* theApp = (WindowApplication*)TheApplication;
theApp->KEY_TERMINATE = WindowApplication::KEY_ESCAPE;
#ifdef WM5_USE_DX9
// DirectX uses a projection matrix for depth in [0,1].
Camera::SetDefaultDepthType(Camera::PM_DEPTH_ZERO_TO_ONE);
#endif
#ifdef WM5_USE_OPENGL
// OpenGL uses a projection matrix for depth in [-1,1].
Camera::SetDefaultDepthType(Camera::PM_DEPTH_MINUS_ONE_TO_ONE);
#endif
// Allow work to be done before the window is created.
if (!theApp->OnPrecreate())
{
return -1;
}
// === Create the window for rendering. ===
// Register the window class.
static char sWindowClass[] = "Wild Magic 5 Application";
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = MsWindowEventHandler;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = 0;
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszClassName = sWindowClass;
wc.lpszMenuName = 0;
RegisterClass(&wc);
DWORD dwStyle;
if (mAllowResize)
{
dwStyle = WS_OVERLAPPEDWINDOW;
}
else
{
// This removes WS_THICKFRAME and WS_MAXIMIZEBOX, both of which allow
// resizing of windows.
dwStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
}
// Require the window to have the specified client area.
RECT rect = { 0, 0, theApp->GetWidth()-1, theApp->GetHeight()-1 };
AdjustWindowRect(&rect, dwStyle, FALSE);
// Create the application window.
HWND handle = CreateWindow(sWindowClass, theApp->GetWindowTitle(),
dwStyle, theApp->GetXPosition(), theApp->GetYPosition(),
rect.right - rect.left + 1, rect.bottom - rect.top + 1, 0, 0, 0, 0);
// Save the handle as an 'int' for portable handle storage.
theApp->SetWindowID(PtrToInt(handle));
// ===
#ifdef WM5_USE_DX9
// Create the device for rendering.
RendererInput input;
input.mWindowHandle = handle;
input.mDriver = Direct3DCreate9(D3D_SDK_VERSION);
assertion(input.mDriver != 0, "Failed to create Direct3D9\n");
mRenderer = new0 Renderer(input, theApp->GetWidth(), theApp->GetHeight(),
mColorFormat, mDepthStencilFormat, mNumMultisamples);
#endif
#ifdef WM5_USE_OPENGL
// The pixelFormat variable is used to support creation of a window that
// supports multisampling. This process requires creating a normal window,
// and then querying whether the renderer supports multisampling. The
// renderer creates a device context for the window which we then need to
// create a second window that supports multisampling. The device context
// rendererDC is set by the renderer during the process.
RendererInput input;
input.mWindowHandle = handle;
input.mPixelFormat = 0;
input.mRendererDC = 0;
input.mDisableVerticalSync = true;
mRenderer = new0 Renderer(input, theApp->GetWidth(), theApp->GetHeight(),
mColorFormat, mDepthStencilFormat, mNumMultisamples);
// To determine whether multisampling is supported, it is necessary to
// create a window, an OpenGL context, and query the driver for the
// multisampling extensions. If it is, a new window must be created
// because the renderer creation involves SetPixelFormat(...) that can
// be called only once for a window.
int numMultisamples = mRenderer->GetNumMultisamples();
if (numMultisamples > 0)
{
int attributes[256], pos = 0;
attributes[pos++] = WGL_SUPPORT_OPENGL_ARB;
//.........这里部分代码省略.........