1
1

Compare commits

...

96 Commits

Author SHA1 Message Date
0c3c49eee3 fix: visual studio 2010 project built with cmake could not find libjpeg 2014-05-30 23:08:27 -05:00
5d3b635d31 Fixed compile errors associated with merge from soc-2013-viewport_fx and MSVC2010
not tested
2014-05-29 22:56:55 -05:00
6eff1cbebc Merge branch 'soc-2014-viewport' into soc-2013-viewport_fx
Conflicts:
	intern/cycles/device/device_cuda.cpp
	intern/ghost/intern/GHOST_WindowCocoa.mm
	source/blender/blenfont/intern/blf_font.c
	source/blender/blenfont/intern/blf_translation.c
	source/blender/blenkernel/BKE_brush.h
	source/blender/blenkernel/BKE_pbvh.h
	source/blender/blenkernel/intern/cdderivedmesh.c
	source/blender/blenkernel/intern/editderivedmesh.c
	source/blender/blenkernel/intern/mesh.c
	source/blender/blenkernel/intern/subsurf_ccg.c
	source/blender/blenlib/BLI_fileops.h
	source/blender/blenlib/BLI_math_matrix.h
	source/blender/blenlib/intern/fileops.c
	source/blender/blenlib/intern/math_matrix.c
	source/blender/editors/animation/anim_channels_defines.c
	source/blender/editors/animation/anim_draw.c
	source/blender/editors/animation/keyframes_draw.c
	source/blender/editors/include/ED_armature.h
	source/blender/editors/interface/interface.c
	source/blender/editors/interface/interface_draw.c
	source/blender/editors/interface/interface_icons.c
	source/blender/editors/interface/interface_panel.c
	source/blender/editors/interface/interface_widgets.c
	source/blender/editors/interface/view2d.c
	source/blender/editors/mask/mask_draw.c
	source/blender/editors/mesh/editmesh_select.c
	source/blender/editors/render/render_opengl.c
	source/blender/editors/screen/area.c
	source/blender/editors/screen/glutil.c
	source/blender/editors/sculpt_paint/paint_cursor.c
	source/blender/editors/sculpt_paint/paint_image.c
	source/blender/editors/sculpt_paint/paint_image_proj.c
	source/blender/editors/sculpt_paint/paint_utils.c
	source/blender/editors/sculpt_paint/sculpt_intern.h
	source/blender/editors/space_buttons/space_buttons.c
	source/blender/editors/space_clip/clip_dopesheet_draw.c
	source/blender/editors/space_clip/clip_draw.c
	source/blender/editors/space_clip/clip_graph_draw.c
	source/blender/editors/space_clip/clip_utils.c
	source/blender/editors/space_console/console_draw.c
	source/blender/editors/space_file/file_draw.c
	source/blender/editors/space_file/file_ops.c
	source/blender/editors/space_graph/graph_draw.c
	source/blender/editors/space_info/info_draw.c
	source/blender/editors/space_info/textview.c
	source/blender/editors/space_logic/logic_window.c
	source/blender/editors/space_nla/nla_draw.c
	source/blender/editors/space_outliner/outliner_draw.c
	source/blender/editors/space_sequencer/sequencer_draw.c
	source/blender/editors/space_view3d/drawanimviz.c
	source/blender/editors/space_view3d/drawarmature.c
	source/blender/editors/space_view3d/drawmesh.c
	source/blender/editors/space_view3d/drawobject.c
	source/blender/editors/space_view3d/view3d_draw.c
	source/blender/editors/space_view3d/view3d_fly.c
	source/blender/editors/space_view3d/view3d_intern.h
	source/blender/editors/space_view3d/view3d_walk.c
	source/blender/editors/transform/transform.c
	source/blender/editors/transform/transform_manipulator.c
	source/blender/editors/util/ed_util.c
	source/blender/editors/uvedit/uvedit_draw.c
	source/blender/gpu/GPU_buffers.h
	source/blender/gpu/intern/gpu_buffers.c
	source/blender/gpu/intern/gpu_codegen.c
	source/blender/gpu/intern/gpu_codegen.h
	source/blender/gpu/intern/gpu_draw.c
	source/blender/render/intern/source/convertblender.c
	source/blender/windowmanager/intern/wm_operators.c
	source/blender/windowmanager/intern/wm_subwindow.c
	source/blender/windowmanager/intern/wm_window.c
2014-05-21 19:02:02 -05:00
49de1ada8d fixed compile errors on MacOSX Clang 5.1 after previous merge 2014-05-20 00:08:13 -05:00
49e9e98c4d error fix: missing definition of offsetof when compiling with clang 5.1 on MacOS 10 Mavericks 2014-05-19 23:50:18 -05:00
e18a9440cc warning fix: removed unused function f_to_char 2014-05-19 22:52:05 -05:00
078884e239 warning fix: typedef of incomplete struct type forces redefinition of the typedef later, which is illegal except in C++ 11 2014-05-19 22:03:20 -05:00
f6416b94a5 more merge conflict resolution from 9822428f6c 2014-03-17 11:48:21 -05:00
9822428f6c Merge branch 'master' into soc-2013-viewport_fx
Conflicts:
	CMakeLists.txt
	intern/cycles/app/CMakeLists.txt
	intern/ghost/CMakeLists.txt
	intern/ghost/intern/GHOST_Window.h
	intern/ghost/intern/GHOST_WindowWin32.cpp
	intern/ghost/intern/GHOST_WindowWin32.h
	release/datafiles/startup.blend
	source/blender/blenfont/BLF_api.h
	source/blender/blenfont/intern/blf_font.c
	source/blender/blenfont/intern/blf_glyph.c
	source/blender/blenfont/intern/blf_lang.c
	source/blender/blenkernel/intern/anim.c
	source/blender/blenkernel/intern/cdderivedmesh.c
	source/blender/blenkernel/intern/displist.c
	source/blender/blenkernel/intern/editderivedmesh.c
	source/blender/blenkernel/intern/mball.c
	source/blender/blenkernel/intern/mesh.c
	source/blender/blenkernel/intern/pbvh.c
	source/blender/blenkernel/intern/subsurf_ccg.c
	source/blender/blenlib/BLI_math_base.h
	source/blender/blenlib/BLI_math_matrix.h
	source/blender/blenlib/BLI_smallhash.h
	source/blender/blenlib/intern/math_matrix.c
	source/blender/blenlib/intern/math_vector_inline.c
	source/blender/blenlib/intern/storage.c
	source/blender/blenloader/BLO_readfile.h
	source/blender/datatoc/CMakeLists.txt
	source/blender/editors/animation/keyframes_draw.c
	source/blender/editors/armature/CMakeLists.txt
	source/blender/editors/armature/editarmature_sketch.c
	source/blender/editors/gpencil/drawgpencil.c
	source/blender/editors/include/BIF_gl.h
	source/blender/editors/include/BIF_glutil.h
	source/blender/editors/include/UI_interface.h
	source/blender/editors/interface/interface_draw.c
	source/blender/editors/interface/interface_ops.c
	source/blender/editors/interface/interface_panel.c
	source/blender/editors/interface/interface_widgets.c
	source/blender/editors/mask/mask_draw.c
	source/blender/editors/mesh/editmesh_knife.c
	source/blender/editors/mesh/editmesh_select.c
	source/blender/editors/screen/glutil.c
	source/blender/editors/screen/screen_edit.c
	source/blender/editors/screen/screendump.c
	source/blender/editors/sculpt_paint/paint_cursor.c
	source/blender/editors/sculpt_paint/paint_image.c
	source/blender/editors/sculpt_paint/paint_image_proj.c
	source/blender/editors/sculpt_paint/paint_intern.h
	source/blender/editors/sculpt_paint/sculpt_intern.h
	source/blender/editors/space_action/action_draw.c
	source/blender/editors/space_action/space_action.c
	source/blender/editors/space_clip/clip_dopesheet_draw.c
	source/blender/editors/space_clip/clip_draw.c
	source/blender/editors/space_file/file_intern.h
	source/blender/editors/space_graph/graph_draw.c
	source/blender/editors/space_image/image_draw.c
	source/blender/editors/space_info/textview.c
	source/blender/editors/space_nla/nla_draw.c
	source/blender/editors/space_node/drawnode.c
	source/blender/editors/space_node/node_draw.c
	source/blender/editors/space_outliner/outliner_draw.c
	source/blender/editors/space_sequencer/sequencer_draw.c
	source/blender/editors/space_text/text_draw.c
	source/blender/editors/space_view3d/drawarmature.c
	source/blender/editors/space_view3d/drawmesh.c
	source/blender/editors/space_view3d/drawobject.c
	source/blender/editors/space_view3d/drawvolume.c
	source/blender/editors/space_view3d/view3d_draw.c
	source/blender/editors/space_view3d/view3d_edit.c
	source/blender/editors/space_view3d/view3d_fly.c
	source/blender/editors/space_view3d/view3d_intern.h
	source/blender/editors/transform/transform.c
	source/blender/editors/transform/transform.h
	source/blender/editors/transform/transform_constraints.c
	source/blender/editors/transform/transform_manipulator.c
	source/blender/editors/util/ed_util.c
	source/blender/editors/uvedit/CMakeLists.txt
	source/blender/editors/uvedit/uvedit_draw.c
	source/blender/editors/uvedit/uvedit_smart_stitch.c
	source/blender/gpu/GPU_buffers.h
	source/blender/gpu/intern/gpu_buffers.c
	source/blender/gpu/intern/gpu_codegen.c
	source/blender/gpu/intern/gpu_draw.c
	source/blender/gpu/intern/gpu_extensions.c
	source/blender/gpu/intern/gpu_simple_shader.c
	source/blender/gpu/shaders/gpu_shader_material.glsl
	source/blender/render/intern/source/voxeldata.c
	source/blender/windowmanager/intern/wm_dragdrop.c
	source/blender/windowmanager/intern/wm_draw.c
	source/blender/windowmanager/intern/wm_event_system.c
	source/blender/windowmanager/intern/wm_gesture.c
	source/blender/windowmanager/intern/wm_subwindow.c
	source/blender/windowmanager/intern/wm_window.c
2014-03-04 15:43:06 -06:00
0f1cac0d87 stub version of refactored GHOST for OSX Cocoa CGL 2014-02-18 19:52:25 -06:00
e2cda64f46 removed 'enabled' field from CLIPPING state (not needed, a shader either implements clipping or it doesn't) 2014-02-17 11:00:16 -06:00
e0ce58dd97 fileops.c: warning fix: int -> float conversion 2014-02-17 10:58:10 -06:00
d63b221f48 Fixing more warnings given by llvm gcc on OSX. 2014-02-15 15:46:40 -06:00
288d8f3ed7 Added GPU_clipping module which implements state for the common clipping state. Also added preliminary support for clipping in the basic aspect, but only for the compatibility profile (i.e. still need to implement GLSL clipping planes) 2014-02-15 13:36:34 -06:00
3dbc408d89 added assert to check for negative light index, also some whitespace cleanup 2014-02-15 13:20:13 -06:00
fd83ad4925 Jason Wilkins contributed this GPU_sprite.h 2014-02-15 13:19:13 -06:00
98e08806c7 OpenGL Desktop system (WITH_GL_SYSTEM_DESKTOP) set to be ON by default in CMakeLists.txt 2014-02-15 10:51:25 -06:00
5a2317757d Fixes for errors building on XCode on Mac OSX Mavericks. (Has more to do with llvm gcc than the OS.)
Still have to refactor GHOST for OSX and move glClipPlane into GPU module.
2014-02-14 11:36:21 -06:00
b6c6e6a2c0 Fixed some build errors that occur on MSVC 2014 when compiling WITH_GL_PROFILE_COMPAT.
(There are other errors that occur also in XCode, but I've fixed them in a separate commit already.)
2014-02-14 11:04:08 -06:00
55308a9557 Should not use formattedMsg unless call to FormatMessage succeeded. 2013-11-02 00:09:26 +00:00
181831d3ab some comments in GPU_raster.h feature flags 2013-09-24 00:20:22 +00:00
63939c44e1 missed adding GPU_pixels.h to CMakeLists.txt, also renamed GPU_uncache_pixels to GPU_pixels_uncache (was inconsistent with GPU_pixels_cache) 2013-09-23 23:01:13 +00:00
ef62a1fd5f because I had not used the feature yet, I had not noticed that I had 'object' and 'param' parameters backwards in the implementation of aspects. also fixed potential bug when using a 'param' and mixing up calls to different aspects 2013-09-23 22:32:01 +00:00
c50657bb86 fancier shader compiler error messages 2013-09-23 21:20:04 +00:00
c05b6d6f28 Finished work adding selection mode hooks. Selection mode uses an alternative set of aspect functions and most aspects can share a default or leave them unimplemented. This keeps each aspect shader from having to implement its own selection mode shader. 2013-09-23 19:33:51 +00:00
149d6aadf9 left gpu_common_intern.h out of project 2013-09-23 19:20:24 +00:00
1395140af1 adding hooks for select mode (incomplete so I can change locations) 2013-09-23 17:35:04 +00:00
43028ad280 Fixups for GPU_sprite. Needed to make a distinction between "points" and "sprites"
Sprites are only drawn by the GPU_ASPECT_SPRITE, while points can be drawn by any aspect.  Sprites can be round and, in the future they may be textured, while points have to be square and flat.
2013-09-23 16:11:26 +00:00
23dadba462 added gpuGetViewport and added GPU_SAFETY checks to GPU_state_latch (state should be set before gotten) 2013-09-23 13:58:46 +00:00
ec1c36c628 Changed method of detecting infinite loop in gpu_check from a count to seeing the same error flag twice 2013-09-23 12:46:50 +00:00
0252c176a1 added gpuErrorSymbol to go with gpuErrorString 2013-09-23 12:25:22 +00:00
ebd4419e6d putting GPU_mipmap_2D declaration in the proper header file (required letting creator.c include GL/glew.h) 2013-09-23 12:06:47 +00:00
de0154c97a Used the 'source_group' feature in CMake to organize the GPU source files better in Visual Studio 2013-09-23 11:49:42 +00:00
b67062ceee fixed violations of some new GPU_SAFETY checks I put in 2013-09-21 03:36:16 +00:00
637a6c4f11 fixed linker errors 2013-09-20 18:11:44 +00:00
a2c1d95303 creator.c doesn't like indirectly including glew.h 2013-09-20 18:02:13 +00:00
65d17750d8 more progress on last refactor before end of GSoC 2013 2013-09-20 17:59:25 +00:00
0d3eda85d6 start of refactoring based on ideas gathered while writing documentation. incomplete because I have to move to a different computer 2013-09-20 12:30:31 +00:00
3ee7410876 some fixes for drawing stipple with drawMappedFaces 2013-08-27 22:33:32 +00:00
ee01240c33 converting gpu_buffers to use extension_wrapper 2013-08-26 22:03:38 +00:00
9987d89480 rest of changes needed for the raster shader (still incomplete, but it compiles) 2013-08-26 21:35:06 +00:00
7ca6852bb2 "raster" shader. meaning a shading mode that handles stippling, anti-aliasing, and wire frame. Incomplete. Checking it so I can change locations. 2013-08-26 11:38:18 +00:00
50e3d32c56 cleaned up basic shader state handling somewhat. lighting seems accurate now
Added automatic GPU_BASIC_TEXTURE_2D disablement if there is no texture bound.
Also, added texture binding to texture object 0 where I could so this actually works.
There may be cases where the bound texture gets cleared across a function call, this should manifest as a white space where I texture should be, but I haven't seen it happen yet.
2013-08-08 01:19:38 +00:00
7f9a651d8c Created shader for 'DrawPixels', got 'DrawPixels' working on ES, removed last FAKE/REAL GL cruft 2013-08-07 17:15:42 +00:00
e894b1b490 Some changes to compile for ES, but it crashes. Need to try on ANGLE, so committing so I can move over to other computer. 2013-08-06 21:25:48 +00:00
fd10c884fd Tested the fixed function fallback mode for the basic shader.
Also tested what happens if there is no glsl support (need to make this a debug option)
Fixed memory leak that is detected when no glsl support (in the quad emulation code)
2013-08-06 20:31:20 +00:00
910046a385 Basic shader now runs and renders lit objects on OpenGL 3.2 Core.
The lighting isn't accurate yet.  Lots of glitches.  

On another note, Vertex Array Objects may not be as useful as I thought they'd be for saving immediate mode state.  

Had to work around a bug in ATI drivers that makes attribute 0 not work when changed with glVertexAttrib.
2013-08-06 03:45:27 +00:00
de4d3e86e5 Cleaning up shader code. Added transform code for spot lights. Still doesn't draw... 2013-08-05 17:11:35 +00:00
89029befa9 runs without crashing, the shaders compile, but nothing draws... 2013-08-05 04:25:17 +00:00
1eb6997a6e compiles again 2013-08-04 22:37:22 +00:00
4ca1fc427f Committing since GPU module compiles again. I've made too many changes without being able to compile and test. Concentrating now on bringing things back into a testable state. 2013-08-04 10:04:28 +00:00
c54932ed40 In progress applying GPU_simple_shader to implemented shading on ES/COre
Broken build because I ran out of steam while replacing calls to glShadeModel.
Will resume after I get some sleep :-)
2013-08-01 22:18:01 +00:00
eb60edacfa got mapped vbo working in ES and Core 2013-07-31 13:56:46 +00:00
2786d98e55 fixed crash at shutdown caused by de-initializing GPU stuff after windows had been destroyed
This makes me concerned about contexts and de-initialization.  I think it will work OK as long as contexts share 'display lists', but there might still be some race conditions caused by resources being managed separately from the windows they are associated with...
2013-07-31 02:32:00 +00:00
a54bcd9e1d Blender now runs on OpenGL 3.2 Core profile without crashing. It does seem to have problems with the TRIPLE refresh method, however.
Immediate mode converted to use vertex array and vertex buffer objects.  ES might be broken now.
2013-07-30 04:55:39 +00:00
217646208c workaround to get mali es emulator working properly, also, fixed a missing texture data format in my revised glaDrawPixelsSafe 2013-07-29 23:31:46 +00:00
5dd2b53bc7 Generalized GL ES so that I could link to both ANGLE with Mali's OpenGL ES Emulator.
I turns out that ANGLE accepts GL_UNSIGNED_INT as indexes when that isn't standard ES.
I had to go ahead and fix my immediate mode index building code to be flexible about what types it uses.

GLEW doesn't like Mali's driver because it eglGetCurrentDisplay doesn't work properly, but that just means it cannot load extensions, everything else seems as good as ANGLE.

http://malideveloper.arm.com/develop-for-mali/tools/opengl-es-2-0-emulator/
2013-07-29 20:28:18 +00:00
0999124a25 Can compile with WGL to initialize ES on desktop, but it turns out my gpu doesn't support the WGL_EXT_create_context_es2_profile, so I can't test it :( 2013-07-29 16:58:32 +00:00
f216c7fa35 some fixes so that the ES profile compiles and runs properly 2013-07-29 16:09:57 +00:00
d5a4a6d844 started working on getting blender to run under the core profile (with deprecated functions turned off), also sketching out a generic pixel format chooser 2013-07-29 14:47:23 +00:00
bd7dcd2ea0 A lot of misc. stuff with the WGL contexts.
now the GLEW contexts get cleared and get created even if glew fails to initialize them
compatibility, core, and ES profile support
sRGB framebuffer creation
removed dead code from WindowWin32
I'm overthinking the robustness of context creation, need to simplify later
2013-07-28 18:22:08 +00:00
6bb66b1073 Got GLEW_MX working with GHOST_ContextEGL 2013-07-27 20:59:45 +00:00
1902d2bcfd Enabled GLEW_MX and got it working with GHOST_ContextWGL
GLEW_MX puts each set of GL entry points into its own independent context.  This should reduce the possibility of WGL and GL getting mismatched.

It should also allow desktop and embedded GL to live in the same program at the same time, which isn't really the end goal, but if multiple versions of OpenGL could run in the same instance of Blender it would mean that GL contexts are well managed and encapsulated.

The biggest chore is probably sharing textures between alien contexts, however, I believe that problem can be solved by the same mechanism that will be needed to allow Blender to recover from power management events on mobile devices (and probably also the desktop when using ES).

Not going to go too far down that road now, but this is the foundation.
2013-07-27 20:32:10 +00:00
2a2708471a Warnings when WGL can't find the best pixel format. 2013-07-27 18:09:49 +00:00
0312361ef4 WGL_ContextEGL in working order 2013-07-27 16:38:52 +00:00
4ad8056310 Added paranoid check to make sure the context used to load WGL extensions and the context finally selected for rendering are compatible. 2013-07-27 16:21:07 +00:00
d32535ab9f GHOST_ContextWGL in working condition 2013-07-27 15:50:23 +00:00
c2177eb16c started implementation of GHOST_ContextWGL.cpp. (Incomplete) 2013-07-27 00:55:20 +00:00
17eb13ae19 Implemented GHOST_ContextEGL.cpp (untested) 2013-07-25 10:04:05 +00:00
b037d8c1df Need to call eglewInit before eglBindAPI.
Also fixed other problems with previous commits that I couldn't detect because I couldn't build.

Also, renamed some glScissor and glViewport to gpu versions... not sure why, I'm planning on changing them back...
2013-07-25 04:58:31 +00:00
b5d318c165 Forgot to add files for the GHOST_Context base class. 2013-07-25 01:37:40 +00:00
63a508c18e Added eglBindAPI calls in a future case where OpenGL VG or desktop OpenGL contexts are also being initialized by EGL. 2013-07-24 22:48:05 +00:00
4ccd805713 eglChooseConfig can return EGL_TRUE even if it doesn't find a suitable configuration, so you have to check the value of num_configs. Removed unused query for the total number of EGL configs. Now using a std::vector to hold the attrib_list. Put variable declarations close to their use sites. 2013-07-24 09:54:52 +00:00
62939e7b86 Added EGL multi-sampling support 2013-07-24 09:22:10 +00:00
adba2ebf14 Added support for multiple EGL contexts. 2013-07-24 05:12:38 +00:00
616ca3608e Fixed syntax errors the appeared in the WITH_GL_PROFILE_COMPAT build. 2013-07-23 08:39:52 +00:00
ff3f06cd19 Implemented replacement for DrawPixels so that icons and images draw on OpenGL ES and started working on the 'aspect' module, the heart of ViewportFX (finally...) 2013-07-23 07:54:05 +00:00
4e053891f9 Blender now runs when compiled with ANGLE and draws to the screen without triggering a GPU_SAFETY abort.
This is a big f***ing deal.  I feel like I've gotten a really nice present for my birthday today :-)
2013-07-22 23:55:44 +00:00
b70cc3b192 Added EGL initialization code to GHOST_WindowWin32, but this is just temporary until I'm sure exactly how GHOST_Context will be implemented. 2013-07-22 17:58:54 +00:00
29b35fa74a Fixed up problems caused from previous update that appear when compiling WITH_GL_PROFILE_COMPAT and WITH_GL_SYSTEM_LEGACY (as opposed to WITH_GL_PROFILE_ES20 and WITH_GL_SYSTEM_EMBEDDED) 2013-07-21 20:07:18 +00:00
175974a48e Found up several functions that really were ES2, Fixed linking problems with EGL/GLESv2, stubbed out Win32 GHOST in preparation for adding EGL support.
Blender compiles, but now crashes on startup due to NULL OpenGL function pointers.
2013-07-21 17:44:01 +00:00
f4557e3299 compiles with no syntax errors with ES headers, but there are now linker errors 2013-07-21 11:49:35 +00:00
0512be63fb Forgot to commit gpu_pixels and gpu_profile 2013-07-21 09:06:15 +00:00
fb6adeee98 Fixed some syntax errors when compiling WITH_GL_PROFILE_COMPAT instead of WITH_GL_PROFILE_ES20.
(Also noticed that I left gpu_profile and gpu_pixels on my computer at the office, ack)
2013-07-21 03:03:28 +00:00
802b5c3754 Have compile errors due to compiling with ES headers down to SELECT mode and PushAttrib/PopAttrib 2013-07-20 14:58:22 +00:00
febf82087c Fixes to get WITH_GL_PROFILE_COMPAT/WITH_GL_SYSTEM_LEGACY working with WITH_GLEW_ES
Also, added comments to the "shims" in gpu_glew.h
2013-07-19 20:55:51 +00:00
7d884a8528 typo in glEndList (glEndlList) 2013-07-19 20:16:05 +00:00
4991d98fd2 GPU_LEGACY - Runtime flag to determine if compatibiity profile is available.
Just a stub now.

Also, polished the get_max_textures function, since it seems to be a good example of how OpenGL versioning can be complicated by the history of changes to OpenGL and the existence of ES.
2013-07-19 19:38:29 +00:00
7135035e9e compiles again with glew-es disabled, still seems to run fine on legacy even after all the tweaks I made (much to my surprise, I expect things to be broken for a bit) 2013-07-19 09:14:01 +00:00
fa487c379b well on the way to conditionally compiling / rewriting non-ES and deprecated functions. still kind of a mess. doesn't compile 2013-07-19 06:00:11 +00:00
281111702b not really a stopping point, but checking in so that I can change my physical location 2013-07-18 17:08:23 +00:00
552f079666 fixed X cone on transform manipulator rotating around wrong axis 2013-07-18 09:34:15 +00:00
e8c68205de cleanup of gpu_matrix.c 2013-07-17 11:44:01 +00:00
6059756162 removing extraneous character 2013-07-17 08:04:03 +00:00
d076822e66 Merged work from working copy of GSoC 2012 work into GSoC 2013 branch.
Compiles w/ Visual Studio 2012 but not thoroughly tested.
Still need double check for any merge "fuzz"
2013-07-17 07:54:20 +00:00
b069eda10c gsoc 2013 branch soc-2013-viewport_fx 2013-06-12 04:03:41 +00:00
404 changed files with 91972 additions and 12314 deletions

View File

@@ -161,11 +161,13 @@ if(UNIX AND NOT APPLE)
option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON)
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON)
option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
option(WITH_GHOST_XDND "Enable drag'n'drop support on X11 using XDND protocol" ON)
else()
# not an option for other OS's
set(WITH_SYSTEM_GLEW OFF)
set(WITH_SYSTEM_GLES OFF)
endif()
@@ -295,6 +297,44 @@ if(CMAKE_COMPILER_IS_GNUCC)
mark_as_advanced(WITH_GCC_MUDFLAP)
endif()
# OpenGL
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
mark_as_advanced(WITH_GLEW_ES)
option(WITH_GLU "Provide the GL Utility Library (GLU). Only works with the 'compatibiity' profile. (deprecated)" ON)
mark_as_advanced(WITH_GLU_ES)
option(WITH_GL_SYSTEM_DESKTOP "Support using the AGL/WGL/XGL system library to initialize OpenGL. Can access 3.1+ core, compatibility, and 2.0 es profiles." ON)
mark_as_advanced(WITH_GL_SYSTEM_DESKTOP)
option(WITH_GL_SYSTEM_EMBEDDED "Support using the EGL system library to initialize OpenGL ES." OFF)
mark_as_advanced(WITH_GL_SYSTEM_EMBEDDED)
option(WITH_GL_PROFILE_COMPAT "Support using the OpenGL 'compatibility' profile. (deprecated)" ON)
mark_as_advanced(WITH_GL_PROFILE_COMPAT)
option(WITH_GL_PROFILE_CORE "Support using the OpenGL 3.1+ 'core' profile." OFF)
mark_as_advanced(WITH_GL_PROFILE_CORE)
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
mark_as_advanced(WITH_GL_PROFILE_ES20)
option(WITH_GPU_SAFETY "Perform extensive runtime tests to catch certain graphics API usage errors. (degrades performance)" OFF)
mark_as_advanced(WITH_GPU_SAFETY)
if(WIN32)
option(WITH_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF)
mark_as_advanced(WITH_ANGLE)
endif()
# Code Coverage
option(WITH_CODE_COVERAGE "Compile with support for generating code coverage information" OFF)
mark_as_advanced(WITH_CODE_COVERAGE)
# Apple
if(APPLE)
cmake_minimum_required(VERSION 2.8.8)
cmake_policy(VERSION 2.8.8)
@@ -1089,7 +1129,7 @@ elseif(WIN32)
set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
endif()
if(MSVC90)
if(MSVC90 OR MSVC10)
set(JPEG_NAMES ${JPEG_NAMES} libjpeg)
endif()
find_package(jpeg REQUIRED)
@@ -2020,10 +2060,78 @@ endif()
#-----------------------------------------------------------------------------
# Configure OpenGL.
find_package(OpenGL)
blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
# unset(OPENGL_LIBRARIES CACHE) # not compat with older cmake
# unset(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake
if(WITH_GL_SYSTEM_DESKTOP)
find_package(OpenGL)
set(GL_LIBRARIES "${OPENGL_gl_LIBRARY}")
if(WITH_GLU)
list(APPEND GL_LIBRARIES "${OPENGL_glu_LIBRARY}")
endif()
elseif(WITH_GL_SYSTEM_EMBEDDED)
if(WITH_SYSTEM_GLES)
find_package_wrapper(OpenGLES)
if(OPENGLES_FOUND)
set(GL_LIBRARIES OPENGLES_LIBRARIES)
else()
message(FATAL_ERROR "Unable to find OpenGL ES libraries, install them or disable WITH_SYSTEM_GLES")
endif()
else()
set(OPENGLES_LIBRARY "" CACHE FILEPATH "OpenGL ES 2.0 library file")
set(OPENGLES_EGL_LIBRARY "" CACHE FILEPATH "EGL library file")
mark_as_advanced(OPENGLES_LIBRARY OPENGLES_EGL_LIBRARY)
list(APPEND GL_LIBRARIES "${OPENGLES_LIBRARY}" "${OPENGLES_EGL_LIBRARY}")
if(WITH_ANGLE)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_ANGLE")
endif()
endif()
if(WIN32)
set(OPENGLES_DLL "" CACHE FILEPATH "OpenGL ES 2.0 redistributable DLL file")
set(OPENGLES_EGL_DLL "" CACHE FILEPATH "EGL redistributable DLL file")
mark_as_advanced(OPENGLES_DLL OPENGLES_EGL_DLL)
if(WITH_ANGLE)
set(D3DCOMPILER_DLL "" CACHE FILEPATH "Direct3D Compiler redistributable DLL file (needed by ANGLE)")
get_filename_component(D3DCOMPILER_FILENAME "${D3DCOMPILER_DLL}" NAME)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DD3DCOMPILER=\"\\\"${D3DCOMPILER_FILENAME}\\\"\"")
mark_as_advanced(D3DCOMPILER_DLL)
endif()
endif()
endif()
if(WITH_GL_PROFILE_COMPAT)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_PROFILE_COMPAT")
endif()
if(WITH_GL_PROFILE_CORE)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_PROFILE_CORE")
endif()
if(WITH_GL_PROFILE_ES20)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_PROFILE_ES20")
endif()
if(WITH_GL_SYSTEM_DESKTOP)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_SYSTEM_DESKTOP")
endif()
if(WITH_GL_SYSTEM_EMBEDDED)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_SYSTEM_EMBEDDED")
endif()
if(WITH_GPU_SAFETY)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GPU_SAFETY")
endif()
#-----------------------------------------------------------------------------
# Configure OpenMP.
@@ -2061,10 +2169,50 @@ if(WITH_SYSTEM_GLEW)
GLEW_INCLUDE_PATH
)
else()
# set(GLEW_LIBRARY "") # unused
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_STATIC -DGLEW_MX")
if(WITH_GLEW_ES)
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew-es/include")
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GLEW_ES")
# this isn't strictly required, but potentally makes GLEW smaller and helps catch unguarded API usage
if(NOT WITH_GL_PROFILE_ES20)
# no es functions are needed
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_NO_ES")
elseif(NOT (WITH_GL_PROFILE_CORE OR WITH_GL_PROFILE_COMPAT))
# es is enabled, but the other functions are all disabled
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_ES_ONLY")
endif()
if(WITH_GL_PROFILE_ES20)
if(WITH_GL_SYSTEM_EMBEDDED)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_USE_LIB_ES20")
endif()
# XXX jwilkins: this is just an experiment to eliminate ES 1 symbols,
# GLEW doesn't really properly provide this level of control (it eliminates too many symbols, for example),
# so there are lots of modifications to GLEW to make this work,
# and no attempt to make it work beyond Blender at this point
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGL_ES_VERSION_1_0=0")
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGL_ES_VERSION_CL_1_1=0")
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGL_ES_VERSION_CM_1_1=0")
endif()
if(WITH_GL_SYSTEM_EMBEDDED)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_INC_EGL")
endif()
else()
# this won't affect the normal glew library, but is used for conditional compilation elsewhere
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_NO_ES")
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
endif()
endif()
if(NOT WITH_GLU)
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_NO_GLU")
endif()
#-----------------------------------------------------------------------------
# Configure Bullet
@@ -2299,6 +2447,18 @@ if(WITH_GCC_MUDFLAP)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_ERROR_MUDFLAP -Wno-error=mudflap)
endif()
#-----------------------------------------------------------------------------
# Code Coverage
if(WITH_CODE_COVERAGE)
set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -fprofile-arcs -ftest-coverage")
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -fprofile-arcs -ftest-coverage")
if(CMAKE_COMPILER_IS_GNUCC)
set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lgcov")
endif()
endif()
#-----------------------------------------------------------------------------
# Include warnings first, so its possible to disable them with user defined flags
# eg: -Wno-uninitialized
set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
@@ -2462,6 +2622,19 @@ if(FIRST_RUN)
info_cfg_option(WITH_MOD_FLUID)
info_cfg_option(WITH_MOD_OCEANSIM)
info_cfg_text("OpenGL:")
info_cfg_option(WITH_GLEW_ES)
info_cfg_option(WITH_GLU)
info_cfg_option(WITH_GL_SYSTEM_DESKTOP)
info_cfg_option(WITH_GL_SYSTEM_EMBEDDED)
info_cfg_option(WITH_GL_PROFILE_COMPAT)
info_cfg_option(WITH_GL_PROFILE_CORE)
info_cfg_option(WITH_GL_PROFILE_ES20)
info_cfg_option(WITH_GPU_SAFETY)
if(WIN32)
info_cfg_option(WITH_ANGLE)
endif()
info_cfg_text("Other:")
info_cfg_option(WITH_OPENNL)

0
build_files/build_environment/install_deps.sh Executable file → Normal file
View File

0
build_files/build_environment/prepare_release_env.sh Executable file → Normal file
View File

View File

@@ -0,0 +1,52 @@
# - Try to find OpenGLES
# Once done this will define
#
# OPENGLES_FOUND - system has OpenGLES and EGL
# OPENGL_EGL_FOUND - system has EGL
# OPENGLES_INCLUDE_DIR - the GLES include directory
# OPENGLES_LIBRARY - the GLES library
# OPENGLES_EGL_INCLUDE_DIR - the EGL include directory
# OPENGLES_EGL_LIBRARY - the EGL library
# OPENGLES_LIBRARIES - all libraries needed for OpenGLES
# OPENGLES_INCLUDES - all includes needed for OpenGLES
FIND_PATH(OPENGLES_INCLUDE_DIR GLES2/gl2.h
/usr/openwin/share/include
/opt/graphics/OpenGL/include /usr/X11R6/include
/usr/include
)
FIND_LIBRARY(OPENGLES_LIBRARY
NAMES GLESv2
PATHS /opt/graphics/OpenGL/lib
/usr/openwin/lib
/usr/shlib /usr/X11R6/lib
/usr/lib
)
FIND_PATH(OPENGLES_EGL_INCLUDE_DIR EGL/egl.h
/usr/openwin/share/include
/opt/graphics/OpenGL/include /usr/X11R6/include
/usr/include
)
FIND_LIBRARY(OPENGLES_EGL_LIBRARY
NAMES EGL
PATHS /usr/shlib /usr/X11R6/lib
/usr/lib
)
SET(OPENGL_EGL_FOUND "NO")
IF(OPENGLES_EGL_LIBRARY AND OPENGLES_EGL_INCLUDE_DIR)
SET(OPENGL_EGL_FOUND "YES")
ENDIF()
SET(OPENGLES_FOUND "NO")
IF(OPENGLES_LIBRARY AND OPENGLES_INCLUDE_DIR AND
OPENGLES_EGL_LIBRARY AND OPENGLES_EGL_INCLUDE_DIR)
SET(OPENGLES_LIBRARIES ${OPENGLES_LIBRARY} ${OPENGLES_LIBRARIES}
${OPENGLES_EGL_LIBRARY})
SET(OPENGLES_INCLUDES ${OPENGLES_INCLUDE_DIR} ${OPENGLES_EGL_INCLUDE_DIR})
SET(OPENGLES_FOUND "YES")
ENDIF()

0
build_files/cmake/cmake_consistency_check.py Executable file → Normal file
View File

0
build_files/cmake/cmake_netbeans_project.py Executable file → Normal file
View File

0
build_files/cmake/cmake_qtcreator_project.py Executable file → Normal file
View File

View File

0
build_files/cmake/example_scripts/make_quicky.py Executable file → Normal file
View File

0
build_files/cmake/example_scripts/make_quiet.sh Executable file → Normal file
View File

View File

@@ -284,8 +284,7 @@ macro(setup_liblinks
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
target_link_libraries(${target}
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${GL_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${FREETYPE_LIBRARY})
@@ -359,9 +358,11 @@ macro(setup_liblinks
endif()
if(WITH_CODEC_FFMPEG)
# Strange!, without this ffmpeg gives linking errors (on linux)
# even though its linked above
target_link_libraries(${target} ${OPENGL_glu_LIBRARY})
# Strange! Without this ffmpeg gives linking errors (on linux),
# even though it's linked above.
if (WITH_GL_SYSTEM_LEGACY)
target_link_libraries(${target} ${OPENGL_glu_LIBRARY})
endif()
target_link_libraries(${target} ${FFMPEG_LIBRARIES})
endif()

0
build_files/cmake/project_info.py Executable file → Normal file
View File

0
build_files/package_spec/build_archive.py Executable file → Normal file
View File

0
build_files/package_spec/build_debian.sh Executable file → Normal file
View File

0
build_files/package_spec/debian/rules Executable file → Normal file
View File

0
doc/blender_file_format/BlendFileDnaExporter_25.py Executable file → Normal file
View File

0
doc/python_api/sphinx_doc_gen.sh Executable file → Normal file
View File

View File

@@ -47,7 +47,11 @@ if(WITH_BINRELOC)
endif()
if(NOT WITH_SYSTEM_GLEW)
add_subdirectory(glew)
if(WITH_GLEW_ES)
add_subdirectory(glew-es)
else()
add_subdirectory(glew)
endif()
endif()
if(WITH_GAMEENGINE)

0
extern/Eigen3/eigen-update.sh vendored Executable file → Normal file
View File

View File

View File

0
extern/carve/bundle.sh vendored Executable file → Normal file
View File

0
extern/carve/include/carve/win32.h vendored Executable file → Normal file
View File

0
extern/carve/mkfiles.sh vendored Executable file → Normal file
View File

50
extern/glew-es/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,50 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2013, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# ***** END GPL LICENSE BLOCK *****
set(INC
include
)
set(INC_SYS
)
if(UNIX)
list(APPEND INC_SYS
${X11_X11_INCLUDE_PATH}
)
endif()
set(SRC
src/glew.c
include/GL/eglew.h
include/GL/glesew.h
include/GL/glew.h
include/GL/glxew.h
include/GL/wglew.h
)
add_definitions(${GL_DEFINITIONS})
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}")

12
extern/glew-es/SConscript vendored Normal file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/python
import sys
import os
Import('env')
sources = ['src/glew.c']
defs = 'GLEW_STATIC'
incs = 'include'
env.BlenderLib ( 'extern_glew', sources, Split(incs), Split(defs), libtype=['extern','player'], priority=[50,230])

1384
extern/glew-es/include/GL/eglew.h vendored Normal file

File diff suppressed because it is too large Load Diff

4318
extern/glew-es/include/GL/glesew.h vendored Normal file

File diff suppressed because it is too large Load Diff

20525
extern/glew-es/include/GL/glew.h vendored Normal file

File diff suppressed because it is too large Load Diff

1649
extern/glew-es/include/GL/glxew.h vendored Normal file

File diff suppressed because it is too large Load Diff

1424
extern/glew-es/include/GL/wglew.h vendored Normal file

File diff suppressed because it is too large Load Diff

22392
extern/glew-es/src/glew.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -45,6 +45,6 @@ set(SRC
include/GL/wglew.h
)
add_definitions(-DGLEW_STATIC)
add_definitions(${GL_DEFINITIONS})
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}")

0
extern/libmv/bundle.sh vendored Executable file → Normal file
View File

0
extern/libmv/mkfiles.sh vendored Executable file → Normal file
View File

0
extern/libmv/third_party/ceres/bundle.sh vendored Executable file → Normal file
View File

0
extern/libmv/third_party/ceres/mkfiles.sh vendored Executable file → Normal file
View File

0
extern/libmv/third_party/glog/src/windows/preprocess.sh vendored Executable file → Normal file
View File

View File

@@ -21,8 +21,8 @@ set(LIBRARIES
cycles_util
${BOOST_LIBRARIES}
${OPENEXR_LIBRARIES}
${OPENGL_LIBRARIES}
${CYCLES_GLEW_LIBRARY}
${SYSTEM_GL_LIBRARIES}
${CYCLES_GLEW_LIBRARY} # XXX jwilkins, is this needed with the viewport fx re-factor?
${OPENIMAGEIO_LIBRARIES}
${PNG_LIBRARIES}
${JPEG_LIBRARIES}

View File

@@ -9,7 +9,7 @@ set(INC
)
set(INC_SYS
${OPENGL_INCLUDE_DIR}
${SYSTEM_GL_INCLUDE_DIR}
${GLEW_INCLUDE_PATH}
)

View File

@@ -60,7 +60,7 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
if(transparent) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* non-standard blend function */
}
glColor3f(1.0f, 1.0f, 1.0f);
@@ -127,8 +127,10 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
glPixelZoom(1.0f, 1.0f);
}
if(transparent)
if(transparent) {
glDisable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
}
}
Device *Device::create(DeviceInfo& info, Stats &stats, bool background)

View File

@@ -962,12 +962,12 @@ public:
else
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, (void*)offset);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
glEnable(GL_TEXTURE_2D);
if(transparent) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* non-standard blend function */
}
glColor3f(1.0f, 1.0f, 1.0f);
@@ -998,9 +998,11 @@ public:
draw_params.unbind_display_space_shader_cb();
}
if(transparent)
if(transparent) {
glDisable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
}
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);

View File

@@ -4,8 +4,8 @@ set(INC
)
set(INC_SYS
${SYSTEM_GL_INCLUDE_DIR}
${GLEW_INCLUDE_PATH}
${OPENGL_INCLUDE_DIR}
)
set(SRC
@@ -70,3 +70,7 @@ include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})
add_library(cycles_util ${SRC} ${SRC_HEADERS})
add_definitions(-DGLEW_STATIC)
add_definitions(-DGLEW_STATIC)

View File

@@ -38,6 +38,8 @@ set(SRC
intern/GHOST_Buttons.cpp
intern/GHOST_C-api.cpp
intern/GHOST_CallbackEventConsumer.cpp
intern/GHOST_Context.cpp
intern/GHOST_ContextNone.cpp
intern/GHOST_DisplayManager.cpp
intern/GHOST_EventManager.cpp
intern/GHOST_ISystem.cpp
@@ -63,6 +65,8 @@ set(SRC
intern/GHOST_Buttons.h
intern/GHOST_CallbackEventConsumer.h
intern/GHOST_Context.h
intern/GHOST_ContextNone.h
intern/GHOST_Debug.h
intern/GHOST_DisplayManager.h
intern/GHOST_Event.h
@@ -128,7 +132,6 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
add_definitions(-DWITH_GHOST_SDL)
endif()
# ack, this is still system dependant
if(APPLE)
list(APPEND SRC
@@ -149,7 +152,6 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
elseif(WIN32)
list(APPEND SRC
intern/GHOST_SystemPathsWin32.cpp
intern/GHOST_SystemPathsWin32.h
)
@@ -164,7 +166,16 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
)
endif()
elseif(APPLE)
else()
if(WITH_GL_SYSTEM_EMBEDDED)
list(APPEND SRC
intern/GHOST_ContextEGL.cpp
intern/GHOST_ContextEGL.h
)
endif()
if(APPLE)
list(APPEND SRC
intern/GHOST_DisplayManagerCocoa.mm
intern/GHOST_SystemCocoa.mm
@@ -176,127 +187,164 @@ elseif(APPLE)
intern/GHOST_SystemPathsCocoa.h
intern/GHOST_WindowCocoa.h
)
if (WITH_GL_SYSTEM_DESKTOP)
list(APPEND SRC
intern/GHOST_ContextCGL.mm
intern/GHOST_ContextCGL.h
)
endif()
if(WITH_INPUT_NDOF)
list(APPEND SRC
intern/GHOST_NDOFManagerCocoa.mm
intern/GHOST_NDOFManagerCocoa.h
)
list(APPEND SRC_NDOF3DCONNEXION
intern/GHOST_NDOFManager3Dconnexion.c
intern/GHOST_NDOFManager3Dconnexion.h
)
if (WITH_GL_SYSTEM_DESKTOP)
list(APPEND SRC
intern/GHOST_ContextAGL.cpp
intern/GHOST_ContextAGL.h
)
endif()
endif()
if(WITH_CODEC_QUICKTIME)
add_definitions(-DWITH_QUICKTIME)
endif()
elseif(UNIX)
list(APPEND INC_SYS
${X11_X11_INCLUDE_PATH}
)
endif()
if(WITH_CODEC_QUICKTIME)
add_definitions(-DWITH_QUICKTIME)
endif()
list(APPEND SRC
intern/GHOST_DisplayManagerX11.cpp
intern/GHOST_SystemX11.cpp
intern/GHOST_SystemPathsX11.cpp
intern/GHOST_WindowX11.cpp
elseif(UNIX)
intern/GHOST_DisplayManagerX11.h
intern/GHOST_SystemX11.h
intern/GHOST_SystemPathsX11.h
intern/GHOST_WindowX11.h
)
list(APPEND INC_SYS
${X11_X11_INCLUDE_PATH}
)
if (WITH_GL_SYSTEM_DESKTOP)
list(APPEND SRC
intern/GHOST_ContextXGL.cpp
intern/GHOST_ContextXGL.h
)
endif()
if(WITH_GHOST_XDND)
add_definitions(-DWITH_XDND)
list(APPEND SRC
intern/GHOST_DisplayManagerX11.cpp
intern/GHOST_SystemX11.cpp
intern/GHOST_SystemPathsX11.cpp
intern/GHOST_WindowX11.cpp
list(APPEND INC
../../extern/xdnd
)
intern/GHOST_DisplayManagerX11.h
intern/GHOST_SystemX11.h
intern/GHOST_SystemPathsX11.h
intern/GHOST_WindowX11.h
)
list(APPEND SRC
intern/GHOST_DropTargetX11.cpp
if(WITH_GHOST_XDND)
add_definitions(-DWITH_XDND)
intern/GHOST_DropTargetX11.h
)
endif()
if(X11_XF86keysym_INCLUDE_PATH)
add_definitions(-DWITH_XF86KEYSYM)
list(APPEND INC_SYS
${X11_XF86keysym_INCLUDE_PATH}
)
endif()
if(WITH_X11_XF86VMODE)
add_definitions(-DWITH_X11_XF86VMODE)
list(APPEND INC_SYS
${X11_xf86vmode_INCLUDE_PATH}
)
endif()
if(WITH_INPUT_NDOF)
list(APPEND SRC
intern/GHOST_NDOFManagerX11.cpp
intern/GHOST_NDOFManagerX11.h
)
endif()
if(NOT WITH_INSTALL_PORTABLE)
add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
endif()
if(WITH_X11_XINPUT)
add_definitions(-DWITH_X11_XINPUT)
list(APPEND INC_SYS
${X11_Xinput_INCLUDE_PATH}
)
endif()
elseif(WIN32)
## Warnings as errors, this is too strict!
#if(MSVC)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
#endif()
list(APPEND INC_SYS
${WINTAB_INC}
)
list(APPEND INC
../../extern/xdnd
../utfconv
)
list(APPEND SRC
intern/GHOST_DropTargetX11.cpp
intern/GHOST_DisplayManagerWin32.cpp
intern/GHOST_SystemWin32.cpp
intern/GHOST_SystemPathsWin32.cpp
intern/GHOST_WindowWin32.cpp
intern/GHOST_DropTargetWin32.cpp
intern/GHOST_DropTargetX11.h
intern/GHOST_DisplayManagerWin32.h
intern/GHOST_DropTargetWin32.h
intern/GHOST_SystemWin32.h
intern/GHOST_SystemPathsWin32.h
intern/GHOST_WindowWin32.h
intern/GHOST_TaskbarWin32.h
)
endif()
if(X11_XF86keysym_INCLUDE_PATH)
add_definitions(-DWITH_XF86KEYSYM)
list(APPEND INC_SYS
${X11_XF86keysym_INCLUDE_PATH}
)
endif()
if (WITH_GL_SYSTEM_DESKTOP)
list(APPEND SRC
intern/GHOST_ContextWGL.cpp
intern/GHOST_ContextWGL.h
)
endif()
if(WITH_INPUT_NDOF)
list(APPEND SRC
intern/GHOST_NDOFManagerWin32.cpp
if(WITH_X11_XF86VMODE)
add_definitions(-DWITH_X11_XF86VMODE)
list(APPEND INC_SYS
${X11_xf86vmode_INCLUDE_PATH}
)
endif()
intern/GHOST_NDOFManagerWin32.h
)
endif()
if(WITH_INPUT_NDOF)
list(APPEND SRC
intern/GHOST_NDOFManagerX11.cpp
intern/GHOST_NDOFManagerX11.h
)
endif()
if(NOT WITH_INSTALL_PORTABLE)
add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
endif()
if(WITH_X11_XINPUT)
add_definitions(-DWITH_X11_XINPUT)
list(APPEND INC_SYS
${X11_Xinput_INCLUDE_PATH}
)
endif()
elseif(WIN32)
## Warnings as errors, this is too strict!
#if(MSVC)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
#endif()
list(APPEND INC_SYS
${WINTAB_INC}
)
list(APPEND INC
../utfconv
)
list(APPEND SRC
intern/GHOST_DisplayManagerWin32.cpp
intern/GHOST_SystemWin32.cpp
intern/GHOST_SystemPathsWin32.cpp
intern/GHOST_WindowWin32.cpp
intern/GHOST_DropTargetWin32.cpp
intern/GHOST_DisplayManagerWin32.h
intern/GHOST_DropTargetWin32.h
intern/GHOST_SystemWin32.h
intern/GHOST_SystemPathsWin32.h
intern/GHOST_WindowWin32.h
intern/GHOST_TaskbarWin32.h
)
if(WITH_INPUT_NDOF)
list(APPEND SRC
intern/GHOST_NDOFManagerWin32.cpp
intern/GHOST_NDOFManagerWin32.h
)
endif()
endif()
add_definitions(-DGLEW_STATIC)
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -0,0 +1,177 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_Context.cpp
* \ingroup GHOST
* Definition of GHOST_Context class.
*/
#include "GHOST_Context.h"
#include <cstdio>
#include <cstring>
GLEWContext* glewContext = NULL;
const char* get_glew_error_message_string(GLenum error)
{
switch (error) {
case GLEW_OK: /* also GLEW_NO_ERROR */
return "OK";
case GLEW_ERROR_NO_GL_VERSION:
return "Unable to determine GL version.";
case GLEW_ERROR_GL_VERSION_10_ONLY:
return "OpenGL 1.1 or later is required.";
case GLEW_ERROR_GLX_VERSION_11_ONLY:
return "GLX 1.2 or later is required.";
#if WITH_GLEW_ES
case GLEW_ERROR_NOT_GLES_VERSION:
return "OpenGL ES is required.";
case GLEW_ERROR_GLES_VERSION:
return "A non-ES version of OpenGL is required.";
case GLEW_ERROR_NO_EGL_VERSION:
return "Unabled to determine EGL version.";
case GLEW_ERROR_EGL_VERSION_10_ONLY:
return "EGL 1.1 or later is required.";
#endif
default:
return NULL;
}
}
const char* get_glew_error_enum_string(GLenum error)
{
switch (error) {
case GLEW_OK: /* also GLEW_NO_ERROR */
return "GLEW_OK";
case GLEW_ERROR_NO_GL_VERSION:
return "GLEW_ERROR_NO_GL_VERSION";
case GLEW_ERROR_GL_VERSION_10_ONLY:
return "GLEW_ERROR_GL_VERSION_10_ONLY";
case GLEW_ERROR_GLX_VERSION_11_ONLY:
return "GLEW_ERROR_GLX_VERSION_11_ONLY";
#if WITH_GLEW_ES
case GLEW_ERROR_NOT_GLES_VERSION:
return "GLEW_ERROR_NOT_GLES_VERSION";
case GLEW_ERROR_GLES_VERSION:
return "GLEW_ERROR_GLES_VERSION";
case GLEW_ERROR_NO_EGL_VERSION:
return "GLEW_ERROR_NO_EGL_VERSION";
case GLEW_ERROR_EGL_VERSION_10_ONLY:
return "GLEW_ERROR_EGL_VERSION_10_ONLY";
#endif
default:
return NULL;
}
}
GLenum glew_chk(GLenum error, const char* file, int line, const char* text)
{
if (error != GLEW_OK) {
const char* code = get_glew_error_enum_string(error);
const char* msg = get_glew_error_message_string(error);
#ifndef NDEBUG
fprintf(
stderr,
"%s(%d):[%s] -> GLEW Error (0x%04X): %s: %s\n",
file,
line,
text,
error,
code ? code : "<no symbol>",
msg ? msg : "<no message>");
#else
fprintf(
stderr,
"GLEW Error (%04X): %s: %s\n",
error,
code ? code : "<no symbol>",
msg ? msg : "<no message>");
#endif
}
return error;
}
void GHOST_Context::initContextGLEW()
{
glewContext = new GLEWContext;
memset(glewContext, 0, sizeof(GLEWContext));
delete m_glewContext;
m_glewContext = glewContext;
GLEW_CHK(glewInit());
}
int GHOST_PixelFormat::computeWeight() const
{
return 0;
}
void GHOST_PixelFormat::print() const
{
}
int GHOST_PixelFormatChooser::choosePixelFormat(GHOST_PixelFormatChooser& factory)
{
return 0;
}

View File

@@ -0,0 +1,146 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_Context.h
* \ingroup GHOST
* Declaration of GHOST_Context class.
*/
#ifndef __GHOST_CONTEXT_H__
#define __GHOST_CONTEXT_H__
#include "GHOST_Types.h"
#define glewGetContext() glewContext
#include <GL/glew.h>
extern "C" GLEWContext* glewContext;
#include <cstdlib> // for NULL
class GHOST_Context
{
public:
/**
* Constructor.
*/
GHOST_Context()
: m_glewContext(NULL)
{}
/**
* Destructor.
*/
virtual ~GHOST_Context()
{
delete m_glewContext;
}
/**
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess swapBuffers() = 0;
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess activateDrawingContext() = 0;
/**
* Call immediately after new to initialize. If this fails then immediately delete the object.
* \param stereoVisual Stereo visual for quad buffered stereo.
* \param numOfAASamples Number of samples used for AA (zero if no AA)
* \return Indication as to whether initialization has succeeded.
*/
virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0) = 0;
/**
* Checks if it is OK for a remove the native display
* \return Indication as to whether removal has succeeded.
*/
virtual GHOST_TSuccess releaseNativeHandles() = 0;
protected:
void initContextGLEW();
void activateGLEW() const
{
glewContext = m_glewContext;
}
private:
GLEWContext* m_glewContext;
};
GLenum glew_chk(GLenum error, const char* file, int line, const char* text);
#ifndef NDEBUG
#define GLEW_CHK(x) glew_chk((x), __FILE__, __LINE__, #x)
#else
#define GLEW_CHK(x) x
#endif
class GHOST_PixelFormat {
public:
enum swap_t { UNKNOWN, COPY, EXCHANGE, UNDEFINED };
virtual bool isUsable() const = 0;
virtual int colorBits() const = 0;
virtual int alphaBits() const = 0;
virtual int depthBits() const = 0;
virtual int stencilBits() const = 0;
virtual int samples() const = 0;
virtual bool sRGB() const = 0;
virtual swap_t swapMethod() const = 0;
int computeWeight() const;
void print() const;
};
class GHOST_PixelFormatChooser {
public:
int choosePixelFormat(GHOST_PixelFormatChooser& factory);
protected:
virtual int safeChoosePixelFormat() const = 0;
virtual int count() const = 0;
virtual GHOST_PixelFormat* get(int i) const = 0;
};
#endif // __GHOST_CONTEXT_H__

View File

@@ -0,0 +1,32 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextAGL.cpp
* \ingroup GHOST
* Definition of GHOST_ContextAGL class.
*/

View File

@@ -0,0 +1,37 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextAGL.h
* \ingroup GHOST
* Declaration of GHOST_ContextAGL class.
*/
#ifndef __GHOST_CONTEXTAGL_H__
#define __GHOST_CONTEXTAGL_H__
#endif // __GHOST_CONTEXTAGL_H__

View File

@@ -0,0 +1,94 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextCGL.h
* \ingroup GHOST
* Declaration of GHOST_ContextCGL class.
*/
#ifndef __GHOST_CONTEXTCGL_H__
#define __GHOST_CONTEXTCGL_H__
#include "GHOST_Context.h"
#ifndef GHOST_OPENGL_CGL_CONTEXT_FLAGS
#define GHOST_OPENGL_CGL_CONTEXT_FLAGS 0
#endif
class GHOST_ContextCGL : public GHOST_Context
{
public:
/**
* Constructor.
*/
GHOST_ContextCGL(
int contextProfileMask = 0,
int contextMajorVersion = 0,
int contextMinorVersion = 0,
int contextFlags = GHOST_OPENGL_CGL_CONTEXT_FLAGS);
/**
* Destructor.
*/
virtual ~GHOST_ContextCGL();
/**
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess swapBuffers();
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess activateDrawingContext();
/**
* Call immediately after new to initialize. If this fails then immediately delete the object.
* \param stereoVisual Stereo visual for quad buffered stereo.
* \param numOfAASamples Number of samples used for AA (zero if no AA)
* \return Indication as to whether initialization has succeeded.
*/
virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0);
/**
* Checks if it is OK for a remove the native display
* \return Indication as to whether removal has succeeded.
*/
virtual GHOST_TSuccess releaseNativeHandles();
};
#endif // __GHOST_CONTEXTCGL_H__

View File

