GODOT IS OPEN SOURCE
This commit is contained in:
parent
0e49da1687
commit
0b806ee0fc
3138 changed files with 1294441 additions and 0 deletions
13
platform/x11/SCsub
Normal file
13
platform/x11/SCsub
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Import('env')
|
||||
|
||||
|
||||
common_x11=[\
|
||||
"context_gl_x11.cpp",\
|
||||
"os_x11.cpp",\
|
||||
"key_mapping_x11.cpp",\
|
||||
]
|
||||
|
||||
if env["target"]=="release":
|
||||
env.Program('#bin/godot_rel',['godot_x11.cpp']+common_x11)
|
||||
else:
|
||||
env.Program('#bin/godot',['godot_x11.cpp']+common_x11)
|
||||
197
platform/x11/context_gl_x11.cpp
Normal file
197
platform/x11/context_gl_x11.cpp
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
/*************************************************************************/
|
||||
/* context_gl_x11.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "context_gl_x11.h"
|
||||
|
||||
#ifdef X11_ENABLED
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <GL/glx.h>
|
||||
|
||||
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
|
||||
typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
|
||||
|
||||
struct ContextGL_X11_Private {
|
||||
|
||||
::GLXContext glx_context;
|
||||
};
|
||||
|
||||
|
||||
void ContextGL_X11::release_current() {
|
||||
|
||||
glXMakeCurrent(x11_display, None, NULL);
|
||||
}
|
||||
|
||||
void ContextGL_X11::make_current() {
|
||||
|
||||
glXMakeCurrent(x11_display, x11_window, p->glx_context);
|
||||
}
|
||||
void ContextGL_X11::swap_buffers() {
|
||||
|
||||
glXSwapBuffers(x11_display,x11_window);
|
||||
}
|
||||
/*
|
||||
static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) {
|
||||
|
||||
//print_line(String()+"getting proc of: "+p_function);
|
||||
GLWrapperFuncPtr func=(GLWrapperFuncPtr)glXGetProcAddress( (const GLubyte*) p_function);
|
||||
if (!func) {
|
||||
print_line("Couldn't find function: "+String(p_function));
|
||||
}
|
||||
|
||||
return func;
|
||||
|
||||
}*/
|
||||
|
||||
Error ContextGL_X11::initialize() {
|
||||
|
||||
|
||||
GLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = NULL;
|
||||
|
||||
// const char *extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
|
||||
|
||||
glXCreateContextAttribsARB = (GLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
|
||||
|
||||
ERR_FAIL_COND_V( !glXCreateContextAttribsARB, ERR_UNCONFIGURED );
|
||||
|
||||
|
||||
static int visual_attribs[] = {
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
|
||||
GLX_DOUBLEBUFFER, true,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_DEPTH_SIZE,0,
|
||||
None
|
||||
};
|
||||
|
||||
int fbcount;
|
||||
GLXFBConfig *fbc = glXChooseFBConfig(x11_display, DefaultScreen(x11_display), visual_attribs, &fbcount);
|
||||
ERR_FAIL_COND_V(!fbc,ERR_UNCONFIGURED);
|
||||
|
||||
XVisualInfo *vi = glXGetVisualFromFBConfig(x11_display, fbc[0]);
|
||||
|
||||
XSetWindowAttributes swa;
|
||||
|
||||
swa.colormap = XCreateColormap(x11_display, RootWindow(x11_display, vi->screen), vi->visual, AllocNone);
|
||||
swa.border_pixel = 0;
|
||||
swa.event_mask = StructureNotifyMask;
|
||||
|
||||
/*
|
||||
char* windowid = getenv("GODOT_WINDOWID");
|
||||
if (windowid) {
|
||||
|
||||
//freopen("/home/punto/stdout", "w", stdout);
|
||||
//reopen("/home/punto/stderr", "w", stderr);
|
||||
x11_window = atol(windowid);
|
||||
} else {
|
||||
*/
|
||||
x11_window = XCreateWindow(x11_display, RootWindow(x11_display, vi->screen), 0, 0, OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel|CWColormap|CWEventMask, &swa);
|
||||
ERR_FAIL_COND_V(!x11_window,ERR_UNCONFIGURED);
|
||||
XMapWindow(x11_display, x11_window);
|
||||
while(true) {
|
||||
// wait for mapnotify (window created)
|
||||
XEvent e;
|
||||
XNextEvent(x11_display, &e);
|
||||
if (e.type == MapNotify)
|
||||
break;
|
||||
}
|
||||
//};
|
||||
|
||||
if (!opengl_3_context) {
|
||||
//oldstyle context:
|
||||
p->glx_context = glXCreateContext(x11_display, vi, 0, GL_TRUE);
|
||||
} else {
|
||||
static int context_attribs[] = {
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||
None
|
||||
};
|
||||
|
||||
p->glx_context = glXCreateContextAttribsARB(x11_display, fbc[0], NULL, true, context_attribs);
|
||||
ERR_FAIL_COND_V(!p->glx_context,ERR_UNCONFIGURED);
|
||||
}
|
||||
|
||||
glXMakeCurrent(x11_display, x11_window, p->glx_context);
|
||||
|
||||
/*
|
||||
glWrapperInit(wrapper_get_proc_address);
|
||||
glFlush();
|
||||
|
||||
glXSwapBuffers(x11_display,x11_window);
|
||||
*/
|
||||
//glXMakeCurrent(x11_display, None, NULL);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ContextGL_X11::get_window_width() {
|
||||
|
||||
XWindowAttributes xwa;
|
||||
XGetWindowAttributes(x11_display,x11_window,&xwa);
|
||||
|
||||
return xwa.width;
|
||||
}
|
||||
int ContextGL_X11::get_window_height() {
|
||||
XWindowAttributes xwa;
|
||||
XGetWindowAttributes(x11_display,x11_window,&xwa);
|
||||
|
||||
return xwa.height;
|
||||
|
||||
}
|
||||
|
||||
|
||||
ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,const OS::VideoMode& p_default_video_mode,bool p_opengl_3_context) : x11_window(p_x11_window) {
|
||||
|
||||
default_video_mode=p_default_video_mode;
|
||||
x11_display=p_x11_display;
|
||||
|
||||
opengl_3_context=p_opengl_3_context;
|
||||
|
||||
double_buffer=false;
|
||||
direct_render=false;
|
||||
glx_minor=glx_major=0;
|
||||
p = memnew( ContextGL_X11_Private );
|
||||
p->glx_context=0;
|
||||
}
|
||||
|
||||
|
||||
ContextGL_X11::~ContextGL_X11() {
|
||||
|
||||
memdelete( p );
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
76
platform/x11/context_gl_x11.h
Normal file
76
platform/x11/context_gl_x11.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*************************************************************************/
|
||||
/* context_gl_x11.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifndef CONTEXT_GL_X11_H
|
||||
#define CONTEXT_GL_X11_H
|
||||
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
*/
|
||||
#ifdef X11_ENABLED
|
||||
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
|
||||
|
||||
|
||||
|
||||
#include "os/os.h"
|
||||
#include "drivers/gl_context/context_gl.h"
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
struct ContextGL_X11_Private;
|
||||
|
||||
class ContextGL_X11 : public ContextGL {
|
||||
|
||||
ContextGL_X11_Private *p;
|
||||
OS::VideoMode default_video_mode;
|
||||
// ::Colormap x11_colormap;
|
||||
::Display *x11_display;
|
||||
::Window& x11_window;
|
||||
bool double_buffer;
|
||||
bool direct_render;
|
||||
int glx_minor,glx_major;
|
||||
bool opengl_3_context;
|
||||
public:
|
||||
|
||||
virtual void release_current();
|
||||
virtual void make_current();
|
||||
virtual void swap_buffers();
|
||||
virtual int get_window_width();
|
||||
virtual int get_window_height();
|
||||
|
||||
virtual Error initialize();
|
||||
|
||||
ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,const OS::VideoMode& p_default_video_mode,bool p_opengl_3_context);
|
||||
~ContextGL_X11();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
146
platform/x11/detect.py
Normal file
146
platform/x11/detect.py
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def is_active():
|
||||
return True
|
||||
|
||||
def get_name():
|
||||
return "X11"
|
||||
|
||||
|
||||
def can_build():
|
||||
|
||||
if (os.name!="posix"):
|
||||
return False
|
||||
|
||||
if sys.platform == "darwin":
|
||||
return False # no x11 on mac for now
|
||||
|
||||
errorval=os.system("pkg-config --version > /dev/null")
|
||||
|
||||
if (errorval):
|
||||
print("pkg-config not found.. x11 disabled.")
|
||||
return False
|
||||
|
||||
x11_error=os.system("pkg-config x11 --modversion > /dev/null ")
|
||||
if (x11_error):
|
||||
print("X11 not found.. x11 disabled.")
|
||||
return False
|
||||
|
||||
x11_error=os.system("pkg-config xcursor --modversion > /dev/null ")
|
||||
if (x11_error):
|
||||
print("xcursor not found.. x11 disabled.")
|
||||
return False
|
||||
|
||||
return True # X11 enabled
|
||||
|
||||
def get_opts():
|
||||
|
||||
return [
|
||||
('use_llvm','Use llvm compiler','no'),
|
||||
('use_sanitizer','Use llvm compiler sanitize address','no'),
|
||||
('force_32_bits','Force 32 bits binary','no')
|
||||
]
|
||||
|
||||
def get_flags():
|
||||
|
||||
return [
|
||||
('opengl', 'no'),
|
||||
('legacygl', 'yes'),
|
||||
('builtin_zlib', 'no'),
|
||||
]
|
||||
|
||||
|
||||
|
||||
def configure(env):
|
||||
|
||||
env.Append(CPPPATH=['#platform/x11'])
|
||||
if (env["use_llvm"]=="yes"):
|
||||
env["CC"]="clang"
|
||||
env["CXX"]="clang++"
|
||||
env["LD"]="clang++"
|
||||
if (env["use_sanitizer"]=="yes"):
|
||||
env.Append(CXXFLAGS=['-fsanitize=address','-fno-omit-frame-pointer'])
|
||||
env.Append(LINKFLAGS=['-fsanitize=address'])
|
||||
|
||||
|
||||
|
||||
if (env["tools"]=="no"):
|
||||
#no tools suffix
|
||||
env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
|
||||
env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
|
||||
|
||||
|
||||
if (env["target"]=="release"):
|
||||
|
||||
env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer'])
|
||||
env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
|
||||
env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
|
||||
|
||||
elif (env["target"]=="release_debug"):
|
||||
|
||||
env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED'])
|
||||
env['OBJSUFFIX'] = "_optd"+env['OBJSUFFIX']
|
||||
env['LIBSUFFIX'] = "_optd"+env['LIBSUFFIX']
|
||||
|
||||
|
||||
# env.Append(CCFLAGS=['-Os','-ffast-math','-fomit-frame-pointer'])
|
||||
#does not seem to have much effect
|
||||
# env.Append(CCFLAGS=['-fno-default-inline'])
|
||||
#recommended by wxwidgets
|
||||
# env.Append(CCFLAGS=['-ffunction-sections','-fdata-sections'])
|
||||
# env.Append(LINKFLAGS=['-Wl','--gc-sections'])
|
||||
|
||||
elif (env["target"]=="debug"):
|
||||
|
||||
env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
|
||||
#does not seem to have much effect
|
||||
# env.Append(CCFLAGS=['-fno-default-inline'])
|
||||
#recommended by wxwidgets
|
||||
# env.Append(CCFLAGS=['-ffunction-sections','-fdata-sections'])
|
||||
# env.Append(LINKFLAGS=['-Wl','--gc-sections'])
|
||||
|
||||
elif (env["target"]=="debug_light"):
|
||||
|
||||
env.Append(CCFLAGS=['-g1', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
|
||||
|
||||
|
||||
elif (env["target"]=="profile"):
|
||||
|
||||
env.Append(CCFLAGS=['-g','-pg'])
|
||||
env.Append(LINKFLAGS=['-pg'])
|
||||
|
||||
env.ParseConfig('pkg-config x11 --cflags --libs')
|
||||
env.ParseConfig('pkg-config xcursor --cflags --libs')
|
||||
|
||||
|
||||
env.ParseConfig('pkg-config freetype2 --cflags --libs')
|
||||
env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
|
||||
|
||||
|
||||
if env['opengl'] == 'yes':
|
||||
env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED'])
|
||||
#env.Append(CPPFLAGS=["-DRTAUDIO_ENABLED"])
|
||||
env.Append(CPPFLAGS=["-DALSA_ENABLED"])
|
||||
env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES1_ENABLED','-DGLES_OVER_GL'])
|
||||
# env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL'])
|
||||
env.Append(LIBS=['GL', 'GLU', 'pthread','asound','z']) #TODO detect linux/BSD!
|
||||
#env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
|
||||
if (env["force_32_bits"]=="yes"):
|
||||
env.Append(CPPFLAGS=['-m32'])
|
||||
env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu'])
|
||||
|
||||
if (env["CXX"]=="clang++"):
|
||||
env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
|
||||
env["CC"]="clang"
|
||||
env["LD"]="clang++"
|
||||
|
||||
import methods
|
||||
|
||||
env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
|
||||
env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
|
||||
env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
|
||||
#env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
|
||||
|
||||
24
platform/x11/export/export.cpp
Normal file
24
platform/x11/export/export.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "export.h"
|
||||
#include "platform/x11/logo.h"
|
||||
#include "tools/editor/editor_import_export.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
void register_x11_exporter() {
|
||||
|
||||
Image img(_x11_logo);
|
||||
Ref<ImageTexture> logo = memnew( ImageTexture );
|
||||
logo->create_from_image(img);
|
||||
|
||||
{
|
||||
Ref<EditorExportPlatformPC> exporter = Ref<EditorExportPlatformPC>( memnew(EditorExportPlatformPC) );
|
||||
exporter->set_binary_extension("bin");
|
||||
exporter->set_release_binary32("linux_x11_32_release");
|
||||
exporter->set_debug_binary32("linux_x11_32_debug");
|
||||
exporter->set_release_binary64("linux_x11_64_release");
|
||||
exporter->set_debug_binary64("linux_x11_64_debug");
|
||||
exporter->set_name("Linux X11");
|
||||
exporter->set_logo(logo);
|
||||
EditorImportExport::get_singleton()->add_export_platform(exporter);
|
||||
}
|
||||
|
||||
}
|
||||
4
platform/x11/export/export.h
Normal file
4
platform/x11/export/export.h
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
|
||||
void register_x11_exporter();
|
||||
|
||||
45
platform/x11/godot_x11.cpp
Normal file
45
platform/x11/godot_x11.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*************************************************************************/
|
||||
/* godot_x11.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "main/main.h"
|
||||
#include "os_x11.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
OS_X11 os;
|
||||
|
||||
Error err = Main::setup(argv[0],argc-1,&argv[1]);
|
||||
if (err!=OK)
|
||||
return 255;
|
||||
|
||||
if (Main::start())
|
||||
os.run(); // it is actually the OS that decides how to run
|
||||
Main::cleanup();
|
||||
|
||||
return os.get_exit_code();
|
||||
}
|
||||
1812
platform/x11/key_mapping_x11.cpp
Normal file
1812
platform/x11/key_mapping_x11.cpp
Normal file
File diff suppressed because it is too large
Load diff
55
platform/x11/key_mapping_x11.h
Normal file
55
platform/x11/key_mapping_x11.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*************************************************************************/
|
||||
/* key_mapping_x11.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifndef KEY_MAPPING_X11_H
|
||||
#define KEY_MAPPING_X11_H
|
||||
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
*/
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/XF86keysym.h>
|
||||
#define XK_MISCELLANY
|
||||
#define XK_LATIN1
|
||||
#define XK_XKB_KEYS
|
||||
#include <X11/keysymdef.h>
|
||||
|
||||
#include "os/keyboard.h"
|
||||
|
||||
class KeyMappingX11 {
|
||||
KeyMappingX11() {};
|
||||
public:
|
||||
static unsigned int get_keycode(KeySym p_keysym);
|
||||
static KeySym get_keysym(unsigned int p_code);
|
||||
static unsigned int get_unicode_from_keysym(KeySym p_keysym);
|
||||
static KeySym get_keysym_from_unicode(unsigned int p_unicode);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
BIN
platform/x11/logo.png
Normal file
BIN
platform/x11/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2 KiB |
1300
platform/x11/os_x11.cpp
Normal file
1300
platform/x11/os_x11.cpp
Normal file
File diff suppressed because it is too large
Load diff
203
platform/x11/os_x11.h
Normal file
203
platform/x11/os_x11.h
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
/*************************************************************************/
|
||||
/* os_x11.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifndef OS_X11_H
|
||||
#define OS_X11_H
|
||||
|
||||
|
||||
#include "os/input.h"
|
||||
#include "drivers/unix/os_unix.h"
|
||||
#include "context_gl_x11.h"
|
||||
#include "servers/visual_server.h"
|
||||
#include "servers/visual/visual_server_wrap_mt.h"
|
||||
#include "servers/visual/rasterizer.h"
|
||||
#include "servers/physics_server.h"
|
||||
#include "servers/audio/audio_server_sw.h"
|
||||
#include "servers/audio/sample_manager_sw.h"
|
||||
#include "servers/spatial_sound/spatial_sound_server_sw.h"
|
||||
#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
|
||||
#include "drivers/rtaudio/audio_driver_rtaudio.h"
|
||||
#include "drivers/alsa/audio_driver_alsa.h"
|
||||
#include "servers/physics_2d/physics_2d_server_sw.h"
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
|
||||
//bitch
|
||||
#undef CursorShape
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
*/
|
||||
|
||||
class OS_X11 : public OS_Unix {
|
||||
|
||||
Atom wm_delete;
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
|
||||
ContextGL_X11 *context_gl;
|
||||
#endif
|
||||
Rasterizer *rasterizer;
|
||||
VisualServer *visual_server;
|
||||
VideoMode current_videomode;
|
||||
List<String> args;
|
||||
Window x11_window;
|
||||
MainLoop *main_loop;
|
||||
::Display* x11_display;
|
||||
char *xmbstring;
|
||||
int xmblen;
|
||||
unsigned long last_timestamp;
|
||||
::Time last_keyrelease_time;
|
||||
::XIC xic;
|
||||
::XIM xim;
|
||||
::XIMStyle xim_style;
|
||||
Point2i last_mouse_pos;
|
||||
bool last_mouse_pos_valid;
|
||||
Point2i last_click_pos;
|
||||
uint64_t last_click_ms;
|
||||
unsigned int event_id;
|
||||
uint32_t last_button_state;
|
||||
|
||||
PhysicsServer *physics_server;
|
||||
unsigned int get_mouse_button_state(unsigned int p_x11_state);
|
||||
InputModifierState get_key_modifier_state(unsigned int p_x11_state);
|
||||
Physics2DServer *physics_2d_server;
|
||||
|
||||
MouseMode mouse_mode;
|
||||
Point2i center;
|
||||
|
||||
void handle_key_event(XKeyEvent *p_event);
|
||||
void process_xevents();
|
||||
virtual void delete_main_loop();
|
||||
IP_Unix *ip_unix;
|
||||
|
||||
AudioServerSW *audio_server;
|
||||
SampleManagerMallocSW *sample_manager;
|
||||
SpatialSoundServerSW *spatial_sound_server;
|
||||
SpatialSound2DServerSW *spatial_sound_2d_server;
|
||||
|
||||
bool force_quit;
|
||||
bool minimized;
|
||||
int dpad_last[2];
|
||||
|
||||
|
||||
const char *cursor_theme;
|
||||
int cursor_size;
|
||||
Cursor cursors[CURSOR_MAX];
|
||||
Cursor null_cursor;
|
||||
CursorShape current_cursor;
|
||||
|
||||
InputDefault *input;
|
||||
|
||||
#ifdef RTAUDIO_ENABLED
|
||||
AudioDriverRtAudio driver_rtaudio;
|
||||
#endif
|
||||
|
||||
#ifdef ALSA_ENABLED
|
||||
AudioDriverALSA driver_alsa;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
JOYSTICKS_MAX = 8,
|
||||
MAX_JOY_AXIS = 32768, // I've no idea
|
||||
};
|
||||
|
||||
struct Joystick {
|
||||
|
||||
int fd;
|
||||
int last_axis[JOY_AXIS_MAX];
|
||||
|
||||
Joystick() {
|
||||
fd = -1;
|
||||
for (int i=0; i<JOY_AXIS_MAX; i++) {
|
||||
|
||||
last_axis[i] = 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Atom net_wm_icon;
|
||||
|
||||
|
||||
int joystick_count;
|
||||
Joystick joysticks[JOYSTICKS_MAX];
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual int get_video_driver_count() const;
|
||||
virtual const char * get_video_driver_name(int p_driver) const;
|
||||
virtual VideoMode get_default_video_mode() const;
|
||||
|
||||
virtual void initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver);
|
||||
virtual void finalize();
|
||||
|
||||
virtual void set_main_loop( MainLoop * p_main_loop );
|
||||
|
||||
void probe_joystick(int p_id = -1);
|
||||
void process_joysticks();
|
||||
void close_joystick(int p_id = -1);
|
||||
|
||||
public:
|
||||
|
||||
virtual String get_name();
|
||||
|
||||
virtual void set_cursor_shape(CursorShape p_shape);
|
||||
|
||||
void set_mouse_mode(MouseMode p_mode);
|
||||
MouseMode get_mouse_mode() const;
|
||||
|
||||
virtual Point2 get_mouse_pos() const;
|
||||
virtual int get_mouse_button_state() const;
|
||||
virtual void set_window_title(const String& p_title);
|
||||
|
||||
virtual void set_icon(const Image& p_icon);
|
||||
|
||||
virtual MainLoop *get_main_loop() const;
|
||||
|
||||
virtual bool can_draw() const;
|
||||
|
||||
virtual void set_clipboard(const String& p_text);
|
||||
virtual String get_clipboard() const;
|
||||
|
||||
virtual void release_rendering_thread();
|
||||
virtual void make_rendering_thread();
|
||||
virtual void swap_buffers();
|
||||
|
||||
|
||||
virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0);
|
||||
virtual VideoMode get_video_mode(int p_screen=0) const;
|
||||
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
|
||||
|
||||
virtual void move_window_to_foreground();
|
||||
|
||||
void run();
|
||||
|
||||
OS_X11();
|
||||
};
|
||||
|
||||
#endif
|
||||
32
platform/x11/platform_config.h
Normal file
32
platform/x11/platform_config.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*************************************************************************/
|
||||
/* platform_config.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include <alloca.h>
|
||||
#define GLES2_INCLUDE_H "gl_context/glew.h"
|
||||
#define GLES1_INCLUDE_H "gl_context/glew.h"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue