This commit is contained in:
Juan Linietsky 2017-01-05 09:18:03 -03:00
commit 495d059a74
17 changed files with 93 additions and 129 deletions

View file

@ -12,7 +12,7 @@ os:
env:
#- GODOT_TARGET=iphone
#- GODOT_TARGET=osx
- GODOT_TARGET=osx
- GODOT_TARGET=x11
#- GODOT_TARGET=android
- GODOT_TARGET=windows

View file

@ -150,12 +150,26 @@ typedef unsigned int GLhandleARB;
typedef unsigned short GLhalfARB;
typedef unsigned short GLhalf;
typedef GLint GLfixed;
// Temporary work around for upstream issue: https://github.com/Dav1dde/glad/issues/70
// Originally fixed by Algorithmus, reapplied in master
#if defined(__APPLE__)
typedef long GLintptr;
typedef long GLsizeiptr;
#else
typedef ptrdiff_t GLintptr;
typedef ptrdiff_t GLsizeiptr;
#endif
typedef int64_t GLint64;
typedef uint64_t GLuint64;
// Temporary work around for upstream issue: https://github.com/Dav1dde/glad/issues/70
// Originally fixed by Algorithmus, reapplied in master
#if defined(__APPLE__)
typedef long GLintptrARB;
typedef long GLsizeiptrARB;
#else
typedef ptrdiff_t GLintptrARB;
typedef ptrdiff_t GLsizeiptrARB;
#endif
typedef int64_t GLint64EXT;
typedef uint64_t GLuint64EXT;
typedef struct __GLsync *GLsync;

View file

@ -136,9 +136,13 @@ void RasterizerGLES3::initialize() {
ERR_PRINT("Error initializing GLAD");
}
#ifdef __APPLE__
// FIXME glDebugMessageCallbackARB does not seem to work on Mac OS X and opengl 3, this may be an issue with our opengl canvas..
#else
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
glDebugMessageCallbackARB(_gl_debug_print, NULL);
glEnable(_EXT_DEBUG_OUTPUT);
#endif
#endif

View file