@@ -0,0 +1,79 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextCGL.mm
* \ingroup GHOST
* Definition of GHOST_ContextCGL class.
*/
#include "GHOST_ContextCGL.h"
GHOST_ContextCGL::GHOST_ContextCGL(
int contextProfileMask,
int contextMajorVersion,
int contextMinorVersion,
int contextFlags)
{
}
GHOST_ContextCGL::~GHOST_ContextCGL()
{
}
GHOST_TSuccess GHOST_ContextCGL::swapBuffers()
{
return GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextCGL::activateDrawingContext()
{
return GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext(bool stereoVisual, GHOST_TUns16 numOfAASamples)
{
return GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextCGL::releaseNativeHandles()
{
return GHOST_kFailure;
}

View File

@@ -0,0 +1,470 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextEGL.cpp
* \ingroup GHOST
* Definition of GHOST_ContextEGL class.
*/
#include "GHOST_ContextEGL.h"
#include <cassert>
#include <cstdio>
#include <vector>
EGLEWContext* eglewContext = NULL;
static const char* get_egl_error_enum_string(EGLenum error)
{
switch(error) {
case EGL_SUCCESS:
return "EGL_SUCCESS";
case EGL_NOT_INITIALIZED:
return "EGL_NOT_INITIALIZED";
case EGL_BAD_ACCESS:
return "EGL_BAD_ALLOC";
case EGL_BAD_ALLOC:
return "EGL_BAD_ALLOC";
case EGL_BAD_ATTRIBUTE:
return "EGL_BAD_ATTRIBUTE";
case EGL_BAD_CONTEXT:
return "EGL_BAD_CONTEXT";
case EGL_BAD_CONFIG:
return "EGL_BAD_CONFIG";
case EGL_BAD_CURRENT_SURFACE:
return "EGL_BAD_CURRENT_SURFACE";
case EGL_BAD_DISPLAY:
return "EGL_BAD_DISPLAY";
case EGL_BAD_SURFACE:
return "EGL_BAD_SURFACE";
case EGL_BAD_MATCH:
return "EGL_BAD_MATCH";
case EGL_BAD_PARAMETER:
return "EGL_BAD_PARAMETER";
case EGL_BAD_NATIVE_PIXMAP:
return "EGL_BAD_NATIVE_PIXMAP";
case EGL_BAD_NATIVE_WINDOW:
return "EGL_BAD_NATIVE_WINDOW";
case EGL_CONTEXT_LOST:
return "EGL_CONTEXT_LOST";
default:
return NULL;
}
}
static const char* get_egl_error_message_string(EGLenum error)
{
switch(error) {
case EGL_SUCCESS:
return "The last function succeeded without error.";
case EGL_NOT_INITIALIZED:
return "EGL is not initialized, or could not be initialized, for the specified EGL display connection.";
case EGL_BAD_ACCESS:
return "EGL cannot access a requested resource (for example a context is bound in another thread).";
case EGL_BAD_ALLOC:
return "EGL failed to allocate resources for the requested operation.";
case EGL_BAD_ATTRIBUTE:
return "An unrecognized attribute or attribute value was passed in the attribute list.";
case EGL_BAD_CONTEXT:
return "An EGLContext argument does not name a valid EGL rendering context.";
case EGL_BAD_CONFIG:
return "An EGLConfig argument does not name a valid EGL frame buffer configuration.";
case EGL_BAD_CURRENT_SURFACE:
return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid.";
case EGL_BAD_DISPLAY:
return "An EGLDisplay argument does not name a valid EGL display connection.";
case EGL_BAD_SURFACE:
return "An EGLSurface argument does not name a valid surface (window, pixel buffer or pixmap) configured for GL rendering.";
case EGL_BAD_MATCH:
return "Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).";
case EGL_BAD_PARAMETER:
return "One or more argument values are invalid.";
case EGL_BAD_NATIVE_PIXMAP:
return "A NativePixmapType argument does not refer to a valid native pixmap.";
case EGL_BAD_NATIVE_WINDOW:
return "A NativeWindowType argument does not refer to a valid native window.";
case EGL_CONTEXT_LOST:
return "A power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering.";
default:
return NULL;
}
}
static bool egl_chk(bool result, const char* file = NULL, int line = 0, const char* text = NULL)
{
if (!result) {
EGLenum error = eglGetError();
const char* code = get_egl_error_enum_string(error);
const char* msg = get_egl_error_message_string(error);
#ifndef NDEBUG
fprintf(
stderr,
"%s(%d):[%s] -> EGL Error (0x%04X): %s: %s\n",
file,
line,
text,
error,
code ? code : "<Unknown>",
msg ? msg : "<Unknown>");
#else
fprintf(
stderr,
"EGL Error (0x%04X): %s: %s\n",
error,
code ? code : "<Unknown>",
msg ? msg : "<Unknown>");
#endif
}
return result;
}
#ifndef NDEBUG
#define EGL_CHK(x) egl_chk((x), __FILE__, __LINE__, #x)
#else
#define EGL_CHK(x) egl_chk(x)
#endif
static inline void bindAPI(EGLenum api)
{
if (eglewContext != NULL && EGLEW_VERSION_1_2)
EGL_CHK(eglBindAPI(api));
}
#if defined(WITH_ANGLE)
HMODULE GHOST_ContextEGL::s_d3dcompiler = NULL;
#endif
EGLContext GHOST_ContextEGL::s_gl_sharedContext = NULL;
EGLint GHOST_ContextEGL::s_gl_sharedCount = 0;
EGLContext GHOST_ContextEGL::s_gles_sharedContext = NULL;
EGLint GHOST_ContextEGL::s_gles_sharedCount = 0;
EGLContext GHOST_ContextEGL::s_vg_sharedContext = NULL;
EGLint GHOST_ContextEGL::s_vg_sharedCount = 0;
#pragma warning(disable : 4715)
template <typename T>
T& choose_api(EGLenum api, T& a, T& b, T& c)
{
switch(api) {
case EGL_OPENGL_API:
return a;
case EGL_OPENGL_ES_API:
return b;
case EGL_OPENVG_API:
return c;
default:
abort();
}
}
GHOST_ContextEGL::GHOST_ContextEGL(
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLenum api,
EGLint contextClientVersion
)
: m_nativeWindow(nativeWindow)
, m_nativeDisplay(nativeDisplay)
, m_api(api)
, m_contextClientVersion(contextClientVersion)
, m_display(EGL_NO_DISPLAY)
, m_surface(EGL_NO_SURFACE)
, m_context(EGL_NO_CONTEXT)
, m_sharedContext(choose_api(api, s_gl_sharedContext, s_gles_sharedContext, s_vg_sharedContext))
, m_sharedCount (choose_api(api, s_gl_sharedCount, s_gles_sharedCount, s_vg_sharedCount))
, m_eglewContext(NULL)
{
assert(m_nativeWindow != NULL);
assert(m_nativeDisplay != NULL);
}
GHOST_ContextEGL::~GHOST_ContextEGL()
{
activateEGLEW();
bindAPI(m_api);
if (m_context != EGL_NO_CONTEXT) {
if (m_context == ::eglGetCurrentContext())
EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
if (m_context != m_sharedContext || m_sharedCount == 1) {
assert(m_sharedCount > 0);
m_sharedCount--;
if (m_sharedCount == 0)
m_sharedContext = EGL_NO_CONTEXT;
EGL_CHK(::eglDestroyContext(m_display, m_context));
}
}
if (m_surface != EGL_NO_SURFACE)
EGL_CHK(::eglDestroySurface(m_display, m_surface));
EGL_CHK(::eglTerminate(m_display));
delete m_eglewContext;
}
GHOST_TSuccess GHOST_ContextEGL::swapBuffers()
{
return EGL_CHK(eglSwapBuffers(m_display, m_surface)) ? GHOST_kSuccess : GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextEGL::activateDrawingContext()
{
activateEGLEW();
activateGLEW();
bindAPI(m_api);
return EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context)) ? GHOST_kSuccess : GHOST_kFailure;
}
void GHOST_ContextEGL::initContextEGLEW()
{
eglewContext = new EGLEWContext;
memset(eglewContext, 0, sizeof(EGLEWContext));
delete m_eglewContext;
m_eglewContext = eglewContext;
GLEW_CHK(eglewInit());
}
GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext(bool stereoVisual, GHOST_TUns16 numOfAASamples)
{
std::vector<EGLint> attrib_list;
if (stereoVisual)
fprintf(stderr, "Warning! Stereo OpenGL ES contexts are not supported.\n");
#if defined(WITH_ANGLE)
// d3dcompiler_XX.dll needs to be loaded before ANGLE will work
if (s_d3dcompiler == NULL) {
s_d3dcompiler = LoadLibrary(D3DCOMPILER);
if (s_d3dcompiler == NULL) {
printf("LoadLibrary(\"" D3DCOMPILER "\") failed!\n");
return GHOST_kFailure;
}
}
#endif
EGLDisplay prev_display = eglGetCurrentDisplay();
EGLSurface prev_draw = eglGetCurrentSurface(EGL_DRAW);
EGLSurface prev_read = eglGetCurrentSurface(EGL_READ);
EGLContext prev_context = eglGetCurrentContext();
m_display = ::eglGetDisplay(m_nativeDisplay);
if (!EGL_CHK(m_display != EGL_NO_DISPLAY))
return GHOST_kFailure;
EGLint major, minor;
if (!EGL_CHK(::eglInitialize(m_display, &major, &minor)))
goto error;
fprintf(stderr, "EGL Version %d.%d\n", major, minor);
if (!EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)))
goto error;
initContextEGLEW();
bindAPI(m_api);
attrib_list.reserve(20);
// The ARM mali ES emulator seems to need this to find a pixel fromat
// XXX jwilkins: mali also fails to initialize EGLEW because of a bug in eglGetCurrentDisplay(), so using major/minor instead of EGLEW_VERSION
if ((major == 1 && minor >= 2 || major > 1) && m_api == EGL_OPENGL_ES_API) {
if (m_contextClientVersion == 1) {
attrib_list.push_back(EGL_RENDERABLE_TYPE);
attrib_list.push_back(EGL_OPENGL_ES_BIT);
}
else if ((major == 1 && minor >= 3 || major > 1) && m_contextClientVersion == 2) {
attrib_list.push_back(EGL_RENDERABLE_TYPE);
attrib_list.push_back(EGL_OPENGL_ES2_BIT);
}
}
attrib_list.push_back(EGL_RED_SIZE);
attrib_list.push_back(8);
attrib_list.push_back(EGL_GREEN_SIZE);
attrib_list.push_back(8);
attrib_list.push_back(EGL_BLUE_SIZE);
attrib_list.push_back(8);
#ifdef GHOST_OPENGL_ALPHA
attrib_list.push_back(EGL_ALPHA_SIZE);
attrib_list.push_back(8);
#endif
attrib_list.push_back(EGL_DEPTH_SIZE);
attrib_list.push_back(24);
#ifdef GHOST_OPENGL_STENCIL
attrib_list.push_back(EGL_STENCIL_SIZE);
attrib_list.push_back(8);
#endif
if (numOfAASamples > 0) {
attrib_list.push_back(EGL_SAMPLE_BUFFERS);
attrib_list.push_back(1);
attrib_list.push_back(EGL_SAMPLES);
attrib_list.push_back(numOfAASamples);
}
attrib_list.push_back(EGL_NONE);
EGLConfig config;
EGLint num_config = 0;
if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &config, 1, &num_config)))
goto error;
// common error is to assume that ChooseConfig worked because it returned EGL_TRUE
if (num_config != 1) // num_config should be exactly 1
goto error;
m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL);
if (!EGL_CHK(m_surface != EGL_NO_SURFACE))
goto error;
attrib_list.clear();
if (m_api == EGL_OPENGL_ES_API && m_contextClientVersion != 0) {
attrib_list.push_back(EGL_CONTEXT_CLIENT_VERSION);
attrib_list.push_back(m_contextClientVersion);
}
attrib_list.push_back(EGL_NONE);
m_context = ::eglCreateContext(m_display, config, m_sharedContext, &(attrib_list[0]));
if (!EGL_CHK(m_context != EGL_NO_CONTEXT))
goto error;
if (m_sharedContext == EGL_NO_CONTEXT)
m_sharedContext = m_context;
m_sharedCount++;
if (!EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context)))
goto error;
// XXX jwilkins: do this again here for mali, since eglGetCurrentDisplay will now work
initContextEGLEW();
initContextGLEW();
return GHOST_kSuccess;
error:
EGL_CHK(eglMakeCurrent(prev_display, prev_draw, prev_read, prev_context));
return GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextEGL::releaseNativeHandles()
{
m_nativeWindow = NULL;
m_nativeDisplay = NULL;
return GHOST_kSuccess;
}

View File

@@ -0,0 +1,130 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextEGL.h
* \ingroup GHOST
* Declaration of GHOST_ContextEGL class.
*/
#ifndef __GHOST_CONTEXTEGL_H__
#define __GHOST_CONTEXTEGL_H__
#include "GHOST_Context.h"
#define eglewGetContext() eglewContext
#include <GL/eglew.h>
extern "C" EGLEWContext* eglewContext;
class GHOST_ContextEGL : public GHOST_Context
{
public:
/**
* Constructor.
*/
GHOST_ContextEGL(
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLenum api = 0,
EGLint contextClientVersion = 0
);
/**
* Destructor.
*/
virtual ~GHOST_ContextEGL();
/**
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess swapBuffers();
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess activateDrawingContext();
/**
* Tries to install a rendering context in this window.
* \param stereoVisual Stereo visual for quad buffered stereo.
* \param numOfAASamples Number of samples used for AA (zero if no AA)
* \return Indication as to whether installation has succeeded.
*/
virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0);
/**
* Removes references to native handles from this context and then returns
* GHOST_kSuccess if it is OK for the parent to release the handles
* and GHOST_kFailure if releasing the handles will interfere with sharing
* \return Indication as to whether removal has succeeded.
*/
virtual GHOST_TSuccess releaseNativeHandles();
protected:
void activateEGLEW() const
{
eglewContext = m_eglewContext;
}
private:
void initContextEGLEW();
EGLNativeDisplayType m_nativeDisplay;
EGLNativeWindowType m_nativeWindow;
const EGLenum m_api;
const EGLint m_contextClientVersion;
EGLContext m_context;
EGLSurface m_surface;
EGLDisplay m_display;
EGLContext& m_sharedContext;
EGLint& m_sharedCount;
EGLEWContext* m_eglewContext;
static EGLContext s_gl_sharedContext;
static EGLint s_gl_sharedCount;
static EGLContext s_gles_sharedContext;
static EGLint s_gles_sharedCount;
static EGLContext s_vg_sharedContext;
static EGLint s_vg_sharedCount;
#if defined(WITH_ANGLE)
static HMODULE s_d3dcompiler;
#endif
};
#endif // __GHOST_CONTEXTEGL_H__

View File

@@ -0,0 +1,61 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextNone.cpp
* \ingroup GHOST
* Definition of GHOST_ContextNone class.
*/
#include "GHOST_ContextNone.h"
GHOST_TSuccess GHOST_ContextNone::swapBuffers()
{
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextNone::activateDrawingContext()
{
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextNone::initializeDrawingContext(bool, GHOST_TUns16)
{
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextNone::releaseNativeHandles()
{
return GHOST_kSuccess;
}

View File

@@ -0,0 +1,72 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextNone.h
* \ingroup GHOST
* Declaration of GHOST_Context class.
*/
#ifndef __GHOST_CONTEXTNONE_H__
#define __GHOST_CONTEXTNONE_H__
#include "GHOST_Context.h"
class GHOST_ContextNone : public GHOST_Context
{
public:
/**
* Dummy function
* \return Always succeeds
*/
virtual GHOST_TSuccess swapBuffers();
/**
* Dummy function
* \return Always succeeds
*/
virtual GHOST_TSuccess activateDrawingContext();
/**
* Dummy function
* \param stereoVisual ignored
* \param numOfAASamples ignored
* \return Always succeeds
*/
virtual GHOST_TSuccess initializeDrawingContext(bool = false, GHOST_TUns16 = 0);
/**
* Dummy function
* \return Always succeeds
*/
GHOST_TSuccess releaseNativeHandles();
};
#endif // __GHOST_CONTEXTNONE_H__

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,162 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextWGL.h
* \ingroup GHOST
* Declaration of GHOST_ContextWGL class.
*/
#ifndef __GHOST_CONTEXTWGL_H__
#define __GHOST_CONTEXTWGL_H__
#include "GHOST_Context.h"
#define wglewGetContext() wglewContext
#include <GL/wglew.h>
extern "C" WGLEWContext* wglewContext;
#ifndef GHOST_OPENGL_WGL_CONTEXT_FLAGS
#define GHOST_OPENGL_WGL_CONTEXT_FLAGS 0
#endif
class GHOST_ContextWGL : public GHOST_Context
{
public:
/**
* Constructor.
*/
GHOST_ContextWGL(
HWND hWnd,
HDC hDC,
int contextProfileMask = 0,
int contextMajorVersion = 0,
int contextMinorVersion = 0,
int contextFlags = GHOST_OPENGL_WGL_CONTEXT_FLAGS);
/**
* Destructor.
*/
virtual ~GHOST_ContextWGL();
/**
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess swapBuffers();
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess activateDrawingContext();
/**
* Call immediately after new to initialize. If this fails then immediately delete the object.
* \param stereoVisual Stereo visual for quad buffered stereo.
* \param numOfAASamples Number of samples used for AA (zero if no AA)
* \return Indication as to whether initialization has succeeded.
*/
virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0);
/**
* Checks if it is OK for a remove the native display
* \return Indication as to whether removal has succeeded.
*/
virtual GHOST_TSuccess releaseNativeHandles();
protected:
void activateWGLEW() const
{
wglewContext = m_wglewContext;
}
private:
int choose_pixel_format(
bool stereoVisual,
int numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB);
int choose_pixel_format_arb(
bool stereoVisual,
int numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB);
int _choose_pixel_format_arb_1(
bool stereoVisual,
int numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB,
int& swapMethodOut);
int _choose_pixel_format_arb_2(
bool stereoVisual,
int numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB,
int swapMethod);
void initContextWGLEW(PIXELFORMATDESCRIPTOR& preferredPFD);
HDC m_hDC;
HWND m_hWnd;
int m_contextProfileMask;
int m_contextMajorVersion;
int m_contextMinorVersion;
int m_contextFlags;
HGLRC m_hGLRC;
bool m_needSetPixelFormat;
WGLEWContext* m_wglewContext;
#ifndef NDEBUG
const char* m_dummyVendor;
const char* m_dummyRenderer;
const char* m_dummyVersion;
#endif
static HGLRC s_sharedHGLRC;
static int s_sharedCount;
static bool s_singleContextMode;
};
#endif // __GHOST_CONTEXTWGL_H__

View File

@@ -0,0 +1,32 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextXGL.cpp
* \ingroup GHOST
* Definition of GHOST_ContextXGL class.
*/

View File

@@ -0,0 +1,37 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_ContextXGL.h
* \ingroup GHOST
* Declaration of GHOST_ContextXGL class.
*/
#ifndef __GHOST_CONTEXTXGL_H__
#define __GHOST_CONTEXTXGL_H__
#endif // __GHOST_CONTEXTXGL_H__

View File

@@ -219,39 +219,28 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(
GHOST_TWindowState state, GHOST_TDrawingContextType type,
bool stereoVisual, const bool exclusive, const GHOST_TUns16 numOfAASamples, const GHOST_TEmbedderWindowID parentWindow)
{
GHOST_Window *window = 0;
window = new GHOST_WindowWin32(this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples, parentWindow);
if (window) {
if (window->getValid()) {
// Store the pointer to the window
// if (state != GHOST_kWindowStateFullScreen) {
GHOST_Window *window =
new GHOST_WindowWin32(
this,
title,
left,
top,
width,
height,
state,
type,
stereoVisual,
numOfAASamples,
parentWindow);
if (window && window->getValid()) {
// Store the pointer to the window
//if (state != GHOST_kWindowStateFullScreen) {
m_windowManager->addWindow(window);
m_windowManager->setActiveWindow(window);
// }
}
else {
// Invalid parent window hwnd
if (((GHOST_WindowWin32 *)window)->getNextWindow() == NULL) {
delete window;
window = 0;
return window;
}
// An invalid window could be one that was used to test for AA
window = ((GHOST_WindowWin32 *)window)->getNextWindow();
// If another window is found, let the wm know about that one, but not the old one
if (window->getValid()) {
m_windowManager->addWindow(window);
}
else {
delete window;
window = 0;
}
}
//}
}
return window;
}

View File

@@ -34,7 +34,6 @@
#define __GHOST_SYSTEMX11_H__
#include <X11/Xlib.h>
#include <GL/glx.h>
#include "GHOST_System.h"
#include "../GHOST_Types.h"

View File

@@ -38,22 +38,26 @@
#include "GHOST_Window.h"
#include "GHOST_ContextNone.h"
#include <assert.h>
GHOST_Window::GHOST_Window(
GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
const bool stereoVisual,
const bool exclusive,
const GHOST_TUns16 numOfAASamples)
:
m_drawingContextType(type),
m_cursorVisible(true),
m_cursorGrab(GHOST_kGrabDisable),
m_cursorShape(GHOST_kStandardCursorDefault),
m_stereoVisual(stereoVisual),
m_numOfAASamples(numOfAASamples)
const GHOST_TUns16 numOfAASamples
)
: m_drawingContextType(GHOST_kDrawingContextTypeNone)
, m_cursorVisible(true)
, m_cursorGrab(GHOST_kGrabDisable)
, m_cursorShape(GHOST_kStandardCursorDefault)
, m_stereoVisual(stereoVisual)
, m_numOfAASamples(numOfAASamples)
, m_context(new GHOST_ContextNone())
{
m_isUnsavedChanges = false;
m_canAcceptDragOperation = false;
@@ -66,6 +70,7 @@ GHOST_Window::GHOST_Window(
m_nativePixelSize = 1.0f;
m_fullScreen = state == GHOST_kWindowStateFullScreen;
if (m_fullScreen) {
m_fullScreenWidth = width;
m_fullScreenHeight = height;
@@ -73,31 +78,65 @@ GHOST_Window::GHOST_Window(
}
GHOST_Window::~GHOST_Window()
{
delete m_context;
}
void *GHOST_Window::getOSWindow() const
{
return NULL;
}
GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType type)
{
GHOST_TSuccess success = GHOST_kSuccess;
if (type != m_drawingContextType) {
success = removeDrawingContext();
if (success) {
success = installDrawingContext(type);
delete m_context;
m_context = NULL;
if (type != GHOST_kDrawingContextTypeNone)
m_context = newDrawingContext(type);
if (m_context != NULL) {
m_drawingContextType = type;
}
else {
m_context = new GHOST_ContextNone();
m_drawingContextType = GHOST_kDrawingContextTypeNone;
}
return (type == m_drawingContextType) ? GHOST_kSuccess : GHOST_kFailure;
}
else {
return GHOST_kSuccess;
}
return success;
}
GHOST_TSuccess GHOST_Window::swapBuffers()
{
return m_context->swapBuffers();
}
GHOST_TSuccess GHOST_Window::activateDrawingContext()
{
return m_context->activateDrawingContext();
}
GHOST_TSuccess GHOST_Window::releaseNativeHandles()
{
return m_context->releaseNativeHandles();
}
GHOST_TSuccess GHOST_Window::setCursorVisibility(bool visible)
{
if (setWindowCursorVisibility(visible)) {

View File

@@ -36,6 +36,7 @@
#include "GHOST_IWindow.h"
class STR_String;
class GHOST_Context;
/**
* Platform independent implementation of GHOST_IWindow.
@@ -66,10 +67,8 @@ public:
* virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
* virtual GHOST_TWindowOrder getOrder(void) = 0;
* virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
* virtual GHOST_TSuccess swapBuffers() = 0;
* virtual GHOST_TSuccess setSwapInterval() = 0;
* virtual int getSwapInterval() = 0;
* virtual GHOST_TSuccess activateDrawingContext() = 0;
* virtual GHOST_TSuccess invalidate() = 0;
*/
@@ -90,35 +89,13 @@ public:
GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
const bool stereoVisual = false,
const bool exclusive = false,
const GHOST_TUns16 numOfAASamples = 0);
/**
* \section Interface inherited from GHOST_IWindow left for derived class
* implementation.
* virtual bool getValid() const = 0;
* virtual void setTitle(const STR_String& title) = 0;
* virtual void getTitle(STR_String& title) const = 0;
* virtual void getWindowBounds(GHOST_Rect& bounds) const = 0;
* virtual void getClientBounds(GHOST_Rect& bounds) const = 0;
* virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width) = 0;
* virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height) = 0;
* virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) = 0;
* virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
* virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
* virtual GHOST_TWindowState getState() const = 0;
* virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
* virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
* virtual GHOST_TSuccess swapBuffers() = 0;
* virtual GHOST_TSuccess setSwapInterval() = 0;
* virtual int getSwapInterval() = 0;
* virtual GHOST_TSuccess activateDrawingContext() = 0;
* virtual GHOST_TSuccess invalidate() = 0;
*/
/**
* Destructor.
* Closes the window and disposes resources allocated.
*/
@@ -257,13 +234,25 @@ public:
/**
* Tries to install a rendering context in this window.
* Child classes do not need to overload this method.
* They should overload the installDrawingContext and removeDrawingContext instead.
* Child classes do not need to overload this method,
* They should overload newDrawingContext instead.
* \param type The type of rendering context installed.
* \return Indication as to whether installation has succeeded.
*/
virtual GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type);
/**
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess swapBuffers();
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess activateDrawingContext();
/**
* Returns the window user data.
* \return The window user data.
@@ -295,13 +284,7 @@ protected:
* \param type The type of rendering context installed.
* \return Indication as to whether installation has succeeded.
*/
virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type) = 0;
/**
* Removes the current drawing context.
* \return Indication as to whether removal has succeeded.
*/
virtual GHOST_TSuccess removeDrawingContext() = 0;
virtual GHOST_Context* newDrawingContext(GHOST_TDrawingContextType type) = 0;
/**
* Sets the cursor visibility on the window using
@@ -333,6 +316,9 @@ protected:
virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
int szx, int szy, int hotX, int hotY, int fg, int bg) = 0;
GHOST_TSuccess releaseNativeHandles();
/** The the of drawing context installed in this window. */
GHOST_TDrawingContextType m_drawingContextType;
@@ -385,6 +371,9 @@ protected:
/* OSX only, retina screens */
float m_nativePixelSize;
private:
GHOST_Context* m_context;
};

View File

@@ -42,6 +42,9 @@
@class CocoaWindow;
@class CocoaOpenGLView;
@class NSCursor;
@class NSOpenGLContext;
@class NSScreen;
class GHOST_SystemCocoa;
@@ -278,18 +281,24 @@ public:
bool getImmediateDraw(void) const { return m_immediateDraw; }
protected:
/**
* Tries to install a rendering context in this window.
* \param type The type of rendering context installed.
* \return Indication as to whether installation has succeeded.
*/
virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
///**
// * Tries to install a rendering context in this window.
// * \param type The type of rendering context installed.
// * \return Indication as to whether installation has succeeded.
// */
//virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
/**
* Removes the current drawing context.
* \return Indication as to whether removal has succeeded.
* \param type The type of rendering context create.
* \return Indication of success.
*/
virtual GHOST_TSuccess removeDrawingContext();
virtual GHOST_Context* newDrawingContext(GHOST_TDrawingContextType type);
///**
// * Removes the current drawing context.
// * \return Indication as to whether removal has succeeded.
// */
//virtual GHOST_TSuccess removeDrawingContext();
/**
* Invalidates the contents of this window.

View File

@@ -20,12 +20,26 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): Maarten Gribnau 05/2001
Damien Plisson 10/2009
* Contributor(s): Maarten Gribnau 05/2001
* Damien Plisson 10/2009
* Jason Wilkins 02/2014
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "GHOST_WindowCocoa.h"
#include "GHOST_SystemCocoa.h"
#include "GHOST_ContextNone.h"
#include "GHOST_Debug.h"
#if defined(WITH_GL_SYSTEM_DESKTOP)
#include "GHOST_ContextCGL.h"
#endif
#if defined(WITH_GL_SYSTEM_EMBEDDED)
#include "GHOST_ContextEGL.h"
#endif
#include <Cocoa/Cocoa.h>
#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1050
@@ -33,17 +47,14 @@
#include <Carbon/Carbon.h>
#endif
#include <OpenGL/gl.h>
#include <OpenGL/CGLRenderers.h>
//#include <OpenGL/gl.h>
//#include <OpenGL/CGLRenderers.h>
/***** Multithreaded opengl code : uncomment for enabling
#include <OpenGL/OpenGL.h>
*/
#include "GHOST_WindowCocoa.h"
#include "GHOST_SystemCocoa.h"
#include "GHOST_Debug.h"
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
/* Lion style fullscreen support when building with the 10.6 SDK */
enum {
@@ -546,7 +557,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
GHOST_TDrawingContextType type,
const bool stereoVisual, const GHOST_TUns16 numOfAASamples
) :
GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual, false, numOfAASamples),
GHOST_Window(width, height, state, stereoVisual, false, numOfAASamples),
m_customCursor(0)
{
NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[40];
@@ -596,9 +607,9 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
pixelFormatAttrsWindow[i++] = NSOpenGLPFABackingStore;
// Force software OpenGL, for debugging
if (getenv("BLENDER_SOFTWAREGL")) {
if (getenv("BLENDER_SOFTWAREGL")) { // XXX jwilkins: fixed this to work on Intel macs? useful feature for Windows and Linux too? Maybe a command line flag is better...
pixelFormatAttrsWindow[i++] = NSOpenGLPFARendererID;
pixelFormatAttrsWindow[i++] = kCGLRendererAppleSWID;
pixelFormatAttrsWindow[i++] = kCGLRendererGenericFloatID;
}
else
pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated;
@@ -629,7 +640,8 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
pixelFormatAttrsWindow[i] = (NSOpenGLPixelFormatAttribute) 0;
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttrsWindow];
// XXX jwilkins: this code seems to have a lot of duplication from above?
//Fall back to no multisampling if Antialiasing init failed
if (pixelFormat == nil) {
@@ -641,9 +653,9 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
pixelFormatAttrsWindow[i++] = NSOpenGLPFABackingStore;
// Force software OpenGL, for debugging
if (getenv("BLENDER_SOFTWAREGL")) {
if (getenv("BLENDER_SOFTWAREGL")) {// XXX jwilkins: fixed this to work on Intel macs? useful feature for Windows and Linux too? Maybe a command line flag is better...
pixelFormatAttrsWindow[i++] = NSOpenGLPFARendererID;
pixelFormatAttrsWindow[i++] = kCGLRendererAppleSWID;
pixelFormatAttrsWindow[i++] = kCGLRendererGenericFloatID;
}
else
pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated;
@@ -1307,7 +1319,7 @@ GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext()
return GHOST_kFailure;
}
#if 0
GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextType type)
{
GHOST_TSuccess success = GHOST_kFailure;
@@ -1387,6 +1399,51 @@ GHOST_TSuccess GHOST_WindowCocoa::removeDrawingContext()
return GHOST_kFailure;
}
}
#endif
GHOST_Context* GHOST_WindowCocoa::newDrawingContext(GHOST_TDrawingContextType type)
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
#if defined(WITH_GL_SYSTEM_DESKTOP)
#if defined(WITH_GL_PROFILE_CORE)
// XXX jwilkins: some implementations will only give you 3.2 even if later compatible versions are available
GHOST_Context* context = new GHOST_ContextCGL(WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 3, 2);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context* context = new GHOST_ContextCGL(WGL_CONTEXT_ES2_PROFILE_BIT_EXT, 2, 0);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context* context = new GHOST_ContextCGL();
#else
#error
#endif
#elif defined(WITH_GL_SYSTEM_EMBEDDED)
#if defined(WITH_GL_PROFILE_CORE)
// XXX jwilkins: not sure yet how to request a core context from EGL
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_API);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_ES_API, 2);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_API);
#else
#error
#endif
#else
#error
#endif
if (context->initializeDrawingContext(m_stereoVisual, m_numOfAASamples))
return context;
else
delete context;
}
return NULL;
}
GHOST_TSuccess GHOST_WindowCocoa::invalidate()

