Initial commit
This commit is contained in:
179
application/demos/example.opengl/engine/windowManager.c
Normal file
179
application/demos/example.opengl/engine/windowManager.c
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* This file is automaticaly generated, Please dont edit this file!
|
||||
*/
|
||||
#include <engine/windowManager.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int DoubleBufferAttributes[] = {
|
||||
GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_DEPTH_SIZE, 12,
|
||||
GLX_DOUBLEBUFFER,
|
||||
None,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void windowManager_setupDisplay( windowManager * this ) {
|
||||
|
||||
this->mainDisplay = XOpenDisplay( 0 );
|
||||
|
||||
this->MainScreen = XDefaultScreen( this->mainDisplay );
|
||||
|
||||
}
|
||||
|
||||
void windowManager_setupWindow( windowManager * this ) {
|
||||
|
||||
|
||||
this->RootWindow = XDefaultRootWindow( this->mainDisplay );
|
||||
|
||||
|
||||
int empty;
|
||||
|
||||
int ResultStatus = glXQueryExtension( this->mainDisplay, &empty, &empty );
|
||||
|
||||
XVisualInfo* VisualInfo = glXChooseVisual( this->mainDisplay, this->MainScreen, DoubleBufferAttributes );
|
||||
|
||||
GLXContext ShareList = None;
|
||||
|
||||
int IsDirectRendering = True;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GLXContext OpenGLContext = glXCreateContext( this->mainDisplay, VisualInfo, ShareList, IsDirectRendering );
|
||||
|
||||
|
||||
|
||||
int WindowX = 0;
|
||||
|
||||
int WindowY = 0;
|
||||
|
||||
int WindowWidth = 1000;
|
||||
|
||||
int WindowHeight = 1024;
|
||||
|
||||
int BorderWidth = 0;
|
||||
|
||||
int WindowClass = InputOutput;
|
||||
|
||||
int WindowDepth = VisualInfo->depth;
|
||||
|
||||
|
||||
Visual* WindowVisual = VisualInfo->visual;
|
||||
|
||||
int AttributeValueMask = CWBackPixel | CWEventMask | CWColormap;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
XSetWindowAttributes WindowAttributes = {};
|
||||
|
||||
WindowAttributes.colormap = XCreateColormap( this->mainDisplay, this->RootWindow, VisualInfo->visual, AllocNone );
|
||||
|
||||
|
||||
|
||||
WindowAttributes.background_pixel = 0;
|
||||
|
||||
|
||||
WindowAttributes.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask | PointerMotionMask;
|
||||
|
||||
this->mainWindow = XCreateWindow( this->mainDisplay, this->RootWindow,
|
||||
WindowX, WindowY, WindowWidth, WindowHeight,
|
||||
BorderWidth, WindowDepth, WindowClass, WindowVisual,
|
||||
AttributeValueMask, &WindowAttributes);
|
||||
|
||||
|
||||
|
||||
|
||||
XMoveWindow( this->mainDisplay, this->mainWindow, -400, 0 );
|
||||
|
||||
XStoreName( this->mainDisplay, this->mainWindow, "Opengl: Fixed function pipeline" );
|
||||
|
||||
glXMakeCurrent( this->mainDisplay, this->mainWindow, OpenGLContext );
|
||||
|
||||
XMapWindow( this->mainDisplay, this->mainWindow );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Atom WM_DELETE_WINDOW = XInternAtom( this->mainDisplay, "WM_DELETE_WINDOW", False );
|
||||
|
||||
|
||||
if( !XSetWMProtocols( this->mainDisplay, this->mainWindow, &WM_DELETE_WINDOW, 1) ) {
|
||||
|
||||
printf( "Couldn't register WM_DELETE_WINDOW\n" );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
windowManager windowManager_new() {
|
||||
|
||||
windowManager instance;
|
||||
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
windowManager * windowManager_newPointer() {
|
||||
|
||||
struct windowManager * pointer = malloc( sizeof ( struct windowManager ) );
|
||||
|
||||
return pointer;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user