@ -35,7 +35,7 @@
#include "drivers/unix/os_unix.h"
#include "main/input_default.h"
#include "servers/visual_server.h"
#include "servers/visual/visual_server_wrap_mt.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"
@ -58,7 +58,8 @@
class OS_OSX : public OS_Unix {
public:
bool force_quit;
Rasterizer *rasterizer;
// rasterizer seems to no longer be given to visual server, its using GLES3 directly?
// Rasterizer *rasterizer;
VisualServer *visual_server;
List<String> args;

View file

@ -38,13 +38,14 @@
#include "servers/visual/visual_server_raster.h"
//#include "drivers/opengl/rasterizer_gl.h"
//#include "drivers/gles2/rasterizer_gles2.h"
#include "drivers/gles3/rasterizer_gles3.h"
#include "os_osx.h"
#include <stdio.h>
#include <stdlib.h>
#include "print_string.h"
#include "servers/physics/physics_server_sw.h"
#include "drivers/gles2/rasterizer_instance_gles2.h"
#include "servers/visual/visual_server_wrap_mt.h"
// #include "drivers/gles2/rasterizer_instance_gles2.h"
// #include "servers/visual/visual_server_wrap_mt.h"
#include "main/main.h"
#include "os/keyboard.h"
#include "dir_access_osx.h"
@ -986,13 +987,11 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
window_size.width = p_desired.width;
window_size.height = p_desired.height;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6 && display_scale>1) {
[window_view setWantsBestResolutionOpenGLSurface:YES];
//if (current_videomode.resizable)
[window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
}
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
// [window_object setTitle:[NSString stringWithUTF8String:"GodotEnginies"]];
[window_object setContentView:window_view];
@ -1000,10 +999,8 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
[window_object setAcceptsMouseMovedEvents:YES];
[window_object center];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
[window_object setRestorable:NO];
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
unsigned int attributeCount = 0;
@ -1022,10 +1019,8 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
ADD_ATTR(NSOpenGLPFADoubleBuffer);
ADD_ATTR(NSOpenGLPFAClosestPolicy);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (false/* use gl3*/)
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
// we now need OpenGL 3 or better, maybe even change this to 3_3Core ?
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);
@ -1084,15 +1079,19 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
AudioDriverManagerSW::add_driver(&audio_driver_osx);
// only opengl support here...
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
rasterizer = instance_RasterizerGLES2();
// rasterizer = instance_RasterizerGLES2();
// visual_server = memnew( VisualServerRaster(rasterizer) );
visual_server = memnew( VisualServerRaster(rasterizer) );
if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
}
visual_server = memnew( VisualServerRaster );
// FIXME: Reimplement threaded rendering? Or remove?
// if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
//
// visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
// }
visual_server->init();
visual_server->cursor_set_visible(false, 0);
@ -1176,7 +1175,7 @@ void OS_OSX::finalize() {
visual_server->finish();
memdelete(visual_server);
memdelete(rasterizer);
// memdelete(rasterizer);
physics_server->finish();
memdelete(physics_server);

View file

@ -28,6 +28,7 @@
/*************************************************************************/
#include <alloca.h>
#define GLES2_INCLUDE_H "GL/glew.h"
#define GLES3_INCLUDE_H "GL/glew.h"
//#define GLES2_INCLUDE_H "GL/glew.h"
//#define GLES3_INCLUDE_H "GL/glew.h"
#define GLES3_INCLUDE_H "gl_context/glad/glad.h"
#define PTHREAD_RENAME_SELF

View file

@ -1087,13 +1087,15 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_
RasterizerGLES3::make_current();
#else
#ifdef DX9_ENABLED
// FIXME: Does DX support still work now that rasterizer is no longer used?
#ifdef DX9_ENABLED
rasterizer = memnew( RasterizerDX9(hWnd) );
#endif
#endif
#endif
visual_server = memnew( VisualServerRaster );
//if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
// FIXME: Reimplement threaded rendering? Or remove?
// if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
//
// visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
// }

View file

@ -40,9 +40,7 @@ void ColorPicker::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_THEME_CHANGED: {
uv_edit->set_texture(get_icon("color_main"));
w_edit->set_texture(get_icon("color_hue"));
sample->set_texture(get_icon("color_sample"));
//sample->set_texture(get_icon("color_sample"));
_update_controls();
} break;
@ -50,8 +48,6 @@ void ColorPicker::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
uv_edit->get_child(0)->cast_to<Control>()->update();
w_edit->get_child(0)->cast_to<Control>()->update();
_update_color();
}
@ -273,14 +269,39 @@ void ColorPicker::_hsv_draw(int p_wich,Control* c)
if (!c)
return;
if (p_wich==0) {
Vector<Point2> points;
points.push_back(Vector2());
points.push_back(Vector2(c->get_size().x,0));
points.push_back(c->get_size());
points.push_back(Vector2(0,c->get_size().y));
Vector<Color> colors;
colors.push_back(Color(1,1,1));
colors.push_back(Color(1,1,1));
colors.push_back(Color());
colors.push_back(Color());
c->draw_polygon(points,colors);
Vector<Color> colors2;
Color col = color;
col.set_hsv(color.get_h(),1,1);
col.a = 0;
colors2.push_back(col);
col.a = 1;
colors2.push_back(col);
col.set_hsv(color.get_h(),1,0);
colors2.push_back(col);
col.a = 0;
colors2.push_back(col);
c->draw_polygon(points,colors);
int x = CLAMP(c->get_size().x * s, 0, c->get_size().x);
int y = CLAMP(c->get_size().y-c->get_size().y * v, 0, c->get_size().y);
Color col = color;
col = color;
col.a=1;
c->draw_line(Point2(x,0),Point2(x,c->get_size().y),col.inverted());
c->draw_line(Point2(0, y),Point2(c->get_size().x, y),col.inverted());
c->draw_line(Point2(x,y),Point2(x,y),Color(1,1,1),2);
} else if (p_wich==1) {
Ref<Texture> hue = get_icon("color_hue","ColorPicker");
c->draw_texture_rect(hue,Rect2(Point2(),c->get_size()));
int y=c->get_size().y-c->get_size().y*h;
Color col=Color();
col.set_hsv(h,1,1);
@ -476,35 +497,30 @@ ColorPicker::ColorPicker() :
HBoxContainer *hb_edit = memnew( HBoxContainer );
uv_edit= memnew ( TextureFrame );
uv_edit= memnew ( Control );
uv_edit->set_ignore_mouse(false);
uv_edit->connect("input_event", this, "_uv_input");
Control *c= memnew( Control );
uv_edit->add_child(c);
c->set_area_as_parent_rect();
c->set_stop_mouse(false);
uv_edit->set_stop_mouse(false);
uv_edit->set_custom_minimum_size(Size2 (256,256));
Vector<Variant> args=Vector<Variant>();
args.push_back(0);
args.push_back(c);
c->connect("draw",this,"_hsv_draw",args);
args.push_back(uv_edit);
uv_edit->connect("draw",this,"_hsv_draw",args);
add_child(hb_edit);
w_edit= memnew( TextureFrame );
w_edit->set_ignore_mouse(false);
w_edit= memnew( Control );
w_edit->set_ignore_mouse(false);
w_edit->set_custom_minimum_size(Size2(30,256));
w_edit->connect("input_event", this, "_w_input");
c= memnew( Control );
w_edit->add_child(c);
c->set_area_as_parent_rect();
c->set_stop_mouse(false);
args.clear();
args.push_back(1);
args.push_back(c);
c->connect("draw",this,"_hsv_draw",args);
args.push_back(w_edit);
w_edit->connect("draw",this,"_hsv_draw",args);
hb_edit->add_child(uv_edit);
hb_edit->add_child(memnew( VSeparator ));

View file

@ -39,7 +39,6 @@
#include "scene/gui/texture_frame.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/check_button.h"
#include "scene/resources/material.h"
class ColorPicker : public BoxContainer {
@ -49,8 +48,8 @@ private:
Control *screen;
Image last_capture;
TextureFrame *uv_edit;
TextureFrame *w_edit;
Control *uv_edit;
Control *w_edit;
TextureFrame *sample;
TextureFrame *preset;
Button *bt_add_preset;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 B

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

View file

@ -835,15 +835,9 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_icon("screen_picker","ColorPicker", make_icon( icon_color_pick_png ) );
t->set_icon("add_preset","ColorPicker", make_icon( icon_add_png ) );
t->set_icon("color_area", "ColorPicker", make_icon( color_picker_main_png));
t->set_icon("color_hue", "ColorPicker", make_icon( color_picker_hue_png));
t->set_icon("color_sample", "ColorPicker", make_icon( color_picker_sample_png));
t->set_shader("uv_editor", "ColorPicker", make_shader("", uv_editor_shader_code, ""));
t->set_shader("w_editor", "ColorPicker", make_shader("", w_editor_shader_code, ""));
// TooltipPanel
Ref<StyleBoxTexture> style_tt = make_stylebox( tooltip_bg_png,4,4,4,4);

0
scene/resources/default_theme/make_header.py Normal file → Executable file
View file

View file

@ -70,12 +70,7 @@ static const unsigned char close_hl_png[]={
static const unsigned char color_picker_hue_png[]={
0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x1,0x0,0x8,0x2,0x0,0x0,0x0,0x35,0x30,0x61,0x19,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x9,0x18,0xc,0x24,0x18,0xa9,0xb3,0x2c,0xb7,0x0,0x0,0x0,0x23,0x49,0x44,0x41,0x54,0x68,0xde,0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,0x7b,0x8a,0xe5,0x90,0x9a,0xab,0x81,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
@ -577,39 +572,3 @@ static const unsigned char window_resizer_png[]={
static const char *uv_editor_shader_code=
"vec3 nd1sl2=vec3(UV,0);"
"uniform float H=0;"
"float nd4sl0=H;"
"float nd7sl0=nd1sl2.x;"
"float nd7sl1=nd1sl2.y;"
"float nd7sl2=nd1sl2.z;"
"float nd2sl1def=-1;"
"float nd2sl0=nd7sl1*nd2sl1def;"
"float nd6sl1def=1;"
"float nd6sl0=nd2sl0+nd6sl1def;"
"vec3 nd3sl0=vec3(nd4sl0,nd7sl0,nd6sl0);"
"vec3 nd5sl0;"
"{"
" vec3 c = nd3sl0;"
" vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);"
" vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);"
" nd5sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);"
"}"
"COLOR.rgb=nd5sl0;";
static const char *w_editor_shader_code=
"vec3 nd1sl2=vec3(UV,0);"
"float nd2sl1=1-nd1sl2.y;"
"vec3 nd3sl0=vec3(nd2sl1,1,1);"
"vec3 nd6sl0;"
"{"
" vec3 c = nd3sl0;"
" vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);"
" vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);"
" nd6sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);"
"}"
"COLOR.rgb=nd6sl0;";

View file

@ -1,19 +0,0 @@
vec3 nd1sl2=vec3(UV,0);
uniform float H=0;
float nd4sl0=H;
float nd7sl0=nd1sl2.x;
float nd7sl1=nd1sl2.y;
float nd7sl2=nd1sl2.z;
float nd2sl1def=-1;
float nd2sl0=nd7sl1*nd2sl1def;
float nd6sl1def=1;
float nd6sl0=nd2sl0+nd6sl1def;
vec3 nd3sl0=vec3(nd4sl0,nd7sl0,nd6sl0);
vec3 nd5sl0;
{
vec3 c = nd3sl0;
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
nd5sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
COLOR.rgb=nd5sl0;

View file

@ -1,11 +0,0 @@
vec3 nd1sl2=vec3(UV,0);
float nd2sl1=1-nd1sl2.y;
vec3 nd3sl0=vec3(nd2sl1,1,1);
vec3 nd6sl0;
{
vec3 c = nd3sl0;
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
nd6sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
COLOR.rgb=nd6sl0;

View file

@ -151,6 +151,11 @@ public:
/* COMPILER */
// lame work around to Apple defining this as a macro in 10.12 SDK
#ifdef TYPE_BOOL
#undef TYPE_BOOL
#endif
enum DataType {
TYPE_VOID,
TYPE_BOOL,