View File

@@ -29,82 +29,34 @@
* \ingroup GHOST
*/
#include <string.h>
#define _USE_MATH_DEFINES
#include "GHOST_WindowWin32.h"
#include "GHOST_SystemWin32.h"
#include "GHOST_DropTargetWin32.h"
#include "GHOST_ContextNone.h"
#include "utfconv.h"
#include "utf_winfunc.h"
// Need glew for some defines
#include <GL/glew.h>
#include <GL/wglew.h>
#include <math.h>
// MSVC6 still doesn't define M_PI
#ifndef M_PI
# define M_PI 3.1415926536
#if defined(WITH_GL_SYSTEM_DESKTOP)
#include "GHOST_ContextWGL.h"
#endif
// Some more multisample defines
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#if defined(WITH_GL_SYSTEM_EMBEDDED)
#include "GHOST_ContextEGL.h"
#endif
#include <math.h>
#include <string.h>
#include <assert.h>
const wchar_t *GHOST_WindowWin32::s_windowClassName = L"GHOST_WindowClass";
const int GHOST_WindowWin32::s_maxTitleLength = 128;
HGLRC GHOST_WindowWin32::s_firsthGLRc = NULL;
HDC GHOST_WindowWin32::s_firstHDC = NULL;
static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd);
static int EnumPixelFormats(HDC hdc);
/*
* Color and depth bit values are not to be trusted.
* For instance, on TNT2:
* When the screen color depth is set to 16 bit, we get 5 color bits
* and 16 depth bits.
* When the screen color depth is set to 32 bit, we get 8 color bits
* and 24 depth bits.
* Just to be safe, we request high waulity settings.
*/
static PIXELFORMATDESCRIPTOR sPreferredFormat = {
sizeof(PIXELFORMATDESCRIPTOR), /* size */
1, /* version */
PFD_SUPPORT_OPENGL |
PFD_DRAW_TO_WINDOW |
PFD_SWAP_COPY | /* support swap copy */
PFD_DOUBLEBUFFER, /* support double-buffering */
PFD_TYPE_RGBA, /* color type */
32, /* prefered color depth */
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
0, /* no alpha buffer */
0, /* alpha bits (ignored) */
0, /* no accumulation buffer */
0, 0, 0, 0, /* accum bits (ignored) */
32, /* depth buffer */
0, /* no stencil buffer */
0, /* no auxiliary buffers */
PFD_MAIN_PLANE, /* main layer */
0, /* reserved */
0, 0, 0 /* no layer, visible, damage masks */
};
/* Intel videocards don't work fine with multiple contexts and
* have to share the same context for all windows.
* But if we just share context for all windows it could work incorrect
* with multiple videocards configuration. Suppose, that Intel videocards
* can't be in multiple-devices configuration. */
static int is_crappy_intel_card(void)
{
static short is_crappy = -1;
if (is_crappy == -1) {
const char *vendor = (const char *)glGetString(GL_VENDOR);
is_crappy = (strstr(vendor, "Intel") != NULL);
}
return is_crappy;
}
/* force NVidia Optimus to used dedicated graphics */
extern "C" {
@@ -122,16 +74,14 @@ GHOST_WindowWin32::GHOST_WindowWin32(
GHOST_TDrawingContextType type,
const bool stereoVisual,
const GHOST_TUns16 numOfAASamples,
GHOST_TEmbedderWindowID parentwindowhwnd,
GHOST_TSuccess msEnabled,
int msPixelFormat)
:
GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone,
stereoVisual, false, numOfAASamples),
GHOST_TEmbedderWindowID parentwindowhwnd
//GHOST_TSuccess msEnabled,
//int msPixelFormat
)
: GHOST_Window(width, height, state, stereoVisual, false, numOfAASamples),
m_inLiveResize(false),
m_system(system),
m_hDC(0),
m_hGlRc(0),
m_hasMouseCaptured(false),
m_hasGrabMouse(false),
m_nPressedButtons(0),
@@ -140,18 +90,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
m_tabletData(NULL),
m_tablet(0),
m_maxPressure(0),
m_multisample(numOfAASamples),
m_multisampleEnabled(msEnabled),
m_msPixelFormat(msPixelFormat),
//For recreation
m_title(title),
m_left(left),
m_top(top),
m_width(width),
m_height(height),
m_normal_state(GHOST_kWindowStateNormal),
m_stereo(stereoVisual),
m_nextWindow(NULL),
m_parentWindowHwnd(parentwindowhwnd)
{
OSVERSIONINFOEX versionInfo;
@@ -272,6 +211,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
0); // pointer to window-creation data
free(title_16);
}
if (m_hWnd) {
// Register this window as a droptarget. Requires m_hWnd to be valid.
// Note that OleInitialize(0) has to be called prior to this. Done in GHOST_SystemWin32.
@@ -286,36 +226,33 @@ GHOST_WindowWin32::GHOST_WindowWin32(
// Store the device context
m_hDC = ::GetDC(m_hWnd);
if (!s_firstHDC) {
s_firstHDC = m_hDC;
}
GHOST_TSuccess success = setDrawingContextType(type);
// Show the window
int nCmdShow;
switch (state) {
case GHOST_kWindowStateMaximized:
nCmdShow = SW_SHOWMAXIMIZED;
break;
case GHOST_kWindowStateMinimized:
nCmdShow = SW_SHOWMINIMIZED;
break;
case GHOST_kWindowStateNormal:
default:
nCmdShow = SW_SHOWNORMAL;
break;
}
GHOST_TSuccess success;
success = setDrawingContextType(type);
if (success) {
// Show the window
int nCmdShow;
switch (state) {
case GHOST_kWindowStateMaximized:
nCmdShow = SW_SHOWMAXIMIZED;
break;
case GHOST_kWindowStateMinimized:
nCmdShow = SW_SHOWMINIMIZED;
break;
case GHOST_kWindowStateNormal:
default:
nCmdShow = SW_SHOWNORMAL;
break;
}
if (success)
{
::ShowWindow(m_hWnd, nCmdShow);
// Force an initial paint of the window
::UpdateWindow(m_hWnd);
}
else {
//invalidate the window
m_hWnd = 0;
::DestroyWindow(m_hWnd);
m_hWnd = NULL;
}
}
@@ -394,11 +331,10 @@ GHOST_WindowWin32::GHOST_WindowWin32(
GHOST_WindowWin32::~GHOST_WindowWin32()
{
if (m_Bar)
{
if (m_Bar) {
m_Bar->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
m_Bar->Release();
};
}
if (m_wintab) {
GHOST_WIN32_WTClose fpWTClose = (GHOST_WIN32_WTClose) ::GetProcAddress(m_wintab, "WTClose");
@@ -410,19 +346,15 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
m_tabletData = NULL;
}
}
if (m_customCursor) {
DestroyCursor(m_customCursor);
m_customCursor = NULL;
}
::wglMakeCurrent(NULL, NULL);
m_multisampleEnabled = GHOST_kFailure;
m_multisample = 0;
setDrawingContextType(GHOST_kDrawingContextTypeNone);
if (m_hDC && m_hDC != s_firstHDC) {
if (m_hWnd != NULL && m_hDC != NULL && releaseNativeHandles())
::ReleaseDC(m_hWnd, m_hDC);
m_hDC = 0;
}
if (m_hWnd) {
if (m_dropTarget) {
// Disable DragDrop
@@ -436,11 +368,6 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
}
}
GHOST_Window *GHOST_WindowWin32::getNextWindow()
{
return m_nextWindow;
}
bool GHOST_WindowWin32::getValid() const
{
return m_hWnd != 0;
@@ -651,16 +578,6 @@ GHOST_TSuccess GHOST_WindowWin32::setOrder(GHOST_TWindowOrder order)
}
GHOST_TSuccess GHOST_WindowWin32::swapBuffers()
{
HDC hDC = m_hDC;
if (is_crappy_intel_card())
hDC = ::wglGetCurrentDC();
return ::SwapBuffers(hDC) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
GHOST_TSuccess GHOST_WindowWin32::setSwapInterval(int interval)
{
if (!WGL_EXT_swap_control)
@@ -676,24 +593,6 @@ int GHOST_WindowWin32::getSwapInterval()
return 0;
}
GHOST_TSuccess GHOST_WindowWin32::activateDrawingContext()
{
GHOST_TSuccess success;
if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
if (m_hDC && m_hGlRc) {
success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
else {
success = GHOST_kFailure;
}
}
else {
success = GHOST_kSuccess;
}
return success;
}
GHOST_TSuccess GHOST_WindowWin32::invalidate()
{
GHOST_TSuccess success;
@@ -706,266 +605,58 @@ GHOST_TSuccess GHOST_WindowWin32::invalidate()
return success;
}
GHOST_TSuccess GHOST_WindowWin32::initMultisample(PIXELFORMATDESCRIPTOR pfd)
{
int pixelFormat;
bool success = FALSE;
UINT numFormats;
HDC hDC = GetDC(getHWND());
float fAttributes[] = {0, 0};
UINT nMaxFormats = 1;
// The attributes to look for
int iAttributes[] = {
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB, pfd.cColorBits,
WGL_DEPTH_BITS_ARB, pfd.cDepthBits,
#ifdef GHOST_OPENGL_ALPHA
WGL_ALPHA_BITS_ARB, pfd.cAlphaBits,
GHOST_Context* GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType type)
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
#if defined(WITH_GL_SYSTEM_DESKTOP)
#if defined(WITH_GL_PROFILE_CORE)
// XXX jwilkins: some implementations will only give you 3.2 even if later compatible versions are available
GHOST_Context* context = new GHOST_ContextWGL(m_hWnd, m_hDC, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 3, 2);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context* context = new GHOST_ContextWGL(m_hWnd, m_hDC, WGL_CONTEXT_ES2_PROFILE_BIT_EXT, 2, 0);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context* context = new GHOST_ContextWGL(m_hWnd, m_hDC);
#else
#error
#endif
WGL_STENCIL_BITS_ARB, pfd.cStencilBits,
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
WGL_SAMPLES_ARB, m_multisample,
0, 0
};
// Get the function
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
#elif defined(WITH_GL_SYSTEM_EMBEDDED)
if (!wglChoosePixelFormatARB)
{
m_multisampleEnabled = GHOST_kFailure;
return GHOST_kFailure;
#if defined(WITH_GL_PROFILE_CORE)
// XXX jwilkins: not sure yet how to request a core context from EGL
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_API);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_ES_API, 2);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_API);
#else
#error
#endif
#else
#error
#endif
if (context->initializeDrawingContext(m_stereoVisual, m_numOfAASamples))
return context;
else
delete context;
}
// iAttributes[17] is the initial multisample. If not valid try to use the closest valid value under it.
while (iAttributes[17] > 0) {
// See if the format is valid
success = wglChoosePixelFormatARB(hDC, iAttributes, fAttributes, nMaxFormats, &pixelFormat, &numFormats);
GHOST_PRINTF("WGL_SAMPLES_ARB = %i --> success = %i, %i formats\n", iAttributes[17], success, numFormats);
if (success && numFormats >= 1 && m_multisampleEnabled == GHOST_kFailure) {
GHOST_PRINTF("valid pixel format with %i multisamples\n", iAttributes[17]);
m_multisampleEnabled = GHOST_kSuccess;
m_msPixelFormat = pixelFormat;
}
iAttributes[17] -= 1;
success = GHOST_kFailure;
}
if (m_multisampleEnabled == GHOST_kSuccess) {
return GHOST_kSuccess;
}
GHOST_PRINT("no available pixel format\n");
return GHOST_kFailure;
return NULL;
}
GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextType type)
{
GHOST_TSuccess success;
switch (type) {
case GHOST_kDrawingContextTypeOpenGL:
{
// If this window has multisample enabled, use the supplied format
if (m_multisampleEnabled)
{
if (SetPixelFormat(m_hDC, m_msPixelFormat, &sPreferredFormat) == FALSE)
{
success = GHOST_kFailure;
break;
}
// Create the context
m_hGlRc = ::wglCreateContext(m_hDC);
if (m_hGlRc) {
if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) {
if (s_firsthGLRc) {
if (is_crappy_intel_card()) {
if (::wglMakeCurrent(NULL, NULL) == TRUE) {
::wglDeleteContext(m_hGlRc);
m_hGlRc = s_firsthGLRc;
}
else {
::wglDeleteContext(m_hGlRc);
m_hGlRc = NULL;
}
}
else {
::wglCopyContext(s_firsthGLRc, m_hGlRc, GL_ALL_ATTRIB_BITS);
::wglShareLists(s_firsthGLRc, m_hGlRc);
}
}
else {
s_firsthGLRc = m_hGlRc;
}
if (m_hGlRc) {
success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
else {
success = GHOST_kFailure;
}
}
else {
success = GHOST_kFailure;
}
}
else {
success = GHOST_kFailure;
}
if (success == GHOST_kFailure) {
printf("Failed to get a context....\n");
}
}
else {
if (m_stereoVisual)
sPreferredFormat.dwFlags |= PFD_STEREO;
// Attempt to match device context pixel format to the preferred format
int iPixelFormat = EnumPixelFormats(m_hDC);
if (iPixelFormat == 0) {
success = GHOST_kFailure;
break;
}
if (::SetPixelFormat(m_hDC, iPixelFormat, &sPreferredFormat) == FALSE) {
success = GHOST_kFailure;
break;
}
// For debugging only: retrieve the pixel format chosen
PIXELFORMATDESCRIPTOR preferredFormat;
::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &preferredFormat);
// Create the context
m_hGlRc = ::wglCreateContext(m_hDC);
if (m_hGlRc) {
if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) {
if (s_firsthGLRc) {
if (is_crappy_intel_card()) {
if (::wglMakeCurrent(NULL, NULL) == TRUE) {
::wglDeleteContext(m_hGlRc);
m_hGlRc = s_firsthGLRc;
}
else {
::wglDeleteContext(m_hGlRc);
m_hGlRc = NULL;
}
}
else {
::wglShareLists(s_firsthGLRc, m_hGlRc);
}
}
else {
s_firsthGLRc = m_hGlRc;
}
if (m_hGlRc) {
success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
else {
success = GHOST_kFailure;
}
}
else {
success = GHOST_kFailure;
}
}
else {
success = GHOST_kFailure;
}
if (success == GHOST_kFailure) {
printf("Failed to get a context....\n");
}
// Attempt to enable multisample
if (m_multisample && WGL_ARB_multisample && !m_multisampleEnabled && !is_crappy_intel_card())
{
success = initMultisample(preferredFormat);
if (success)
{
// Make sure we don't screw up the context
if (m_hGlRc == s_firsthGLRc)
s_firsthGLRc = NULL;
m_drawingContextType = GHOST_kDrawingContextTypeOpenGL;
removeDrawingContext();
// Create a new window
GHOST_TWindowState new_state = getState();
m_nextWindow = new GHOST_WindowWin32((GHOST_SystemWin32 *)GHOST_ISystem::getSystem(),
m_title,
m_left,
m_top,
m_width,
m_height,
new_state,
type,
m_stereo,
m_multisample,
m_parentWindowHwnd,
m_multisampleEnabled,
m_msPixelFormat);
// Return failure so we can trash this window.
success = GHOST_kFailure;
break;
}
else {
m_multisampleEnabled = GHOST_kSuccess;
printf("Multisample failed to initialize\n");
success = GHOST_kSuccess;
}
}
}
}
break;
case GHOST_kDrawingContextTypeNone:
success = GHOST_kSuccess;
break;
default:
success = GHOST_kFailure;
}
return success;
}
GHOST_TSuccess GHOST_WindowWin32::removeDrawingContext()
{
GHOST_TSuccess success;
switch (m_drawingContextType) {
case GHOST_kDrawingContextTypeOpenGL:
// we shouldn't remove the drawing context if it's the first OpenGL context
// If we do, we get corrupted drawing. See #19997
if (m_hGlRc && m_hGlRc != s_firsthGLRc) {
success = ::wglDeleteContext(m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
m_hGlRc = 0;
}
else {
success = GHOST_kFailure;
}
break;
case GHOST_kDrawingContextTypeNone:
success = GHOST_kSuccess;
break;
default:
success = GHOST_kFailure;
}
return success;
}
void GHOST_WindowWin32::lostMouseCapture()
{
if (m_hasMouseCaptured)
{ m_hasGrabMouse = false;
m_nPressedButtons = 0;
m_hasMouseCaptured = false; };
if (m_hasMouseCaptured) {
m_hasGrabMouse = false;
m_nPressedButtons = 0;
m_hasMouseCaptured = false;
}
}
void GHOST_WindowWin32::registerMouseClickEvent(int press)
@@ -1308,95 +999,3 @@ GHOST_TSuccess GHOST_WindowWin32::endProgressBar()
return GHOST_kFailure;
}
/* Ron Fosner's code for weighting pixel formats and forcing software.
* See http://www.opengl.org/resources/faq/technical/weight.cpp */
static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd)
{
int weight = 0;
/* assume desktop color depth is 32 bits per pixel */
/* cull unusable pixel formats */
/* if no formats can be found, can we determine why it was rejected? */
if (!(pfd.dwFlags & PFD_SUPPORT_OPENGL) ||
!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
!(pfd.dwFlags & PFD_DOUBLEBUFFER) || /* Blender _needs_ this */
(pfd.cDepthBits <= 8) ||
!(pfd.iPixelType == PFD_TYPE_RGBA))
{
return 0;
}
weight = 1; /* it's usable */
/* the bigger the depth buffer the better */
/* give no weight to a 16-bit depth buffer, because those are crap */
weight += pfd.cDepthBits - 16;
weight += pfd.cColorBits - 8;
#ifdef GHOST_OPENGL_ALPHA
if (pfd.cAlphaBits > 0)
weight ++;
#endif
/* want swap copy capability -- it matters a lot */
if (pfd.dwFlags & PFD_SWAP_COPY) weight += 16;
/* but if it's a generic (not accelerated) view, it's really bad */
if (pfd.dwFlags & PFD_GENERIC_FORMAT) weight /= 10;
return weight;
}
/* A modification of Ron Fosner's replacement for ChoosePixelFormat */
/* returns 0 on error, else returns the pixel format number to be used */
static int EnumPixelFormats(HDC hdc)
{
int iPixelFormat;
int i, n, w, weight = 0;
PIXELFORMATDESCRIPTOR pfd;
/* we need a device context to do anything */
if (!hdc) return 0;
iPixelFormat = 1; /* careful! PFD numbers are 1 based, not zero based */
/* obtain detailed information about
* the device context's first pixel format */
n = 1 + ::DescribePixelFormat(hdc, iPixelFormat,
sizeof(PIXELFORMATDESCRIPTOR), &pfd);
/* choose a pixel format using the useless Windows function in case
* we come up empty handed */
iPixelFormat = ::ChoosePixelFormat(hdc, &sPreferredFormat);
if (!iPixelFormat) return 0; /* couldn't find one to use */
for (i = 1; i <= n; i++) { /* not the idiom, but it's right */
::DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
w = WeightPixelFormat(pfd);
// be strict on stereo
if (!((sPreferredFormat.dwFlags ^ pfd.dwFlags) & PFD_STEREO)) {
if (w > weight) {
weight = w;
iPixelFormat = i;
}
}
}
if (weight == 0) {
// we could find the correct stereo setting, just find any suitable format
for (i = 1; i <= n; i++) { /* not the idiom, but it's right */
::DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
w = WeightPixelFormat(pfd);
if (w > weight) {
weight = w;
iPixelFormat = i;
}
}
}
return iPixelFormat;
}

View File

@@ -37,15 +37,19 @@
#error WIN32 only!
#endif // WIN32
#define _WIN32_WINNT 0x501 // require Windows XP or newer
#define WIN32_LEAN_AND_MEAN
#include "GHOST_Window.h"
#include "GHOST_TaskbarWin32.h"
#ifndef __MINGW64__
#define _WIN32_WINNT 0x501 // require Windows XP or newer
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
//#if defined(WITH_GL_SYSTEM_EMBEDDED) // XXX jwilkins: can remove this after implementing GHOST_Context
//#include <GL/eglew.h>
//#endif
#include <wintab.h>
#define PACKETDATA (PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION | PK_CURSOR)
@@ -94,9 +98,9 @@ public:
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
const bool stereoVisual = false,
const GHOST_TUns16 numOfAASamples = 0,
GHOST_TEmbedderWindowID parentWindowHwnd = 0,
GHOST_TSuccess msEnabled = GHOST_kFailure,
int msPixelFormat = 0
GHOST_TEmbedderWindowID parentWindowHwnd = 0
//GHOST_TSuccess msEnabled = GHOST_kFailure,
//int msPixelFormat = 0
);
/**
@@ -105,12 +109,12 @@ public:
*/
virtual ~GHOST_WindowWin32();
/**
* Returns the window to replace this one if it's getting replaced
* \return The window replacing this one.
*/
///**
// * Returns the window to replace this one if it's getting replaced
// * \return The window replacing this one.
// */
GHOST_Window *getNextWindow();
//GHOST_Window *getNextWindow();
/**
* Returns indication as to whether the window is valid.
@@ -208,10 +212,6 @@ public:
virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
/**
* Swaps front and back buffers of a window.
* \return Indication of success.
*/
virtual GHOST_TSuccess swapBuffers();
/**
* Sets the swap interval for swapBuffers.
@@ -226,12 +226,6 @@ public:
*/
virtual int getSwapInterval();
/**
* Activates the drawing context of this window.
* \return Indication of success.
*/
virtual GHOST_TSuccess activateDrawingContext();
/**
* Invalidates the contents of this window.
*/
@@ -248,13 +242,13 @@ public:
*/
virtual GHOST_TSuccess endProgressBar();
/**
* Returns the name of the window class.
* \return The name of the window class.
*/
static const wchar_t *getWindowClassName() {
return s_windowClassName;
}
///**
// * Returns the name of the window class.
// * \return The name of the window class.
// */
//static const wchar_t *getWindowClassName() {
// return s_windowClassName;
//}
/**
* Register a mouse click event (should be called
@@ -296,23 +290,16 @@ public:
GHOST_TSuccess endFullScreen() const {return GHOST_kFailure;}
/** if the window currently resizing */
bool m_inLiveResize;
bool m_inLiveResize; // XXX jwilkins: ugh
protected:
GHOST_TSuccess initMultisample(PIXELFORMATDESCRIPTOR pfd);
private:
//GHOST_TSuccess initMultisample(PIXELFORMATDESCRIPTOR pfd);
/**
* Tries to install a rendering context in this window.
* \param type The type of rendering context installed.
* \param type The type of rendering context create.
* \return Indication of success.
*/
virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
/**
* Removes the current drawing context.
* \return Indication of success.
*/
virtual GHOST_TSuccess removeDrawingContext();
virtual GHOST_Context* newDrawingContext(GHOST_TDrawingContextType type);
/**
* Sets the cursor visibility on the window using
@@ -360,12 +347,29 @@ protected:
HWND m_hWnd;
/** Device context handle. */
HDC m_hDC;
/** OpenGL rendering context. */
HGLRC m_hGlRc;
/** The first created OpenGL context (for sharing display lists) */
static HGLRC s_firsthGLRc;
/** The first created device context handle. */
static HDC s_firstHDC;
//#if defined(WITH_GL_SYSTEM_DESKTOP) || defined(WITH_GL_SYSTEM_LEGACY)
// /** OpenGL rendering context. */
// HGLRC m_hGlRc;
// /** The first created OpenGL context (for sharing display lists) */
// static HGLRC s_firsthGLRc;
// /** The first created device context handle. */
// static HDC s_firstHDC;
//#endif
//#if defined(WITH_GL_SYSTEM_EMBEDDED)
// EGLContext m_egl_context;
// EGLSurface m_egl_surface;
// EGLDisplay m_egl_display;
//
//#if defined(WITH_ANGLE)
// static HMODULE s_d3dcompiler;
//#endif
//
// static EGLContext s_egl_first_context;
//
// static bool s_eglew_initialized;
//#endif
/** Flag for if window has captured the mouse */
bool m_hasMouseCaptured;
/** Flag if an operator grabs the mouse with WM_cursor_grab_enable/ungrab()
@@ -393,26 +397,26 @@ protected:
LONG m_maxPressure;
LONG m_maxAzimuth, m_maxAltitude;
/** Preferred number of samples */
GHOST_TUns16 m_multisample;
///** Preferred number of samples */
//GHOST_TUns16 m_multisample;
/** Check if multisample is supported */
GHOST_TSuccess m_multisampleEnabled;
///** Check if multisample is supported */
//GHOST_TSuccess m_multisampleEnabled;
/** The pixelFormat to use for multisample */
int m_msPixelFormat;
///** The pixelFormat to use for multisample */
//int m_msPixelFormat;
/** We need to following to recreate the window */
const STR_String& m_title;
GHOST_TInt32 m_left;
GHOST_TInt32 m_top;
GHOST_TUns32 m_width;
GHOST_TUns32 m_height;
///** We need to following to recreate the window */
//const STR_String& m_title;
//GHOST_TInt32 m_left;
//GHOST_TInt32 m_top;
//GHOST_TUns32 m_width;
//GHOST_TUns32 m_height;
GHOST_TWindowState m_normal_state;
bool m_stereo;
//bool m_stereo;
/** The GHOST_System passes this to wm if this window is being replaced */
GHOST_Window *m_nextWindow;
///** The GHOST_System passes this to wm if this window is being replaced */
//GHOST_Window *m_nextWindow;
/** Hwnd to parent window */
GHOST_TEmbedderWindowID m_parentWindowHwnd;

View File

@@ -156,8 +156,11 @@ static long BLENDER_ICON_48x48x32[] = {
4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303,
};
#ifdef GLEW_INC_EGL
EGLContext GHOST_WindowX11::s_firstContext = NULL;
#else
GLXContext GHOST_WindowX11::s_firstContext = NULL;
#endif
GHOST_WindowX11::
GHOST_WindowX11(
@@ -192,11 +195,12 @@ GHOST_WindowX11(
int attributes[40], i, samples;
int natom;
int glxVersionMajor, glxVersionMinor; /* As in GLX major.minor */
int major, minor; /* As in GLX major.minor */
m_visual = NULL;
if (!glXQueryVersion(m_display, &glxVersionMajor, &glxVersionMinor)) {
#ifndef GLEW_INC_EGL
if (!glXQueryVersion(m_display, &major, &minor)) {
printf("%s:%d: X11 glXQueryVersion() failed, verify working openGL system!\n", __FILE__, __LINE__);
/* exit if this is the first window */
@@ -225,7 +229,7 @@ GHOST_WindowX11(
attributes[i++] = GLX_ALPHA_SIZE; attributes[i++] = 1;
#endif
/* GLX >= 1.4 required for multi-sample */
if (samples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) {
if(samples && (major >= 1) && (minor >= 4)) {
attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1;
attributes[i++] = GLX_SAMPLES; attributes[i++] = samples;
}
@@ -256,22 +260,27 @@ GHOST_WindowX11(
break;
}
}
#else
m_visual = (XVisualInfo*)calloc(sizeof(XVisualInfo), 1);
#endif
/* Create a bunch of attributes needed to create an X window. */
/* First create a colormap for the window and visual.
* This seems pretty much a legacy feature as we are in rgba mode anyway. */
XSetWindowAttributes xattributes;
unsigned int xattributes_valuemask = (CWBorderPixel | CWColormap | CWEventMask);
memset(&xattributes, 0, sizeof(xattributes));
xattributes.colormap = XCreateColormap(m_display,
RootWindow(m_display, m_visual->screen),
m_visual->visual,
AllocNone
);
#ifndef WITH_ANDROID
xattributes.colormap =
XCreateColormap(
m_display,
RootWindow(m_display, m_visual->screen),
m_visual->visual,
AllocNone);
#endif
xattributes.border_pixel = 0;
@@ -307,7 +316,6 @@ GHOST_WindowX11(
);
}
else {
Window root_return;
int x_return, y_return;
unsigned int w_return, h_return, border_w_return, depth_return;
@@ -336,8 +344,7 @@ GHOST_WindowX11(
);
XSelectInput(m_display, parentWindow, SubstructureNotifyMask);
}
}
#ifdef WITH_XDND
/* initialize drop target for newly created window */
@@ -519,6 +526,7 @@ bool GHOST_WindowX11::createX11_XIC()
#endif
#ifdef WITH_X11_XINPUT
void GHOST_WindowX11::initXInputDevices()
{
XExtensionVersion *version = XGetExtensionVersion(m_display, INAME);
@@ -1083,7 +1091,11 @@ GHOST_WindowX11::
swapBuffers()
{
if (getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL) {
glXSwapBuffers(m_display, m_window);
#ifdef GLEW_INC_EGL
eglSwapBuffers(gl_display, gl_surface);
#else
glXSwapBuffers(m_display, m_window);
#endif
return GHOST_kSuccess;
}
else {
@@ -1096,13 +1108,17 @@ GHOST_WindowX11::
activateDrawingContext()
{
if (m_context != NULL) {
#ifdef GLEW_INC_EGL
//eglMakeCurrent(gl_display, gl_surface, gl_surface, m_context);
#else
glXMakeCurrent(m_display, m_window, m_context);
#endif
/* Disable AA by default */
if (m_numOfAASamples > 0) {
glDisable(GL_MULTISAMPLE_ARB);
}
return GHOST_kSuccess;
}
}
return GHOST_kFailure;
}
@@ -1174,7 +1190,11 @@ GHOST_WindowX11::
}
if (m_context != s_firstContext) {
#ifdef GLEW_INC_EGL
eglDestroyContext(gl_display, m_context);
#else
glXDestroyContext(m_display, m_context);
#endif
}
if (p_owner == m_window) {
@@ -1195,7 +1215,12 @@ GHOST_WindowX11::
#endif
XDestroyWindow(m_display, m_window);
#ifdef GLEW_INC_EGL
free(m_visual);
#else
XFree(m_visual);
#endif
}
@@ -1215,6 +1240,7 @@ installDrawingContext(
GHOST_TSuccess success;
switch (type) {
case GHOST_kDrawingContextTypeOpenGL:
#ifndef GLEW_INC_EGL
{
#ifdef WITH_X11_XINPUT
/* use our own event handlers to avoid exiting blender,
@@ -1237,14 +1263,77 @@ installDrawingContext(
else {
success = GHOST_kFailure;
}
#ifdef WITH_X11_XINPUT
/* Restore handler */
(void) XSetErrorHandler(old_handler);
(void) XSetIOErrorHandler(old_handler_io);
#endif
#else
{
EGLint ver[2];
EGLint num_config;
EGLConfig config;
EGLint attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
EGLint attribList[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_DEPTH_SIZE, 8,
//EGL_ALPHA_SIZE, 8,
/*EGL_ALPHA_SIZE, 8,
EGL_STENCIL_SIZE, 8,
EGL_SAMPLE_BUFFERS, 1,*/
EGL_NONE
};
gl_display = eglGetDisplay((EGLNativeDisplayType)m_display);
if(gl_display == EGL_NO_DISPLAY)
{
success = GHOST_kFailure;
break;
}
if(!eglInitialize(gl_display, &ver[0], &ver[1]))
{
success = GHOST_kFailure;
break;
}
if(!eglGetConfigs(gl_display, NULL, 0, &num_config))
{
success = GHOST_kFailure;
break;
}
if(!eglChooseConfig(gl_display, attribList, &config, 1, &num_config))
{
success = GHOST_kFailure;
break;
}
gl_surface = eglCreateWindowSurface(gl_display, config, (EGLNativeWindowType)m_window, NULL);
if (gl_surface == EGL_NO_SURFACE)
{
success = GHOST_kFailure;
break;
}
m_context = eglCreateContext(gl_display, config, EGL_NO_CONTEXT, attribs);
if(m_context == EGL_NO_CONTEXT)
{
success = GHOST_kFailure;
break;
}
if(!eglMakeCurrent(gl_display, gl_surface, gl_surface, m_context))
{
success = GHOST_kFailure;
break;
}
glClearColor(0.447, 0.447, 0.447, 0);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_DITHER);
eglSwapBuffers(gl_display, gl_surface);
success = GHOST_kSuccess;
break;
}
#endif
case GHOST_kDrawingContextTypeNone:
{
success = GHOST_kSuccess;
@@ -1266,15 +1355,19 @@ GHOST_TSuccess
GHOST_WindowX11::
removeDrawingContext()
{
GHOST_TSuccess success;
GHOST_TSuccess success = GHOST_kFailure;
if (m_context != NULL) {
#ifndef GLEW_INC_EGL
if (m_context != NULL) { // XXX jwilkins: seems odd not to check if this is s_firstContext
glXDestroyContext(m_display, m_context);
m_context = NULL;
success = GHOST_kSuccess;
}
else {
success = GHOST_kFailure;
}
#endif
return success;
}

View File

@@ -35,7 +35,14 @@
#include "GHOST_Window.h"
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <X11/Xutil.h>
#ifndef GLEW_INC_EGL
#include <GL/glxew.h>
#else
#include <GL/eglew.h>
#endif
// For tablets
#ifdef WITH_X11_XINPUT
# include <X11/extensions/XInput.h>
@@ -350,14 +357,25 @@ private:
void initXInputDevices();
#endif
#ifndef GLEW_INC_EGL
EGLContext m_context;
EGLSurface gl_surface;
EGLDisplay gl_display;
#else
GLXContext m_context;
#endif
Window m_window;
Display *m_display;
XVisualInfo *m_visual;
GHOST_TWindowState m_normal_state;
/** The first created OpenGL context (for sharing display lists) */
#ifndef GLEW_INC_EGL
static EGLContext s_firstContext;
#else
static GLXContext s_firstContext;
#endif
/// A pointer to the typed system class.

View File

@@ -65,6 +65,7 @@
/* needed for uintptr_t and attributes, exception, dont use BLI anywhere else in MEM_* */
#include "../../source/blender/blenlib/BLI_sys_types.h"
#include "../../source/blender/blenlib/BLI_compiler_attrs.h"
#include "../../source/blender/blenlib/BLI_utildefines.h" /* for __func__ */
#ifdef __cplusplus
extern "C" {

0
release/bin/blender-softwaregl Executable file → Normal file
View File

0
release/bin/blender-thumbnailer.py Executable file → Normal file
View File

0
release/datafiles/blender_icons_update.py Executable file → Normal file
View File

0
release/datafiles/ctodata.py Executable file → Normal file
View File

0
release/datafiles/datatoc.py Executable file → Normal file
View File

0
release/datafiles/prvicons_update.py Executable file → Normal file
View File

0
release/scripts/modules/bl_i18n_utils/merge_po.py Executable file → Normal file
View File

View File

0
release/scripts/modules/bl_i18n_utils/utils_rtl.py Executable file → Normal file
View File

0
release/scripts/modules/blend_render_info.py Executable file → Normal file
View File

View File

@@ -32,6 +32,8 @@
#ifndef __BLF_API_H__
#define __BLF_API_H__
#include <string.h> /* for size_t */
struct rctf;
struct ColorManagedDisplay;
@@ -71,6 +73,8 @@ void BLF_size(int fontid, int size, int dpi);
void BLF_matrix(int fontid, const double m[16]);
/* Draw the string using the default font, size and dpi. */
void BLF_draw_default_lock(void);
void BLF_draw_default_unlock(void);
void BLF_draw_default(float x, float y, float z, const char *str, size_t len);
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len);
@@ -79,6 +83,11 @@ void BLF_draw(int fontid, const char *str, size_t len);
void BLF_draw_ascii(int fontid, const char *str, size_t len);
int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth);
/* Draw large blocks of text more efficiently by
explicitely reserving OpenGL for that purpose*/
void BLF_draw_lock(int fontid);
void BLF_draw_unlock(int fontid);
/* Get the string byte offset that fits within a given width */
size_t BLF_width_to_strlen(int fontid, const char *str, size_t len, float width, float *r_width);
/* Same as BLF_width_to_strlen but search from the string end */

View File

@@ -33,7 +33,7 @@
#ifndef __BLF_TRANSLATION_H__
#define __BLF_TRANSLATION_H__
#include "BLI_utildefines.h" /* for bool type */
#include "BLI_sys_types.h" /* for bool type */
#define TEXT_DOMAIN_NAME "blender"

View File

@@ -32,6 +32,7 @@ set(INC
../imbuf
../../../intern/guardedalloc
../../../intern/locale
../gpu
)
set(INC_SYS
@@ -58,7 +59,7 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
add_definitions(-DGLEW_STATIC)
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_blenfont "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -39,6 +39,7 @@ incs = [
'../blenkernel',
'../blenlib',
'../editors/include',
'../gpu',
'../imbuf',
'../makesdna',
'../makesrna',

View File

@@ -50,12 +50,16 @@
#include "BLI_math.h"
#include "BLI_threads.h"
#include "BIF_gl.h"
#include "BLF_api.h"
#include "blf_internal_types.h"
#include "blf_internal.h"
#include "GPU_blender_aspect.h"
#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "GPU_font.h"
/* Max number of font in memory.
* Take care that now every font have a glyph cache per size/dpi,
* so we don't need load the same font with different size, just
@@ -160,10 +164,10 @@ static int blf_global_font_init(void)
if (global_font_default == -1) {
printf("Warning: Can't find default font!\n");
return 0;
return false;
}
else {
return 1;
return true;
}
}
@@ -458,31 +462,36 @@ void BLF_blur(int fontid, int size)
}
}
void BLF_draw_default_lock(void)
{
if (blf_global_font_init()) {
BLF_draw_lock(global_font_default);
}
}
void BLF_draw_default_unlock(void)
{
if (blf_global_font_init()) {
BLF_draw_unlock(global_font_default);
}
}
void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
{
if (!str)
return;
if (!blf_global_font_init())
return;
BLF_size(global_font_default, global_font_points, global_font_dpi);
BLF_position(global_font_default, x, y, z);
BLF_draw(global_font_default, str, len);
if (str && blf_global_font_init()) {
BLF_size(global_font_default, global_font_points, global_font_dpi);
BLF_position(global_font_default, x, y, z);
BLF_draw(global_font_default, str, len);
}
}
/* same as above but call 'BLF_draw_ascii' */
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
{
if (!str)
return;
if (!blf_global_font_init())
return;
BLF_size(global_font_default, global_font_points, global_font_dpi);
BLF_position(global_font_default, x, y, z);
BLF_draw_ascii(global_font_default, str, len); /* XXX, use real length */
if (str && blf_global_font_init()) {
BLF_position(global_font_default, x, y, z);
BLF_draw(global_font_default, str, len); /* XXX, use real length */
}
}
void BLF_rotation_default(float angle)
@@ -494,103 +503,154 @@ void BLF_rotation_default(float angle)
}
}
static void blf_draw__start(FontBLF *font, GLint *mode, GLint *param)
static void draw_lock(FontBLF *font)
{
/*
* The pixmap alignment hack is handle
* in BLF_position (old ui_rasterpos_safe).
*/
if (!font) {
return;
}
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (font->locked == 0) {
GPU_font_begin();
/* Save the current matrix mode. */
glGetIntegerv(GL_MATRIX_MODE, mode);
if (font->shadow || font->blur) {
gpuImmediateFormat_T2_C4_V2(); // DOODLE: blurred and/or shadowed text
}
else {
gpuImmediateFormat_T2_V2(); // DOODLE: normal text
}
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
/* one-time GL setup */
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glEnable(GL_BLEND);
}
if (font->flags & BLF_MATRIX)
glMultMatrixd((GLdouble *)&font->m);
font->locked++;
}
glTranslatef(font->pos[0], font->pos[1], font->pos[2]);
static void draw_unlock(FontBLF *font)
{
if (!font) {
return;
}
GPU_ASSERT(font->locked > 0);
font->locked--;
if (font->locked == 0) {
glDisable(GL_BLEND);
gpuImmediateUnformat();
GPU_font_end();
}
}
void BLF_draw_lock(int fontid)
{
draw_lock(blf_get(fontid));
}
void BLF_draw_unlock(int fontid)
{
draw_unlock(blf_get(fontid));
}
static void blf_draw__start(FontBLF *font)
{
/* The pixmap alignment hack is handled
in BLF_position (old ui_rasterpos_safe). */
#if GPU_SAFETY && defined(WITH_GL_PROFILE_COMPAT)
{
GLenum param;
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, (GLint*)(&param));
GPU_ASSERT(param == GL_MODULATE);
GPU_ASSERT(gpuGetMatrixMode() == GL_MODELVIEW);
}
#endif
gpuMatrixMode(GL_TEXTURE);
gpuPushMatrix();
gpuLoadIdentity();
gpuMatrixMode(GL_MODELVIEW);
gpuPushMatrix();
if (font->flags & BLF_MATRIX) {
gpuMultMatrixd((GLdouble *)&font->m);
}
gpuTranslate(font->pos[0], font->pos[1], font->pos[2]);
if (font->flags & BLF_ASPECT)
glScalef(font->aspect[0], font->aspect[1], font->aspect[2]);
gpuScale(font->aspect[0], font->aspect[1], font->aspect[2]);
if (font->flags & BLF_ROTATION) /* radians -> degrees */
glRotatef(font->angle * (float)(180.0 / M_PI), 0.0f, 0.0f, 1.0f);
if (font->flags & BLF_ROTATION)
gpuRotateAxis(RAD2DEGF(font->angle), 'Z');
if (font->shadow || font->blur)
glGetFloatv(GL_CURRENT_COLOR, font->orig_col);
if (font->shadow || font->blur)
gpuGetColor4fv(font->orig_col);
/* always bind the texture for the first glyph */
font->tex_bind_state = -1;
/* Save the current parameter to restore it later. */
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
if (*param != GL_MODULATE)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
draw_lock(font);
}
static void blf_draw__end(GLint mode, GLint param)
static void blf_draw__end(FontBLF *font)
{
/* and restore the original value. */
if (param != GL_MODULATE)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
draw_unlock(font);
glMatrixMode(GL_TEXTURE);
glPopMatrix();
gpuMatrixMode(GL_TEXTURE);
gpuPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
gpuMatrixMode(GL_MODELVIEW);
gpuPopMatrix();
if (mode != GL_MODELVIEW)
glMatrixMode(mode);
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
/* XXX: current color becomes undefined due to use of vertex arrays,
but a lot of code relies on it remaining the same */
if (font->shadow || font->blur)
gpuColor4fv(font->orig_col);
}
void BLF_draw(int fontid, const char *str, size_t len)
{
FontBLF *font = blf_get(fontid);
GLint mode, param;
if (len > 0 && str[0]) {
FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
blf_draw__start(font, &mode, &param);
blf_font_draw(font, str, len);
blf_draw__end(mode, param);
if (font && font->glyph_cache) {
blf_draw__start(font);
blf_font_draw(font, str, len);
blf_draw__end(font);
}
}
}
void BLF_draw_ascii(int fontid, const char *str, size_t len)
{
FontBLF *font = blf_get(fontid);
GLint mode, param;
if (len > 0 && str[0]) {
FontBLF *font = blf_get(fontid);
if (font && font->glyph_cache) {
blf_draw__start(font, &mode, &param);
blf_font_draw_ascii(font, str, len);
blf_draw__end(mode, param);
if (font && font->glyph_cache) {
blf_draw__start(font);
blf_font_draw_ascii(font, str, len);
blf_draw__end(font);
}
}
}
int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth)
{
FontBLF *font = blf_get(fontid);
GLint mode, param;
int columns = 0;
if (font && font->glyph_cache) {
blf_draw__start(font, &mode, &param);
blf_draw__start(font);
columns = blf_font_draw_mono(font, str, len, cwidth);
blf_draw__end(mode, param);
blf_draw__end(font);
}
return columns;

View File

@@ -50,8 +50,6 @@
#include "BLI_string.h"
#include "BLI_threads.h"
#include "BIF_gl.h"
#include "BLF_api.h"
#include "blf_internal_types.h"
#include "blf_internal.h"

View File

@@ -55,7 +55,6 @@
#include "BLI_threads.h"
#include "BLI_alloca.h"
#include "BIF_gl.h"
#include "BLF_api.h"
#include "IMB_colormanagement.h"
@@ -65,6 +64,9 @@
#include "BLI_strict_flags.h"
#include "GPU_immediate.h"
#include "GPU_state_latch.h"
/* freetype2 handle ONLY for this file!. */
static FT_Library ft_lib;
static SpinLock ft_lib_mutex;
@@ -178,6 +180,7 @@ void blf_font_draw(FontBLF *font, const char *str, size_t len)
int pen_x = 0, pen_y = 0;
size_t i = 0;
GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table;
int needs_end = false;
BLF_KERNING_VARS(font, has_kerning, kern_mode);
@@ -194,11 +197,18 @@ void blf_font_draw(FontBLF *font, const char *str, size_t len)
BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
/* do not return this loop if clipped, we want every character tested */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
/* blf_glyph_render calls gpuBegin */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y, &needs_end);
pen_x += (int)g->advance;
g_prev = g;
}
if (needs_end) {
gpuEnd();
}
gpuBindTexture(GL_TEXTURE_2D, 0); /* restore default */
}
/* faster version of blf_font_draw, ascii only for view dimensions */
@@ -209,6 +219,7 @@ void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len)
FT_Vector delta;
int pen_x = 0, pen_y = 0;
GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table;
int needs_end = false;
BLF_KERNING_VARS(font, has_kerning, kern_mode);
@@ -222,11 +233,18 @@ void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len)
BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
/* do not return this loop if clipped, we want every character tested */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
/* blf_glyph_render calls gpuBegin */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y, &needs_end);
pen_x += (int)g->advance;
g_prev = g;
}
if (needs_end) {
gpuEnd();
}
gpuBindTexture(GL_TEXTURE_2D, 0); /* restore default */
}
/* use fixed column width, but an utf8 character may occupy multiple columns */
@@ -238,6 +256,7 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
int pen_x = 0, pen_y = 0;
size_t i = 0;
GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table;
int needs_end = false;
blf_font_ensure_ascii_table(font);
@@ -250,7 +269,8 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
continue;
/* do not return this loop if clipped, we want every character tested */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
/* blf_glyph_render calls gpuBegin */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y, &needs_end);
col = BLI_wcwidth((wchar_t)c);
if (col < 0)
@@ -260,6 +280,12 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
pen_x += cwidth * col;
}
if (needs_end) {
gpuEnd();
}
gpuBindTexture(GL_TEXTURE_2D, 0); /* restore default */
return columns;
}

View File

@@ -52,7 +52,6 @@
#include "BLI_rect.h"
#include "BLI_threads.h"
#include "BIF_gl.h"
#include "BLF_api.h"
#include "blf_internal_types.h"
@@ -60,6 +59,11 @@
#include "BLI_strict_flags.h"
#include "GPU_state_latch.h"
#include "GPU_immediate.h"
GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, unsigned int size, unsigned int dpi)
{
GlyphCacheBLF *p;
@@ -169,13 +173,18 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc)
gc->p2_height = font->max_tex_size;
glGenTextures(1, &gc->textures[gc->cur_tex]);
glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = gc->textures[gc->cur_tex]));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
gpuBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = gc->textures[gc->cur_tex]));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#if defined(WITH_GL_PROFILE_CORE)
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, gc->p2_width, gc->p2_height, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
#elif defined(WITH_GL_PROFILE_COMPAT) || defined(WITH_GL_PROFILE_ES20)
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL);
#endif
GPU_CHECK_NO_ERROR();
}
GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c)
@@ -309,55 +318,53 @@ void blf_glyph_free(GlyphBLF *g)
static void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1, float y2)
{
glBegin(GL_QUADS);
glTexCoord2f(uv[0][0], uv[0][1]);
glVertex2f(dx, y1);
gpuTexCoord2f(uv[0][0], uv[0][1]);
gpuVertex2f(dx, y1);
glTexCoord2f(uv[0][0], uv[1][1]);
glVertex2f(dx, y2);
gpuTexCoord2f(uv[0][0], uv[1][1]);
gpuVertex2f(dx, y2);
glTexCoord2f(uv[1][0], uv[1][1]);
glVertex2f(dx1, y2);
gpuTexCoord2f(uv[1][0], uv[1][1]);
gpuVertex2f(dx1, y2);
glTexCoord2f(uv[1][0], uv[0][1]);
glVertex2f(dx1, y1);
glEnd();
gpuTexCoord2f(uv[1][0], uv[0][1]);
gpuVertex2f(dx1, y1);
}
static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
{
const float soft[25] = {1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f,
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f,
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f};
const float *fp = soft;
static const float soft[25] =
{1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f,
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f,
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f};
int i = 0;
float color[4];
float dx, dy;
color[0] = shadow_col[0];
color[1] = shadow_col[1];
color[2] = shadow_col[2];
for (dx = -2; dx < 3; dx++) {
for (dy = -2; dy < 3; dy++, fp++) {
color[3] = *(fp) * shadow_col[3];
glColor4fv(color);
for (dy = -2; dy < 3; dy++) {
color[3] = soft[i++] * shadow_col[3];
gpuColor4fv(color);
blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
}
}
glColor4fv(color);
}
static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
{
const float soft[9] = {1 / 16.0f, 2 / 16.0f, 1 / 16.0f,
2 / 16.0f, 4 / 16.0f, 2 / 16.0f,
1 / 16.0f, 2 / 16.0f, 1 / 16.0f};
static const float soft[9] =
{1 / 16.0f, 2 / 16.0f, 1 / 16.0f,
2 / 16.0f, 4 / 16.0f, 2 / 16.0f,
1 / 16.0f, 2 / 16.0f, 1 / 16.0f};
const float *fp = soft;
int i = 0;
float color[4];
float dx, dy;
@@ -366,14 +373,12 @@ static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x
color[2] = shadow_col[2];
for (dx = -1; dx < 2; dx++) {
for (dy = -1; dy < 2; dy++, fp++) {
color[3] = *(fp) * shadow_col[3];
glColor4fv(color);
for (dy = -1; dy < 2; dy++) {
color[3] = soft[i++] * shadow_col[3];
gpuColor4fv(color);
blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
}
}
glColor4fv(color);
}
static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
@@ -384,24 +389,52 @@ static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
rect->ymax = y + g->pos_y - (float)g->height;
}
void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
void blf_glyph_render(
FontBLF *font,
GlyphBLF *g,
float x,
float y,
int *needs_end)
{
int need_begin = !(*needs_end);
rctf rect;
if ((!g->width) || (!g->height))
if (g->width == 0 || g->height == 0) {
return;
}
blf_glyph_calc_rect(&rect, g, x, y);
if (font->flags & BLF_CLIPPING) {
/* intentionally check clipping without shadow offset */
rctf rect_test = rect;
BLI_rctf_translate(&rect_test, font->pos[0], font->pos[1]);
if (!BLI_rctf_inside_rctf(&font->clip_rec, &rect_test)) {
return;
}
}
if (g->build_tex == 0) {
GlyphCacheBLF *gc = font->glyph_cache;
if (!need_begin) {
gpuEnd();
need_begin = true;
*needs_end = false;
}
GPU_CHECK_NO_ERROR();
if (font->max_tex_size == -1)
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size);
GPU_CHECK_NO_ERROR();
if (gc->cur_tex == BLF_CURTEX_UNSET) {
blf_glyph_cache_texture(font, gc);
gc->x_offs = gc->pad;
gc->y_offs = 0;
}
GPU_CHECK_NO_ERROR();
if (gc->x_offs > (gc->p2_width - gc->max_glyph_width)) {
gc->x_offs = gc->pad;
@@ -430,14 +463,16 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
}
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
GPU_CHECK_NO_ERROR();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, g->tex);
GPU_CHECK_NO_ERROR();
gpuBindTexture(GL_TEXTURE_2D, g->tex);
#if defined(WITH_GL_PROFILE_CORE)
glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_RED, GL_UNSIGNED_BYTE, g->bitmap);
#else
glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap);
glPopClientAttrib();
#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); /* restore default value */ //-V112
g->uv[0][0] = ((float)g->xoff) / ((float)gc->p2_width);
g->uv[0][1] = ((float)g->yoff) / ((float)gc->p2_height);
@@ -451,20 +486,17 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
g->build_tex = 1;
}
blf_glyph_calc_rect(&rect, g, x, y);
if (font->flags & BLF_CLIPPING) {
/* intentionally check clipping without shadow offset */
rctf rect_test = rect;
BLI_rctf_translate(&rect_test, font->pos[0], font->pos[1]);
if (!BLI_rctf_inside_rctf(&font->clip_rec, &rect_test)) {
return;
if (font->tex_bind_state != g->tex) {
if (!need_begin) {
gpuEnd();
need_begin = true;
}
gpuBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = g->tex));
}
if (font->tex_bind_state != g->tex) {
glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = g->tex));
if (need_begin) {
gpuBegin(GL_QUADS);
*needs_end = true;
}
if (font->flags & BLF_SHADOW) {
@@ -472,7 +504,6 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
blf_glyph_calc_rect(&rect_ofs, g,
x + (float)font->shadow_x,
y + (float)font->shadow_y);
switch (font->shadow) {
case 3:
blf_texture3_draw(font->shadow_col, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
@@ -481,12 +512,11 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
blf_texture5_draw(font->shadow_col, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
break;
default:
glColor4fv(font->shadow_col);
gpuColor4fv(font->shadow_col);
blf_texture_draw(g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
break;
}
glColor4fv(font->orig_col);
}
switch (font->blur) {
@@ -497,9 +527,12 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
blf_texture5_draw(font->orig_col, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
break;
default:
if (font->flags & BLF_SHADOW) {
gpuColor4fv(font->orig_col);
}
blf_texture_draw(g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
break;
}
return;
}

View File

@@ -73,6 +73,6 @@ struct GlyphBLF *blf_glyph_search(struct GlyphCacheBLF *gc, unsigned int c);
struct GlyphBLF *blf_glyph_add(struct FontBLF *font, unsigned int index, unsigned int c);
void blf_glyph_free(struct GlyphBLF *g);
void blf_glyph_render(struct FontBLF *font, struct GlyphBLF *g, float x, float y);
void blf_glyph_render(struct FontBLF *font, struct GlyphBLF *g, float x, float y, int *needs_end);
#endif /* __BLF_INTERNAL_H__ */

View File

@@ -31,6 +31,8 @@
#ifndef __BLF_INTERNAL_TYPES_H__
#define __BLF_INTERNAL_TYPES_H__
#include "GPU_glew.h"
typedef struct GlyphCacheBLF {
struct GlyphCacheBLF *next;
struct GlyphCacheBLF *prev;
@@ -225,6 +227,8 @@ typedef struct FontBLF {
/* data for buffer usage (drawing into a texture buffer) */
FontBufInfoBLF buf_info;
int locked;
} FontBLF;
typedef struct DirBLF {

View File

@@ -52,10 +52,10 @@
static const char unifont_filename[] = "droidsans.ttf.gz";
static unsigned char *unifont_ttf = NULL;
static int unifont_size = 0;
static bli_off_t unifont_size = 0;
static const char unifont_mono_filename[] = "bmonofont-i18n.ttf.gz";
static unsigned char *unifont_mono_ttf = NULL;
static int unifont_mono_size = 0;
static bli_off_t unifont_mono_size = 0;
#endif /* WITH_INTERNATIONAL */
unsigned char *BLF_get_unifont(int *r_unifont_size)
@@ -75,7 +75,7 @@ unsigned char *BLF_get_unifont(int *r_unifont_size)
}
}
*r_unifont_size = unifont_size;
*r_unifont_size = (int)unifont_size; /* XXX jwilkins: assuming font file is less than 2GiB */
return unifont_ttf;
#else

View File

@@ -79,6 +79,8 @@
#include "BKE_customdata.h"
#include "BKE_bvhutils.h"
#include "BLI_utildefines.h"
struct CCGElem;
struct CCGKey;
struct MVert;
@@ -134,8 +136,8 @@ typedef enum DerivedMeshType {
typedef enum DMDrawOption {
/* the element is hidden or otherwise non-drawable */
DM_DRAW_OPTION_SKIP = 0,
/* normal drawing */
DM_DRAW_OPTION_NORMAL = 1,
/* draw element normally */
DM_DRAW_OPTION_NORMALLY = 1,
/* draw, but don't set the color from mcol */
DM_DRAW_OPTION_NO_MCOL = 2,
/* used in drawMappedFaces, use GL stipple for the face */
@@ -148,10 +150,13 @@ typedef int (*DMCompareDrawOptions)(void *userData, int cur_index, int next_inde
typedef void (*DMSetDrawInterpOptions)(void *userData, int index, float t);
typedef DMDrawOption (*DMSetDrawOptions)(void *userData, int index);
typedef DMDrawOption (*DMSetDrawOptionsTex)(struct MTFace *tface, const bool has_vcol, int matnr);
typedef void (*DMForEachMappedVert)(void *, int, const float *, const float *, const short *);
typedef void (*DMForEachMappedFaceCenter)(void *, int, const float *, const float *);
typedef enum DMDrawFlag {
DM_DRAW_USE_COLORS = 1,
DM_DRAW_ALWAYS_SMOOTH = 2
DM_DRAW_ALWAYS_SMOOTH = 2,
DM_DRAW_USE_NORMALS = 4,
} DMDrawFlag;
typedef enum DMForeachFlag {
@@ -172,9 +177,8 @@ typedef enum DMDirtyFlag {
DM_DIRTY_NORMALS = 1 << 2,
} DMDirtyFlag;
typedef struct DerivedMesh DerivedMesh;
struct DerivedMesh {
/** Private DerivedMesh data, only for internal DerivedMesh use */
typedef struct DerivedMesh {
/** Private struct DerivedMesh data, only for internal struct DerivedMesh use */
CustomData vertData, edgeData, faceData, loopData, polyData;
int numVertData, numEdgeData, numTessFaceData, numLoopData, numPolyData;
int needsFree; /* checked on ->release, is set to 0 for cached results */
@@ -191,102 +195,102 @@ struct DerivedMesh {
char cd_flag;
/** Calculate vert and face normals */
void (*calcNormals)(DerivedMesh *dm);
void (*calcNormals)(struct DerivedMesh *dm);
/** Calculate loop (split) normals */
void (*calcLoopNormals)(DerivedMesh *dm, const float split_angle);
void (*calcLoopNormals)(struct DerivedMesh *dm, const float split_angle);
/** Recalculates mesh tessellation */
void (*recalcTessellation)(DerivedMesh *dm);
void (*recalcTessellation)(struct DerivedMesh *dm);
/* Misc. Queries */
/* Also called in Editmode */
int (*getNumVerts)(DerivedMesh *dm);
int (*getNumEdges)(DerivedMesh *dm);
int (*getNumTessFaces)(DerivedMesh *dm);
int (*getNumLoops)(DerivedMesh *dm);
int (*getNumPolys)(DerivedMesh *dm);
int (*getNumVerts)(struct DerivedMesh *dm);
int (*getNumEdges)(struct DerivedMesh *dm);
int (*getNumTessFaces)(struct DerivedMesh *dm);
int (*getNumLoops)(struct DerivedMesh *dm);
int (*getNumPolys)(struct DerivedMesh *dm);
/** Copy a single vert/edge/tessellated face from the derived mesh into
* *{vert/edge/face}_r. note that the current implementation
* of this function can be quite slow, iterating over all
* elements (editmesh)
*/
void (*getVert)(DerivedMesh *dm, int index, struct MVert *r_vert);
void (*getEdge)(DerivedMesh *dm, int index, struct MEdge *r_edge);
void (*getTessFace)(DerivedMesh *dm, int index, struct MFace *r_face);
void (*getVert)(struct DerivedMesh *dm, int index, struct MVert *r_vert);
void (*getEdge)(struct DerivedMesh *dm, int index, struct MEdge *r_edge);
void (*getTessFace)(struct DerivedMesh *dm, int index, struct MFace *r_face);
/** Return a pointer to the entire array of verts/edges/face from the
* derived mesh. if such an array does not exist yet, it will be created,
* and freed on the next ->release(). consider using getVert/Edge/Face if
* you are only interested in a few verts/edges/faces.
*/
struct MVert *(*getVertArray)(DerivedMesh * dm);
struct MEdge *(*getEdgeArray)(DerivedMesh * dm);
struct MFace *(*getTessFaceArray)(DerivedMesh * dm);
struct MLoop *(*getLoopArray)(DerivedMesh * dm);
struct MPoly *(*getPolyArray)(DerivedMesh * dm);
struct MVert *(*getVertArray)(struct DerivedMesh * dm);
struct MEdge *(*getEdgeArray)(struct DerivedMesh * dm);
struct MFace *(*getTessFaceArray)(struct DerivedMesh * dm);
struct MLoop *(*getLoopArray)(struct DerivedMesh * dm);
struct MPoly *(*getPolyArray)(struct DerivedMesh * dm);
/** Copy all verts/edges/faces from the derived mesh into
* *{vert/edge/face}_r (must point to a buffer large enough)
*/
void (*copyVertArray)(DerivedMesh *dm, struct MVert *r_vert);
void (*copyEdgeArray)(DerivedMesh *dm, struct MEdge *r_edge);
void (*copyTessFaceArray)(DerivedMesh *dm, struct MFace *r_face);
void (*copyLoopArray)(DerivedMesh *dm, struct MLoop *r_loop);
void (*copyPolyArray)(DerivedMesh *dm, struct MPoly *r_poly);
void (*copyVertArray)(struct DerivedMesh *dm, struct MVert *r_vert);
void (*copyEdgeArray)(struct DerivedMesh *dm, struct MEdge *r_edge);
void (*copyTessFaceArray)(struct DerivedMesh *dm, struct MFace *r_face);
void (*copyLoopArray)(struct DerivedMesh *dm, struct MLoop *r_loop);
void (*copyPolyArray)(struct DerivedMesh *dm, struct MPoly *r_poly);
/** Return a copy of all verts/edges/faces from the derived mesh
* it is the caller's responsibility to free the returned pointer
*/
struct MVert *(*dupVertArray)(DerivedMesh * dm);
struct MEdge *(*dupEdgeArray)(DerivedMesh * dm);
struct MFace *(*dupTessFaceArray)(DerivedMesh * dm);
struct MLoop *(*dupLoopArray)(DerivedMesh * dm);
struct MPoly *(*dupPolyArray)(DerivedMesh * dm);
struct MVert *(*dupVertArray)(struct DerivedMesh * dm);
struct MEdge *(*dupEdgeArray)(struct DerivedMesh * dm);
struct MFace *(*dupTessFaceArray)(struct DerivedMesh * dm);
struct MLoop *(*dupLoopArray)(struct DerivedMesh * dm);
struct MPoly *(*dupPolyArray)(struct DerivedMesh * dm);
/** Return a pointer to a single element of vert/edge/face custom data
* from the derived mesh (this gives a pointer to the actual data, not
* a copy)
*/
void *(*getVertData)(DerivedMesh *dm, int index, int type);
void *(*getEdgeData)(DerivedMesh *dm, int index, int type);
void *(*getTessFaceData)(DerivedMesh *dm, int index, int type);
void *(*getPolyData)(DerivedMesh *dm, int index, int type);
void *(*getVertData)(struct DerivedMesh *dm, int index, int type);
void *(*getEdgeData)(struct DerivedMesh *dm, int index, int type);
void *(*getTessFaceData)(struct DerivedMesh *dm, int index, int type);
void *(*getPolyData)(struct DerivedMesh *dm, int index, int type);
/** Return a pointer to the entire array of vert/edge/face custom data
* from the derived mesh (this gives a pointer to the actual data, not
* a copy)
*/
void *(*getVertDataArray)(DerivedMesh *dm, int type);
void *(*getEdgeDataArray)(DerivedMesh *dm, int type);
void *(*getTessFaceDataArray)(DerivedMesh *dm, int type);
void *(*getLoopDataArray)(DerivedMesh *dm, int type);
void *(*getPolyDataArray)(DerivedMesh *dm, int type);
void *(*getVertDataArray)(struct DerivedMesh *dm, int type);
void *(*getEdgeDataArray)(struct DerivedMesh *dm, int type);
void *(*getTessFaceDataArray)(struct DerivedMesh *dm, int type);
void *(*getLoopDataArray)(struct DerivedMesh *dm, int type);
void *(*getPolyDataArray)(struct DerivedMesh *dm, int type);
/** Retrieves the base CustomData structures for
* verts/edges/tessfaces/loops/facdes*/
CustomData *(*getVertDataLayout)(DerivedMesh * dm);
CustomData *(*getEdgeDataLayout)(DerivedMesh * dm);
CustomData *(*getTessFaceDataLayout)(DerivedMesh * dm);
CustomData *(*getLoopDataLayout)(DerivedMesh * dm);
CustomData *(*getPolyDataLayout)(DerivedMesh * dm);
CustomData *(*getVertDataLayout)(struct DerivedMesh * dm);
CustomData *(*getEdgeDataLayout)(struct DerivedMesh * dm);
CustomData *(*getTessFaceDataLayout)(struct DerivedMesh * dm);
CustomData *(*getLoopDataLayout)(struct DerivedMesh * dm);
CustomData *(*getPolyDataLayout)(struct DerivedMesh * dm);
/** Copies all customdata for an element source into dst at index dest */
void (*copyFromVertCData)(DerivedMesh *dm, int source, CustomData *dst, int dest);
void (*copyFromEdgeCData)(DerivedMesh *dm, int source, CustomData *dst, int dest);
void (*copyFromFaceCData)(DerivedMesh *dm, int source, CustomData *dst, int dest);
void (*copyFromVertCData)(struct DerivedMesh *dm, int source, CustomData *dst, int dest);
void (*copyFromEdgeCData)(struct DerivedMesh *dm, int source, CustomData *dst, int dest);
void (*copyFromFaceCData)(struct DerivedMesh *dm, int source, CustomData *dst, int dest);
/** Optional grid access for subsurf */
int (*getNumGrids)(DerivedMesh *dm);
int (*getGridSize)(DerivedMesh *dm);
struct CCGElem **(*getGridData)(DerivedMesh * dm);
DMGridAdjacency *(*getGridAdjacency)(DerivedMesh * dm);
int *(*getGridOffset)(DerivedMesh * dm);
void (*getGridKey)(DerivedMesh *dm, struct CCGKey *key);
DMFlagMat *(*getGridFlagMats)(DerivedMesh * dm);
unsigned int **(*getGridHidden)(DerivedMesh * dm);
int (*getNumGrids)(struct DerivedMesh *dm);
int (*getGridSize)(struct DerivedMesh *dm);
struct CCGElem **(*getGridData)(struct DerivedMesh * dm);
DMGridAdjacency *(*getGridAdjacency)(struct DerivedMesh * dm);
int *(*getGridOffset)(struct DerivedMesh * dm);
void (*getGridKey)(struct DerivedMesh *dm, struct CCGKey *key);
DMFlagMat *(*getGridFlagMats)(struct DerivedMesh * dm);
unsigned int **(*getGridHidden)(struct DerivedMesh * dm);
/** Iterate over each mapped vertex in the derived mesh, calling the
@@ -294,7 +298,7 @@ struct DerivedMesh {
* coordinate and normal. For historical reasons the normal can be
* passed as a float or short array, only one should be non-NULL.
*/
void (*foreachMappedVert)(DerivedMesh *dm,
void (*foreachMappedVert)(struct DerivedMesh *dm,
void (*func)(void *userData, int index, const float co[3],
const float no_f[3], const short no_s[3]),
void *userData,
@@ -304,7 +308,7 @@ struct DerivedMesh {
* given function with the original edge and the mapped edge's new
* coordinates.
*/
void (*foreachMappedEdge)(DerivedMesh *dm,
void (*foreachMappedEdge)(struct DerivedMesh *dm,
void (*func)(void *userData, int index,
const float v0co[3], const float v1co[3]),
void *userData);
@@ -312,7 +316,7 @@ struct DerivedMesh {
/** Iterate over each mapped loop in the derived mesh, calling the given function
* with the original loop index and the mapped loops's new coordinate and normal.
*/
void (*foreachMappedLoop)(DerivedMesh *dm,
void (*foreachMappedLoop)(struct DerivedMesh *dm,
void (*func)(void *userData, int vertex_index, int face_index,
const float co[3], const float no[3]),
void *userData,
@@ -322,7 +326,7 @@ struct DerivedMesh {
* given function with the original face and the mapped face's (or
* faces') center and normal.
*/
void (*foreachMappedFaceCenter)(DerivedMesh *dm,
void (*foreachMappedFaceCenter)(struct DerivedMesh *dm,
void (*func)(void *userData, int index,
const float cent[3], const float no[3]),
void *userData,
@@ -332,46 +336,46 @@ struct DerivedMesh {
*
* Also called in Editmode
*/
void (*getMinMax)(DerivedMesh *dm, float r_min[3], float r_max[3]);
void (*getMinMax)(struct DerivedMesh *dm, float r_min[3], float r_max[3]);
/** Direct Access Operations
* - Can be undefined
* - Must be defined for modifiers that only deform however */
/** Get vertex location, undefined if index is not valid */
void (*getVertCo)(DerivedMesh *dm, int index, float r_co[3]);
void (*getVertCo)(struct DerivedMesh *dm, int index, float r_co[3]);
/** Fill the array (of length .getNumVerts()) with all vertex locations */
void (*getVertCos)(DerivedMesh *dm, float (*r_cos)[3]);
void (*getVertCos)(struct DerivedMesh *dm, float (*r_cos)[3]);
/** Get smooth vertex normal, undefined if index is not valid */
void (*getVertNo)(DerivedMesh *dm, int index, float r_no[3]);
void (*getPolyNo)(DerivedMesh *dm, int index, float r_no[3]);
void (*getVertNo)(struct DerivedMesh *dm, int index, float r_no[3]);
void (*getPolyNo)(struct DerivedMesh *dm, int index, float r_no[3]);
/** Get a map of vertices to faces
*/
const struct MeshElemMap *(*getPolyMap)(struct Object *ob, DerivedMesh *dm);
const struct MeshElemMap *(*getPolyMap)(struct Object *ob, struct DerivedMesh *dm);
/** Get the BVH used for paint modes
*/
struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm);
struct PBVH *(*getPBVH)(struct Object *ob, struct DerivedMesh *dm);
/* Drawing Operations */
/** Draw all vertices as bgl points (no options) */
void (*drawVerts)(DerivedMesh *dm);
void (*drawVerts)(struct DerivedMesh *dm);
/** Draw edges in the UV mesh (if exists) */
void (*drawUVEdges)(DerivedMesh *dm);
void (*drawUVEdges)(struct DerivedMesh *dm);
/** Draw all edges as lines (no options)
*
* Also called for *final* editmode DerivedMeshes
*/
void (*drawEdges)(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges);
void (*drawEdges)(struct DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges);
/** Draw all loose edges (edges w/ no adjoining faces) */
void (*drawLooseEdges)(DerivedMesh *dm);
void (*drawLooseEdges)(struct DerivedMesh *dm);
/** Draw all faces
* o Set face normal or vertex normal based on inherited face flag
@@ -380,13 +384,13 @@ struct DerivedMesh {
*
* Also called for *final* editmode DerivedMeshes
*/
void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4],
void (*drawFacesSolid)(struct DerivedMesh *dm, float (*partial_redraw_planes)[4],
bool fast, DMSetMaterial setMaterial);
/** Draw all faces using MTFace
* - Drawing options too complicated to enumerate, look at code.
*/
void (*drawFacesTex)(DerivedMesh *dm,
void (*drawFacesTex)(struct DerivedMesh *dm,
DMSetDrawOptionsTex setDrawOptions,
DMCompareDrawOptions compareDrawOptions,
void *userData);
@@ -395,7 +399,7 @@ struct DerivedMesh {
* o setMaterial is called for every different material nr
* o Only if setMaterial returns true
*/
void (*drawFacesGLSL)(DerivedMesh *dm, DMSetMaterial setMaterial);
void (*drawFacesGLSL)(struct DerivedMesh *dm, DMSetMaterial setMaterial);
/** Draw mapped faces (no color, or texture)
* - Only if !setDrawOptions or
@@ -403,14 +407,16 @@ struct DerivedMesh {
* returns true
*
* If drawSmooth is set to true then vertex normals should be set and
* glShadeModel called with GL_SMOOTH. Otherwise the face normal should
* be set and glShadeModel called with GL_FLAT.
* gpuShadeModel called with GL_SMOOTH. Otherwise the face normal should
* be set and gpuShadeModel called with GL_FLAT.
*
* XXX jwilkins: the above comment needs to be reevaluated since shadeModel is going away
*
* The setDrawOptions is allowed to not set drawSmooth (for example, when
* lighting is disabled), in which case the implementation should draw as
* smooth shaded.
*/
void (*drawMappedFaces)(DerivedMesh *dm,
void (*drawMappedFaces)(struct DerivedMesh *dm,
DMSetDrawOptions setDrawOptions,
DMSetMaterial setMaterial,
DMCompareDrawOptions compareDrawOptions,
@@ -420,7 +426,7 @@ struct DerivedMesh {
/** Draw mapped faces using MTFace
* - Drawing options too complicated to enumerate, look at code.
*/
void (*drawMappedFacesTex)(DerivedMesh *dm,
void (*drawMappedFacesTex)(struct DerivedMesh *dm,
DMSetDrawOptions setDrawOptions,
DMCompareDrawOptions compareDrawOptions,
void *userData);
@@ -430,7 +436,7 @@ struct DerivedMesh {
* - setDrawOptions is called for every face
* - Only if setMaterial and setDrawOptions return true
*/
void (*drawMappedFacesGLSL)(DerivedMesh *dm,
void (*drawMappedFacesGLSL)(struct DerivedMesh *dm,
DMSetMaterial setMaterial,
DMSetDrawOptions setDrawOptions,
void *userData);
@@ -439,7 +445,7 @@ struct DerivedMesh {
* - Only if !setDrawOptions or setDrawOptions(userData, mapped-edge)
* returns true
*/
void (*drawMappedEdges)(DerivedMesh *dm,
void (*drawMappedEdges)(struct DerivedMesh *dm,
DMSetDrawOptions setDrawOptions,
void *userData);
@@ -450,7 +456,7 @@ struct DerivedMesh {
*
* NOTE: This routine is optional!
*/
void (*drawMappedEdgesInterp)(DerivedMesh *dm,
void (*drawMappedEdgesInterp)(struct DerivedMesh *dm,
DMSetDrawOptions setDrawOptions,
DMSetDrawInterpOptions setDrawInterpOptions,
void *userData);
@@ -459,14 +465,14 @@ struct DerivedMesh {
* - setMaterial is called for every different material nr
* - setFace is called to verify if a face must be hidden
*/
void (*drawMappedFacesMat)(DerivedMesh *dm,
void (*drawMappedFacesMat)(struct DerivedMesh *dm,
void (*setMaterial)(void *userData, int matnr, void *attribs),
bool (*setFace)(void *userData, int index), void *userData);
/** Release reference to the DerivedMesh. This function decides internally
* if the DerivedMesh will be freed, or cached for later use. */
void (*release)(DerivedMesh *dm);
};
/** Release reference to the struct DerivedMesh. This function decides internally
* if the struct DerivedMesh will be freed, or cached for later use. */
void (*release)(struct DerivedMesh *dm);
} DerivedMesh;
/** utility function to initialize a DerivedMesh's function pointers to
* the default implementation (for those functions which have a default)

View File

@@ -114,7 +114,7 @@ void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, st
bool verify_paths);
/* Fix all the paths for the entire database... */
void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const char *oldName, const char *newName);
void BKE_all_animdata_fix_paths_rename(struct ID *ref_id, const char *prefix, const char *oldName, const char *newName);
/* Fix the path after removing elements that are not ID (e.g., node) */
void BKE_animdata_fix_paths_remove(struct ID *id, const char *path);

View File

@@ -35,6 +35,7 @@ struct Main;
struct rctf;
struct Scene;
struct wmOperator;
struct UnifiedPaintSettings;
// enum CurveMappingPreset;
@@ -70,9 +71,9 @@ float BKE_brush_curve_strength_clamp(struct Brush *br, float p, const float len)
float BKE_brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */
/* sampling */
float BKE_brush_sample_tex_3D(const Scene *scene, struct Brush *br, const float point[3],
float BKE_brush_sample_tex_3D(const struct Scene *scene, struct Brush *br, const float point[3],
float rgba[4], const int thread, struct ImagePool *pool);
float BKE_brush_sample_masktex(const Scene *scene, struct Brush *br, const float point[2],
float BKE_brush_sample_masktex(const struct Scene *scene, struct Brush *br, const float point[2],
const int thread, struct ImagePool *pool);
/* texture */
@@ -90,9 +91,9 @@ float BKE_brush_unprojected_radius_get(const struct Scene *scene, struct Brush *
void BKE_brush_unprojected_radius_set(struct Scene *scene, struct Brush *brush, float value);
float BKE_brush_alpha_get(const struct Scene *scene, struct Brush *brush);
void BKE_brush_alpha_set(Scene *scene, struct Brush *brush, float alpha);
float BKE_brush_weight_get(const Scene *scene, struct Brush *brush);
void BKE_brush_weight_set(const Scene *scene, struct Brush *brush, float value);
void BKE_brush_alpha_set(struct Scene *scene, struct Brush *brush, float alpha);
float BKE_brush_weight_get(const struct Scene *scene, struct Brush *brush);
void BKE_brush_weight_set(const struct Scene *scene, struct Brush *brush, float value);
int BKE_brush_use_locked_size(const struct Scene *scene, struct Brush *brush);
int BKE_brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush);

View File

@@ -71,7 +71,7 @@ typedef struct DispList {
int parts, nr;
short col, rt; /* rt used by initrenderNurbs */
float *verts, *nors;
int *index;
unsigned int *index;
unsigned int *col1, *col2;
int charidx;
int totindex; /* indexed array drawing surfaces */

View File

@@ -37,6 +37,8 @@
* for every fresh Blender run.
*/
#include "BLI_sys_types.h" /* for bool */
#include "DNA_listBase.h"
#ifdef __cplusplus

View File

@@ -31,6 +31,8 @@
* \ingroup bke
*/
#include "DNA_property_types.h" /* for MAX_PROPSTRING */
struct bProperty;
struct ListBase;
struct Object;

View File

@@ -272,7 +272,7 @@ set(SRC
intern/pbvh_intern.h
)
add_definitions(-DGLEW_STATIC)
add_definitions(${GL_DEFINITIONS})
if(WITH_AUDASPACE)
list(APPEND INC

View File

@@ -70,12 +70,11 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
#include "BLI_sys_types.h" /* for intptr_t support */
#include "GL/glew.h"
#include "GPU_buffers.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_material.h"
#include "GPU_glew.h"
/* very slow! enable for testing only! */
// #define USE_MODIFIER_VALIDATE
@@ -3047,18 +3046,18 @@ static void navmesh_drawColored(DerivedMesh *dm)
#if 0
//UI_ThemeColor(TH_WIRE);
glDisable(GL_LIGHTING);
glLineWidth(2.0);
gpuDisableLighting();
gpuLineWidth(2.0);
dm->drawEdges(dm, 0, 1);
glLineWidth(1.0);
glEnable(GL_LIGHTING);
gpuLineWidth(1.0);
gpuEnableLighting();
#endif
glDisable(GL_LIGHTING);
gpuDisableLighting();
/* if (GPU_buffer_legacy(dm) ) */ { /* TODO - VBO draw code, not high priority - campbell */
DEBUG_VBO("Using legacy code. drawNavMeshColored\n");
//glShadeModel(GL_SMOOTH);
glBegin(glmode = GL_QUADS);
//gpuShadeModel(GL_SMOOTH);
gpuBegin(glmode = GL_QUADS);
for (a = 0; a < dm->numTessFaceData; a++, mface++) {
int new_glmode = mface->v4 ? GL_QUADS : GL_TRIANGLES;
int pi = polygonIdx[a];
@@ -3070,20 +3069,20 @@ static void navmesh_drawColored(DerivedMesh *dm)
}
if (new_glmode != glmode) {
glEnd();
glBegin(glmode = new_glmode);
gpuEnd();
gpuBegin(glmode = new_glmode);
}
glColor3fv(col);
glVertex3fv(mvert[mface->v1].co);
glVertex3fv(mvert[mface->v2].co);
glVertex3fv(mvert[mface->v3].co);
gpuColor3fv(col);
gpuVertex3fv(mvert[mface->v1].co);
gpuVertex3fv(mvert[mface->v2].co);
gpuVertex3fv(mvert[mface->v3].co);
if (mface->v4) {
glVertex3fv(mvert[mface->v4].co);
gpuVertex3fv(mvert[mface->v4].co);
}
}
glEnd();
gpuEnd();
}
glEnable(GL_LIGHTING);
gpuEnableLighting();
}
static void navmesh_DM_drawFacesTex(DerivedMesh *dm,

View File

@@ -29,6 +29,7 @@
* \ingroup bke
*/
#include <stddef.h>
#include "MEM_guardedalloc.h"
#include <stdlib.h>

View File

@@ -236,7 +236,7 @@ static int findFileRecursive(char *filename_new,
if (S_ISREG(status.st_mode)) { /* is file */
if (STREQLEN(filename, de->d_name, FILE_MAX)) { /* name matches */
/* open the file to read its size */
size = status.st_size;
size = (int)status.st_size; /* assumes files can't be bigger than 2GiB */
if ((size > 0) && (size > *filesize)) { /* find the biggest file */
*filesize = size;
BLI_strncpy(filename_new, path, FILE_MAX);

Some files were not shown because too many files have changed in this diff Show More