Compare commits

...

365 Commits

Author SHA1 Message Date
kaetemi 440e062fb0 Merge branch 'develop' into feature/opengl3 4 years ago
kaetemi 15880d8d60 Merge remote-tracking branch 'origin/develop' into feature/opengl3 5 years ago
kaetemi 341e6b7173 Merge branch 'feature/post-code-move' into feature/opengl3 5 years ago
kaetemi c065ce5919 Merge branch 'feature/pre-code-move' into feature/opengl3 5 years ago
kaetemi a537e8c8a8 Merge branch 'develop' into feature/opengl3 5 years ago
kaetemi bbecb833b3 Merge with develop
--HG--
branch : opengl3
9 years ago
kaetemi 35d1e1e9d5 Add input lag reduction test
--HG--
branch : opengl3
10 years ago
kaetemi 4fd44d89a9 Design comments
--HG--
branch : opengl3
10 years ago
kaetemi aab0e3b0d4 Use unsynchronized triple buffering for volatile vertex buffers
--HG--
branch : opengl3
10 years ago
kaetemi 25994fd86b Detect in-flight buffers caused by asynchronous frame rendering
--HG--
branch : opengl3
10 years ago
kaetemi 6ba039c329 Add fence functions
--HG--
branch : opengl3
10 years ago
kaetemi 94bd3b66bb Merge with develop
--HG--
branch : opengl3
10 years ago
kaetemi 66b94d93bf Align total ubo size
--HG--
branch : opengl3
10 years ago
kaetemi 22f6ba78ac Add some debugging
--HG--
branch : opengl3
10 years ago
kaetemi 52214f221d Naming conventions adjustment
--HG--
branch : opengl3
10 years ago
kaetemi 4f5f779a92 Correct vec2
--HG--
branch : opengl3
10 years ago
kaetemi 6ea037e48d Add initial uniform buffer code
--HG--
branch : opengl3
10 years ago
kaetemi 660e72e756 Add hash specialization for uniform buffer format
--HG--
branch : opengl3
10 years ago
kaetemi be428c4901 Generate hash of uniform buffer format on the fly
--HG--
branch : opengl3
10 years ago
kaetemi 9e00340a0d Remove some debug
--HG--
branch : opengl3
10 years ago
kaetemi 65a2f9dad7 Move uniform buffer format builder to NL3D
--HG--
branch : opengl3
10 years ago
kaetemi 5ef419bce3 Test uniform buffer format
--HG--
branch : opengl3
10 years ago
kaetemi 8bdb4e577b Add glsl generation code for uniform buffer format
--HG--
branch : opengl3
10 years ago
kaetemi 631d91b40a Add test for uniform buffer format
--HG--
branch : opengl3
10 years ago
kaetemi 642ae4208e Uniform buffer format building
--HG--
branch : opengl3
10 years ago
kaetemi a2f5ed0037 Don't apply fog to alpha channel
--HG--
branch : opengl3
10 years ago
kaetemi 3a2f04bfb5 Apply matrix basis change transparently to projection instead of view
--HG--
branch : opengl3
10 years ago
kaetemi 5b59e6ba95 Add some initial uniform buffer related code
--HG--
branch : opengl3
10 years ago
kaetemi 916683ed2a Always use namespace for driver
--HG--
branch : opengl3
10 years ago
kaetemi 018417437e Adjust builtin shader program hash
--HG--
branch : opengl3
10 years ago
kaetemi 0299519116 Use hashes for shader program lookup
--HG--
branch : opengl3
10 years ago
kaetemi f1f2e6fa1d Merge with develop
--HG--
branch : opengl3
10 years ago
kaetemi ee98cf6709 Merge with develop
--HG--
branch : opengl3
10 years ago
kaetemi 161086bd56 Merge changes from OpenGL driver into OpenGL3 driver
--HG--
branch : opengl3
10 years ago
kaetemi 3db0105185 Merge with develop
--HG--
branch : opengl3
10 years ago
kaetemi 66126429c2 GL3: Temp bugfix
--HG--
branch : opengl3
11 years ago
kaetemi 6a207ffd76 Backed out changeset: 97ebe9c61936
--HG--
branch : opengl3
11 years ago
kaetemi c9e8fb94c8 Backed out changeset: 8fd9b4f9a6b2
--HG--
branch : opengl3
11 years ago
kaetemi 55aae0d138 Without sync but memory intensive, performance gain vs regular stream buffer only minimal
--HG--
branch : opengl3
11 years ago
kaetemi 5bc87eeeed Backed out changeset: 70793b42008e
--HG--
branch : opengl3
11 years ago
kaetemi afea49e83d GL3: Manual syncing
--HG--
branch : opengl3
11 years ago
kaetemi 42936097ce GL3: Add experimental implementation for volatile buffers using pinned memory
--HG--
branch : opengl3
11 years ago
kaetemi aab353672c GL3: Debug
--HG--
branch : opengl3
11 years ago
kaetemi 50dea16ee7 GL3: Disable an assert
--HG--
branch : opengl3
11 years ago
kaetemi f860d46543 Merge with default
--HG--
branch : opengl3
11 years ago
kaetemi 0a9135a511 Add note
--HG--
branch : opengl3
11 years ago
kaetemi 1896876b11 Merge with default
--HG--
branch : opengl3
11 years ago
kaetemi b5b0ec45ca Adjust a memory preference
--HG--
branch : opengl3
11 years ago
kaetemi 85542abbfe GL3: Report correct location
--HG--
branch : opengl3
11 years ago
kaetemi 76cacae628 GL3: Add support for GL_AMD_pinned_memory
--HG--
branch : opengl3
11 years ago
kaetemi 60851a863e GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi 636b93a7b5 GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi 0543548272 GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi 984b899287 GL3: Set slowUnlockVertexBufferHard to false
--HG--
branch : opengl3
11 years ago
kaetemi f3766f9c40 GL3: Implement RAMPreferred
--HG--
branch : opengl3
11 years ago
kaetemi fef2365b5d Merge with default
--HG--
branch : opengl3
11 years ago
kaetemi f799bdb650 GL3: Optimize volatile vertex buffers
--HG--
branch : opengl3
11 years ago
kaetemi 516a56acd8 GL3: Use GL_STREAM_DRAW for volatile buffers
--HG--
branch : opengl3
11 years ago
kaetemi b6ac857074 GL3: Refactor vertex buffers
--HG--
branch : opengl3
11 years ago
kaetemi 46ac4541f9 GL3: Rename
--HG--
branch : opengl3
11 years ago
kaetemi 9b48fb0c5a Change default for 'setStaticMemoryToVRAM'
--HG--
branch : opengl3
11 years ago
kaetemi 835e0846a1 Merge with default
--HG--
branch : opengl3
11 years ago
kaetemi 457f794584 Merge with default
--HG--
branch : opengl3
11 years ago
kaetemi a0796d23de GL3: Don't use expensive dynamic_cast
--HG--
branch : opengl3
11 years ago
kaetemi 96d4a17340 GL3: Render up to 31 lightmaps at once!
--HG--
branch : opengl3
11 years ago
kaetemi 5d542ed91e GL3: Increase number of usable samplers in program from 4 to 32
--HG--
branch : opengl3
11 years ago
kaetemi 393d08532a GL3: Alpha test bugfix
--HG--
branch : opengl3
11 years ago
kaetemi cda664c62a GL3: Bugfix
--HG--
branch : opengl3
11 years ago
kaetemi 181db9adb9 GL3: Initial lightmap shader implementation
--HG--
branch : opengl3
11 years ago
kaetemi 9df1935f5e GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi a37d7a3127 GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi 9dbdcd1d4e GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi b372f203ec GL3: Bugfix
--HG--
branch : opengl3
11 years ago
kaetemi cb3f3b72c5 GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi 07f663a68e GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi 5a4dd538f1 GL3: Implement mapTextureStageToUV
--HG--
branch : opengl3
11 years ago
kaetemi 09db5b352c GL3: Bugfix
--HG--
branch : opengl3
11 years ago
kaetemi 007d8877b8 GL3: Remove invalid calls
--HG--
branch : opengl3
11 years ago
kaetemi f347172bbe GL3: Use compatibility instead of core, because core disables s3tc extension...
--HG--
branch : opengl3
11 years ago
kaetemi 44102b2034 GL3: Use glClearBuffer
--HG--
branch : opengl3
11 years ago
kaetemi 7e565518ec GL3: Fix
--HG--
branch : opengl3
11 years ago
kaetemi 07269aea3e Backed out changeset: 455175ba6c2e
--HG--
branch : opengl3
11 years ago
kaetemi ec190696ad GL3: Unlit material color
--HG--
branch : opengl3
11 years ago
kaetemi 4913e7dc94 GL3: Primary and secondary color vertex attributes
--HG--
branch : opengl3
11 years ago
kaetemi 4b4ac31a3d Remove branch unrelated features (must backout this changeset after merging into parent feature branch)
--HG--
branch : opengl3
11 years ago
kaetemi 267e7397c5 GL3: Support specular materials with missing textures
--HG--
branch : opengl3
11 years ago
kaetemi cfe1b2b8da GL3: Don't call virtual getters for accessing internal data, please
--HG--
branch : opengl3
11 years ago
kaetemi 6d946081e3 GL3: Fix typo
--HG--
branch : opengl3
11 years ago
kaetemi 25cb297dcf GL3: Fix for texture formats
--HG--
branch : opengl3
11 years ago
kaetemi d415ff508e Backed out changeset: 96647f9b388a
--HG--
branch : opengl3
11 years ago
kaetemi 725ec35188 GL3: Use core profile texture formats
--HG--
branch : opengl3
11 years ago
kaetemi d421f34c1a GL3: Remove dead code
--HG--
branch : opengl3
11 years ago
kaetemi 9cf5b3305c GL3: Create 3.3 core profile context
--HG--
branch : opengl3
11 years ago
kaetemi 11e871c8ab GL3: Remove dead code
--HG--
branch : opengl3
11 years ago
kaetemi a17fc28955 GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi f7d0b292f7 GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi 75d2bf91bf GL3: Even more refactoring
--HG--
branch : opengl3
11 years ago
kaetemi 17b3fa7b55 GL3: More refactoring
--HG--
branch : opengl3
11 years ago
kaetemi 5002eea62a GL3: Further refactor
--HG--
branch : opengl3
11 years ago
kaetemi a13d39e9f4 GL3: Begin refactoring pixel program
--HG--
branch : opengl3
11 years ago
kaetemi 270342a07d GL3: Specular related
--HG--
branch : opengl3
11 years ago
kaetemi 2aa36f413d GL3: Prepare TexGen implementation
--HG--
branch : opengl3
11 years ago
kaetemi 8532f79833 GL3: Remove dead code
--HG--
branch : opengl3
11 years ago
kaetemi 62381dd219 GL3: Cleanup dead code
--HG--
branch : opengl3
11 years ago
kaetemi 1a40e67fee GL3: Remove dead code
--HG--
branch : opengl3
11 years ago
kaetemi 11dc9110c2 GL3: Remove dead code
--HG--
branch : opengl3
11 years ago
kaetemi c0bb40b4a5 GL3: Fix tex coord (fixes landscape near rendering)
--HG--
branch : opengl3
11 years ago
kaetemi c270ec5a58 GL3: Remove dead code
--HG--
branch : opengl3
11 years ago
kaetemi 12cb0ac306 GL3: Fix
--HG--
branch : opengl3
11 years ago
kaetemi 78ec40afa7 GL3: Rewrite generateTexEnv
--HG--
branch : opengl3
11 years ago
kaetemi f62228592e GL3: Cleanup samplers
--HG--
branch : opengl3
11 years ago
kaetemi 7691e22a28 GL3: Fix ambient
--HG--
branch : opengl3
11 years ago
kaetemi 75e650432f GL3: Cleanup and fix lighting state bug in pp
--HG--
branch : opengl3
11 years ago
kaetemi d5d82ce900 GL3: Fix
--HG--
branch : opengl3
11 years ago
kaetemi 443eb54128 GL3: Note
--HG--
branch : opengl3
11 years ago
kaetemi 21eca5af5f GL3: Optimize
--HG--
branch : opengl3
11 years ago
kaetemi 424aa079a2 GL3: Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi b25747b2ef GL3: Optimize VP switching
--HG--
branch : opengl3
11 years ago
kaetemi 5d80073c0f GL3: Refactoring vertex program generation
--HG--
branch : opengl3
11 years ago
kaetemi 7a960ed768 GL3: Cleanup user program state
--HG--
branch : opengl3
11 years ago
kaetemi 3885389b3b GL3: Remove GL_LIGHTING
--HG--
branch : opengl3
11 years ago
kaetemi 641125963e GL3: Replace glActiveTexture
--HG--
branch : opengl3
11 years ago
kaetemi 7ae15eb2b8 GL3: Remove ARB_multitexture
--HG--
branch : opengl3
11 years ago
kaetemi 89c83f86e5 GL3: Remove GL_EXT_blend_color and GL_EXT_secondary_color
--HG--
branch : opengl3
11 years ago
kaetemi 4fe91132ce GL3: Remove GL_ARB_multisample
--HG--
branch : opengl3
11 years ago
kaetemi 5ad62b942a GL3: Remove GL_MAX_TEXTURE_UNITS_ARB
--HG--
branch : opengl3
11 years ago
kaetemi 9c1165dcf9 GL3: Remove GL_MAX_LIGHTS
--HG--
branch : opengl3
11 years ago
kaetemi 8a60e5d4fa GL3: Remove checkForPerPixelLightingSupport
--HG--
branch : opengl3
11 years ago
kaetemi 313de47e53 GL3: Remove GL_ARB_texture_rectangle
--HG--
branch : opengl3
11 years ago
kaetemi 0802330985 GL3: Remove GL_ARB_texture_cube_map
--HG--
branch : opengl3
11 years ago
kaetemi 441d3a66f5 GL3: Remove GL_EXT_separate_specular_color
--HG--
branch : opengl3
11 years ago
kaetemi fce7aab22c GL3: Remove GL_EXT_vertex_weighting
--HG--
branch : opengl3
11 years ago
kaetemi d7c5d30523 GL3: Remove GL_ARB_texture_non_power_of_two
--HG--
branch : opengl3
11 years ago
kaetemi 79141e0a9c GL3: Remove GL_ARB_texture_compression
--HG--
branch : opengl3
11 years ago
kaetemi 3c1b39e103 GL3: Remove unused variable
--HG--
branch : opengl3
11 years ago
kaetemi 3bba0fad6c GL3: Remove GL_EXT_framebuffer_object
--HG--
branch : opengl3
11 years ago
kaetemi 40a6972753 GL3: Remove GL_ATI_texture_env_combine3 and GL_ATIX_texture_env_route
--HG--
branch : opengl3
11 years ago
kaetemi 118d6e0966 GL3: Remove GL_NV_occlusion_query
--HG--
branch : opengl3
11 years ago
kaetemi 2139f39c43 GL3: Remove GL_EXT_texture_env_combine
--HG--
branch : opengl3
11 years ago
kaetemi b978ec5c8e Cleanup extensions
--HG--
branch : opengl3
11 years ago
kaetemi b12c15ab5d Follow existing code style
--HG--
branch : opengl3
11 years ago
kaetemi 99f37eb90c Cleanup style
--HG--
branch : opengl3
11 years ago
kaetemi be050f3927 Cleanup
--HG--
branch : opengl3
11 years ago
kaetemi e01a42e21f Fix shader compile
--HG--
branch : opengl3
11 years ago
kaetemi 082504bc70 Workaround for shader bug
--HG--
branch : opengl3
11 years ago
kaetemi 444d652435 More logging
--HG--
branch : opengl3
11 years ago
kaetemi 41f77780d5 Functions texture2D and textureCube are deprecated
--HG--
branch : opengl3
11 years ago
kaetemi 870df89bcd Remove unnecessary assert
--HG--
branch : opengl3
11 years ago
kaetemi df1e27b82c Fix shader compile on nv driver
--HG--
branch : opengl3
11 years ago
kaetemi cc32c24f23 Revert branch unrelated change
--HG--
branch : opengl3
11 years ago
kaetemi fe967a6a12 Revert branch unrelated change
--HG--
branch : opengl3
11 years ago
kaetemi d7a0816547 Merge with default
--HG--
branch : opengl3
11 years ago
kaetemi 3738aa71ce Fix EOL
--HG--
branch : opengl3
11 years ago
dfighter1985 2ca40f10eb Merging default.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 681a0bc8f3 Don't generate and cache shaders if they are set up from outside of the driver.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 43ad0189c6 Set up the shader programs in setupMaterial call.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 709c54e485 Fixed a GLSL syntax bug that I introduced into the shader generator in December. Specular material will now longer disappear.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 3a84270a84 Textures with DSDT/DUDV format will now be uploaded as RG8. Ryzom will now not crash while entering world.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 fb38a7a0a7 Disable lights when the material isn't lighted.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 2a158e76e1 Lights should now be turned off even when enableLightInternal is called directly. This also fixes the dark background on the character selection screen.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 9c69e1bf84 Material colors ( ambient, diffuse, specular ) should now be used when there's no texture available.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 a119d3e1a0 Use the view matrix instead of modelview to transform the light stuff.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 8f2e75415c Set up the normalmatrix in the driver and feed it to the shaders, instead of calculating it in the shaders.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 9c0e1c2449 Tattos ( and other multitextured stuff ) will now show up again, even if there's only one texture coordinate set.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 7f7a3e159b Reverse directional light direction as it is done in the old OpenGL driver. Also normalize normal.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 90dc025fd8 Fixed: Some uniforms names were wrong after the merge, which led to rendering issues.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 eb9b3e4f0f Implemented light controls.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 1cc71457eb Implemented a basic fog control widget.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 ed885d3df6 Replaced ARB VertexAttribArray stuff with the core calls.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 d37b004372 Removed some more deprecated stuff.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 a9a9768872 Removed ARB fragment shader stuff.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 f768704cbf Removed some ATI stuff.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 6947a58ba1 Removed fixed embm stuff.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 8276cb0140 We shouldn't set up a generated or newly compiled shader program if we already have one ( set up from outside the driver for example ).
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 82a7237e7d Forgot to actually add the driver infos to the list, which caused the driver to hang on deletion.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 c105164eeb Getting rid of z-order assignment warning.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 982b99d8d0 Merged the GPU program stuff from mainline.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 3b16f096cc Merge with rename commit.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 32e814ecb6 Use separate shaders in the OpenGL3 driver.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 b70ce1eb09 Renamed OpenGL3 to opengl3
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 ace1b5386b Check GL_ARB_separate_shader_objects extension on startup, and load related functions.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 cf6d2a88bc Removed some now unused methods.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 afb56ea660 Moved the rendering methods into a new file.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 b0613e334c Removed a now unused file.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 9d3e3a6a73 GL_VERTEX_PROGRAM_TWO_SIDED_ARB isn't used in the GL3 driver.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 7b5aaf7e0f Some cleanup, most of the old OpenGL stuff should be gone.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 5326324b56 Some comments.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 69a4a9f9a5 Two sided rendering, while using dynmat.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 390d1bb156 Don't call newMaterial() every time we load a (sub)material.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 dbd5185de1 Only use the shader combo box for the user shaders.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 586c25f864 When clearing the dynmat, should clear all of them. Also fixes a crash.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 3949c210f6 OpenGL should be fed a clamped color value.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 76204a844d When changing a shader in the editor, reload it in the driver too.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 b775237215 It's now possible to render using the user shaders and dynmat.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 c3c3f154b1 Instead of auto-generating the dynmaterial added a menu item in the material editor that will trigger it if needed.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 8269ec7be5 Wrong direction, wrong lighting!
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 11fe86e552 Forgot to actually pass the direction in the previous commit...
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 72e7d09113 Don't calculate these more than once.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 69c41a31ae These positions and directions were supposed to be in eye coords.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 0453f30582 Added lighting to the specular shader.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 f194704a28 Refactored directional lighting a little. No need to calculate things more than once.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 0ab68ef25f Added point light support.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 9a647a893c Specular shader should compile even when there's no fog added.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 2e4b6bb6ae Don't try to edit stock shaders.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 a9a1d17c4f Added the stock shader names to the material editor, so it will now be able to select them when loading a shape.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 1d71a540ba Apparently QColor::set[color]f takes colors as floats clamped to the [0,1] range.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 c6bb6ec2a9 Renamed a bunch of shader related classes in NL3D to contain the word Usr, since they are user shader related.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 6c58856ed7 Shininess is now loaded from the material as a uniform instead of being hardcoded.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 4ba9d815d4 Colors are now set from the light setup, rather than being hardcoded.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 6f396aa8f7 Added the directional light(s) to the lightmap shader too.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 01ef7fd973 The specular calculation is probably faster this way.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 4ec92d2f06 Simplified the directional light shader generator functions.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 28c4b5b157 Added specular term to the directional lights.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 354d2b8c65 Added ambient term support for directional light.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 43817746ec Renamed light[n]Col to light[n]ColDiff.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 0def5caf54 Added diffuse directional light support to the normal shader.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 3c99323ada Apparently typos and redundantly setting uniforms can totally ruin rendering :D
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 5fbfe7b17f Since now we have fog support, this doesn't need to be disabled anymore.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 8d57eac3d4 Some basic fog.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 c6b714299a Instead of their own bool, store enabled features in the features variable as a flag.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 bbb4762b77 Move shader description generation to it's own method.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 06d7bd9c74 Added alpha test to generated shaders.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 d6558b5b0d Fixed some typos with shader generation.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 37c8b096b1 Added OpenGL3 as a driver option to the configuration tool.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 300cd284d1 Generate samplers for Lightmap shader, based on the number of lightmaps. This fixes the weird display of some lightmapped shapes.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 36a30e83a0 Don't try to render if can't set program up.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 1acccdb5ef Uniform index caching.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 16290f7ff9 Merging default.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 882118612d Moved some constants to uniforms.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 77ae38e452 Added a very primitive shader caching scheme.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 931c18cb51 Diffuse texenv should work with the material color, not the diffuse color. Also modulate the texenv result with vertex color if applicable. Also add the shader type as comment in the top of the shader.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 34de0b5569 Removed renderTriangles2 as the normal render loop is used now.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 a1cf2c640b This too.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 35429fea43 Oups forgot this when changing the rendering loop.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 7307d748ea Sometimes shapes have 0 materials?!
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 14aea7acc9 Removed the debug triangle from the material editor plugin.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 eabc209303 Render from the normal loops.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 888812e72d Only validate the shader program after it's set up. Avoids false alarm.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 5bc7ecf799 Specular shader is now on GLSL.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 86482ed82f Fixed some shader compile errors.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 ed23ec247d Render lightmaps with GLSL.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 0ab6322955 More fixed functionality pipeline disabled with conditional build.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 997a231bff Conditionally build some deprecated functions. Also little adjustment to the shader texenv generator.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 c74e279282 Some settings for the normal shaded material.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 e740fd4aeb Don't crash when releasing.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 d67640dab6 Render with GLSL. Long way to go.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 169ee413df Redundant cloud shader code.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 f77bcf6981 Generate cloud shader.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 2c84b164ee Water shader generation.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 750e7b5e8e A little explanation after I successfully decyphered this.
--HG--
branch : gsoc2013-dfighter
11 years ago
dfighter1985 d64dd4f23f Generate shader for per-pixel without specular.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 6b3b8855ee Generate Per-Pixel Lighting shader.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 2ca79259ce More work on specular shader generation. Hopefully now it's right.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 1414f4d3c1 Little bit of refactoring.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 12df2fd71c Generate specular shader.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 69cc5e48ed Lightmap shader generator.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 f6737c8aa4 UserColor shader should use the normal generator.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 4f8ac17529 Implemented the mapping of TexEnv calls to GLSL. More or less.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 c49265b9db The stringstream used is now part of the generator class.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 7384cdd10a Added offset enum.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 0dcb470a19 Generate the pixel shader ins too.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 46363f1909 Started working on the shader generator.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 d67198580a Implemented uniform querying, setting. Also updated the test triangle.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 3ca6a98aec Made the triangle debug program a bit more complicated, now using interpolated color.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 9dc91a6ed1 Abstract program objects, vertex, and pixel programs can now be created using the driver, so the user can now feed shaders to it.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 41e84066fb Better store vertex and pixel programs separately so we can detach them if needed.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 f5358f712c Rendering the debug triangle with GLSL now works.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 b3ea9ee787 Implemented shader and program object classes.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 ed5741addd Added stubs for GLSL program classes.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 f387256984 Added triangle drawing for debug purposes.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 c7e8ebcf05 Added some more GLSL related calls.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 50bb8c5d60 Made some GLSL related OpenGL functions available.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 10aad932db Removed checks for ARB fragment shader, as it's part of OpenGL as of 3.0+, also fragment shaders cannot be disabled as of the same version.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 dd0a691fb8 This also belongs there.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 90595b5bb6 Removed NV Texture env combine stuff.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 3aae79c38b Removed NV Texture Shader related stuff.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 6fba0c094a Merging default
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 c90f51afbe Look for OpenGL 3.3 not 1.2 on startup.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 82d29b3e23 In OpenGL 3+ we cannot disable HW VBO since it's mandatory, also Vertex Programs are mandatory too, so they must be abailable. No need to check for them!
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 a81db21e0a Removed lots of EXT Vertex Shader related code.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 932f2bdd27 Removed lots of Nvidia shader related code.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 f925666d83 Manage the texture matrices too.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 b1777ff546 Projection matrix is now generated and managed by Nel and only loaded into OpenGL when dirty.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 f34f4d10d3 While I'm at it, I've renamed the VBO parameters too for the same reason.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 15b4be874e Removed the ARB keyword from the VBO managing GL functions, as they are part of the core specification as of OpenGL 3.3
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 31451aa0f6 Removed the ARB word from the names of CVertexArrayRangeARB and CVertexBufferHardARB.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 cfc4565b5d Removed more stuff that's no longer neccessary now that we only work with VBO.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 6360302a2b Use VBO only.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 bb6195f858 Always prefer VBOs as OpenGL core requires the use of VBOs.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 ee2c14670e It's a good idea to actually use the VBO if we spent this time cleaning up the implementations :D
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 44188b58b7 We only have 1 kind of HW VBO left.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 0d98540f2e Ryzom checks for 0 allocated AGP/Video RAM, so lie max. here instead of saying 0.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 adab29e5a6 There's no need for *this* dummy VB either.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 5e69d558ec Since we use HW VBO, we don't need to actually check for it.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 b444f69db3 VertexArrayRange allocation thing is pointless when using ARB VBOs since, the driver takes care about allocating to either system RAM or video RAM.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 e41a15ae30 Allow Ryzom client to use the new driver.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 d06f675c08 Removed more of the vendor specific VBO stuff ( function definitions for example )
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 28c49a0427 These friends and the function are now pointless.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 5c7540d85e Removed vendor specific VBO code.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 8f45e49fa0 GL3 driver can now be instantiated.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 7f0ae42a40 Finally finished cleaning the OpenGL ES stuff.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 e44b663bdb Even more OpenGL ES cleanup.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 2b5eddbe95 More OpenGL ES cleanup.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 879f2f3a85 More GLES stuff removed.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 40da205b59 Removed some GLES related code.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 296083ba61 First batch of renames.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 d5e5775f29 "Forked" the OpenGL driver.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 dddd531249 Moved back the unix event emitter to the OpenGL driver. It was a bad idea to move it out ( this way ) originally.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 1c0d74fc00 Unix build fixes.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 dcf3ba2785 Move unix event emitter out of the driver, to NL3D.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 0c64261e22 The 3dsmax exporter will now use the material file specified in the Nel material.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 f94960dffe Added the Nel material file selection possibility to the Nel material 3dsmax startup script.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 3ff8613205 Merging default.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 7a9ae41fd5 Missing a letter e here
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 ac98c00088 The prototype of the material exporter. It's only called when exporting a mesh, for now.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 80bcf2026a If dynamic material already exists, simply just reinitialize it.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 e99c1e2785 Clear the properties when clearing the scene, and also deactivate the buttons and comboboxes of the material widget.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 b776409cc8 More material properties are converted now.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 6ad18a88f5 Shouldn't reset the material properties, when editing them.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 37fb2cfcda Started work on converting the old material to new one. Some colors are already out. Also made some modifications to the editor so it can deal with it.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 fb3f069a38 Should be able to save QColor based QVariant too.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 c8147b301c Oups. Wrong copypaste of my own code.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 192e9c058a More work on the Variant type. Also modified material editor to use it.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 a113c81db3 Added a Variant type ( for holding variable type values ) to NLMISC
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 9306bd71e6 Added GUI code for multi/sub-material.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 c2296a2a93 It's not a terrible idea to remember the last used directory in the file open dialogs.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 04dcad32e7 Added support for adding basic primitives cube, sphere, cylinder, teapot.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 a2ccb7e796 The main window takes ownership of ViewPortWidget because of setCentralWidget, so no need to delete it here.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 6d31a50f5d I'll give up, I don't know why wheel events are not passed over to this widget as native events. Fortunately they are not needed, since the Nel style 3d mouse listener doesn't use them.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 42bf13dcfd Implemented shape moving/rotating/zooming. Used parts of Dnk's code from object viewer for setting the camera up properly. NOTE: for some reason the ViewPortWidget doesn't receive native mouse wheel events. An investigation is in order.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 66fb3c1284 Shapes can now be loaded and rendered to ViewPortWidget.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 8408ddd552 Added ViewPortWidget.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 96eb64ecbe Shader can now be set for the rendering pass, using the shader combo box in MaterialWidget.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 cc86cdd3ef ShaderEditorWidget will now load/save it's content.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 c9cd9cdd3c Shaders will now show up in the shader combobox of MaterialWidget.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 1f2ff5721e Shaders are now loaded/saved/deleted from the disk.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 00b47d6a50 Implemented the Shader widget, more or less.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 128c2a3270 Changed the Shader widget a little.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 a57bb57c58 Missed these.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 a71e4bc3ed Added some Shader related classes. They are not yet complete.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 6d79a2cf6f Use the color editor for color properties. Also don't crash if property type is not supported by the property browser.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 2e6b1a834f We don't want duplicate property names and labels either.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 9294cdc644 We don't want duplicate passes.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 ea06a2c656 Property values can now be changed.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 9ee24b3b93 Property browser will now show the properties.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 ed267a6587 Probably we don't want the default first pass to be stuck with us if we're loading a material.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 fa3ad050de It's not a bad idea to always have at least 1 pass.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 d96b7e2d66 Added a new class, MaterialSpliter, it holds the Material widget, and the Material properties Qt property tree widget, and acts as a proxy / message router for them.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 c9605dde57 Little bit of refactoring.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 832178a83f Adding / Removing properties will now work.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 94fe455a1a Material widget now retrieves the passes when loading a material.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 067676c049 Changing passes should now show up on the material widget too!
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 02e61b1e1b Implemented the functionality of the Render Passes widget.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 30f8c9f9e1 Added a Nel3D proxy class.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 8c35946010 Material properties widget is now linked to the right button.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 85e885f274 Worked a bit more on dynamic material. Also started to rework the material and pass widgets since I've realized I messed it up. Eg.: passes should have properties, not the material itself.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 26fab0c173 Forgot to add these to CMakeLists.txt
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 32071d9053 Added skeleton for CDynMaterial. This class will be the new material.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 40c95e82ff Changed the shader editor widget into a dialog. Implemented some of the button functions of Shader widget.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 abbc09e19c Added ShaderWidget, and restructured the material related menu items.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 d46944f258 More GUI skeleton work. Added Shader Editor widget.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 e87e265c42 Implemented some of the buttons of the GUI skeleton.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 5aec012c5f Added some more widget skeletons.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 ca52a76e5d Added the skeleton of the OVQT Material Editor plugin.
--HG--
branch : gsoc2013-dfighter
12 years ago
dfighter1985 8fa5067506 Created my GSOC2013 branch.
--HG--
branch : gsoc2013-dfighter
12 years ago

@ -136,6 +136,14 @@ MACRO(NL_ADD_STATIC_VID_DRIVERS name)
ENDIF() ENDIF()
ENDIF() ENDIF()
IF(WITH_DRIVER_OPENGL3)
IF(WIN32)
TARGET_LINK_LIBRARIES(${name} nel_drv_opengl3_win)
ELSE(WIN32)
TARGET_LINK_LIBRARIES(${name} nel_drv_opengl3)
ENDIF()
ENDIF()
IF(WITH_DRIVER_OPENGLES) IF(WITH_DRIVER_OPENGLES)
IF(WIN32) IF(WIN32)
TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win) TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win)
@ -303,6 +311,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
# Drivers Support # Drivers Support
### ###
OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON ) OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON )
OPTION(WITH_DRIVER_OPENGL3 "Build OpenGL3 Driver (3D)" OFF)
OPTION(WITH_DRIVER_OPENGLES "Build OpenGL ES Driver (3D)" OFF) OPTION(WITH_DRIVER_OPENGLES "Build OpenGL ES Driver (3D)" OFF)
OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF) OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF)
OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON ) OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON )

@ -298,7 +298,7 @@ public:
virtual bool clearZBuffer(float zval=1) = 0; virtual bool clearZBuffer(float zval=1) = 0;
/// Clear the current target surface stencil buffer. The function ignores the viewport settings but uses the scissor. /// Clear the current target surface stencil buffer. The function ignores the viewport settings but uses the scissor.
virtual bool clearStencilBuffer(float stencilval=0) = 0; virtual bool clearStencilBuffer(sint stencilval=0) = 0;
/// Set the color mask filter through where the operation done will pass /// Set the color mask filter through where the operation done will pass
virtual void setColorMask(bool bRed, bool bGreen, bool bBlue, bool bAlpha) = 0; virtual void setColorMask(bool bRed, bool bGreen, bool bBlue, bool bAlpha) = 0;
@ -580,7 +580,7 @@ public:
bool getStaticMemoryToVRAM() const { return _StaticMemoryToVRAM; } bool getStaticMemoryToVRAM() const { return _StaticMemoryToVRAM; }
/* Set to true if static vertex and index buffers must by allocated in VRAM, false in AGP. /* Set to true if static vertex and index buffers must by allocated in VRAM, false in AGP.
* Default is false. * Default is true.
*/ */
void setStaticMemoryToVRAM(bool staticMemoryToVRAM); void setStaticMemoryToVRAM(bool staticMemoryToVRAM);

@ -33,10 +33,12 @@
# define NL3D_D3D_DLL_NAME "libnel_drv_direct3d_win" # define NL3D_D3D_DLL_NAME "libnel_drv_direct3d_win"
#elif defined (NL_OS_WINDOWS) #elif defined (NL_OS_WINDOWS)
# define NL3D_GL_DLL_NAME "nel_drv_opengl_win" # define NL3D_GL_DLL_NAME "nel_drv_opengl_win"
# define NL3D_GL3_DLL_NAME "nel_drv_opengl3_win"
# define NL3D_GLES_DLL_NAME "nel_drv_opengles_win" # define NL3D_GLES_DLL_NAME "nel_drv_opengles_win"
# define NL3D_D3D_DLL_NAME "nel_drv_direct3d_win" # define NL3D_D3D_DLL_NAME "nel_drv_direct3d_win"
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
# define NL3D_GL_DLL_NAME "nel_drv_opengl" # define NL3D_GL_DLL_NAME "nel_drv_opengl"
# define NL3D_GL3_DLL_NAME "nel_drv_opengl3"
# define NL3D_GLES_DLL_NAME "nel_drv_opengles" # define NL3D_GLES_DLL_NAME "nel_drv_opengles"
#else #else
# error "Unknown system" # error "Unknown system"
@ -77,6 +79,32 @@ struct EDruOpenglDriverCantCreateDriver : public EDru
EDruOpenglDriverCantCreateDriver() : EDru( NL3D_GL_DLL_NAME " can't create driver" ) {} EDruOpenglDriverCantCreateDriver() : EDru( NL3D_GL_DLL_NAME " can't create driver" ) {}
}; };
// OpenGL 3
struct EDruOpengl3DriverNotFound : public EDru
{
EDruOpengl3DriverNotFound() : EDru( NL3D_GL3_DLL_NAME " not found" ) {}
};
struct EDruOpengl3DriverCorrupted : public EDru
{
EDruOpengl3DriverCorrupted() : EDru( "Can't get NL3D_createIDriverInstance from " NL3D_GL3_DLL_NAME " (Bad dll?)" ) {}
};
struct EDruOpengl3DriverOldVersion : public EDru
{
EDruOpengl3DriverOldVersion() : EDru( NL3D_GL3_DLL_NAME " is a too old version. Ask for a more recent file" ) {}
};
struct EDruOpengl3DriverUnknownVersion : public EDru
{
EDruOpengl3DriverUnknownVersion() : EDru( NL3D_GL3_DLL_NAME " is more recent than the application" ) {}
};
struct EDruOpengl3DriverCantCreateDriver : public EDru
{
EDruOpengl3DriverCantCreateDriver() : EDru( NL3D_GL3_DLL_NAME " can't create driver" ) {}
};
// OpenGL ES // OpenGL ES
struct EDruOpenglEsDriverNotFound : public EDru struct EDruOpenglEsDriverNotFound : public EDru
{ {
@ -139,6 +167,9 @@ public:
/// Portable Function which create a GL Driver (using gl dll...). /// Portable Function which create a GL Driver (using gl dll...).
static IDriver *createGlDriver(); static IDriver *createGlDriver();
/// Portable Function which create a GL3 Driver (using gl dll...).
static IDriver *createGl3Driver() throw(EDru);
/// Portable Function which create a GL ES Driver (using gl dll...). /// Portable Function which create a GL ES Driver (using gl dll...).
static IDriver *createGlEsDriver(); static IDriver *createGlEsDriver();

@ -35,6 +35,8 @@
namespace NL3D { namespace NL3D {
static const uint32 IDRV_PROGRAM_MAXSAMPLERS = 32;
// List typedef. // List typedef.
class IDriver; class IDriver;
class IProgramDrvInfos; class IProgramDrvInfos;
@ -116,7 +118,202 @@ struct CProgramIndex
ModelViewProjectionTranspose, ModelViewProjectionTranspose,
ModelViewProjectionInverseTranspose, ModelViewProjectionInverseTranspose,
NormalMatrix,
ViewMatrix,
Fog, Fog,
FogParams,
FogColor,
Color,
//DiffuseColor,
AlphaRef,
Constant0,
Constant1,
Constant2,
Constant3,
Constant4,
Constant5,
Constant6,
Constant7,
Constant8,
Constant9,
Constant10,
Constant11,
Constant12,
Constant13,
Constant14,
Constant15,
Constant16,
Constant17,
Constant18,
Constant19,
Constant20,
Constant21,
Constant22,
Constant23,
Constant24,
Constant25,
Constant26,
Constant27,
Constant28,
Constant29,
Constant30,
Constant31,
Sampler0,
Sampler1,
Sampler2,
Sampler3,
Sampler4,
Sampler5,
Sampler6,
Sampler7,
Sampler8,
Sampler9,
Sampler10,
Sampler11,
Sampler12,
Sampler13,
Sampler14,
Sampler15,
Sampler16,
Sampler17,
Sampler18,
Sampler19,
Sampler20,
Sampler21,
Sampler22,
Sampler23,
Sampler24,
Sampler25,
Sampler26,
Sampler27,
Sampler28,
Sampler29,
Sampler30,
Sampler31,
TexMatrix0,
TexMatrix1,
TexMatrix2,
TexMatrix3,
TexGen0ObjectPlaneS,
TexGen0ObjectPlaneT,
TexGen0ObjectPlaneP,
TexGen0ObjectPlaneQ,
TexGen1ObjectPlaneS,
TexGen1ObjectPlaneT,
TexGen1ObjectPlaneP,
TexGen1ObjectPlaneQ,
TexGen2ObjectPlaneS,
TexGen2ObjectPlaneT,
TexGen2ObjectPlaneP,
TexGen2ObjectPlaneQ,
TexGen3ObjectPlaneS,
TexGen3ObjectPlaneT,
TexGen3ObjectPlaneP,
TexGen3ObjectPlaneQ,
TexGen0EyePlaneS,
TexGen0EyePlaneT,
TexGen0EyePlaneP,
TexGen0EyePlaneQ,
TexGen1EyePlaneS,
TexGen1EyePlaneT,
TexGen1EyePlaneP,
TexGen1EyePlaneQ,
TexGen2EyePlaneS,
TexGen2EyePlaneT,
TexGen2EyePlaneP,
TexGen2EyePlaneQ,
TexGen3EyePlaneS,
TexGen3EyePlaneT,
TexGen3EyePlaneP,
TexGen3EyePlaneQ,
SelfIllumination,
Light0DirOrPos,
Light1DirOrPos,
Light2DirOrPos,
Light3DirOrPos,
Light4DirOrPos,
Light5DirOrPos,
Light6DirOrPos,
Light7DirOrPos,
Light0ColAmb,
Light1ColAmb,
Light2ColAmb,
Light3ColAmb,
Light4ColAmb,
Light5ColAmb,
Light6ColAmb,
Light7ColAmb,
Light0ColDiff,
Light1ColDiff,
Light2ColDiff,
Light3ColDiff,
Light4ColDiff,
Light5ColDiff,
Light6ColDiff,
Light7ColDiff,
Light0ColSpec,
Light1ColSpec,
Light2ColSpec,
Light3ColSpec,
Light4ColSpec,
Light5ColSpec,
Light6ColSpec,
Light7ColSpec,
Light0Shininess,
Light1Shininess,
Light2Shininess,
Light3Shininess,
Light4Shininess,
Light5Shininess,
Light6Shininess,
Light7Shininess,
Light0ConstAttn,
Light1ConstAttn,
Light2ConstAttn,
Light3ConstAttn,
Light4ConstAttn,
Light5ConstAttn,
Light6ConstAttn,
Light7ConstAttn,
Light0LinAttn,
Light1LinAttn,
Light2LinAttn,
Light3LinAttn,
Light4LinAttn,
Light5LinAttn,
Light6LinAttn,
Light7LinAttn,
Light0QuadAttn,
Light1QuadAttn,
Light2QuadAttn,
Light3QuadAttn,
Light4QuadAttn,
Light5QuadAttn,
Light6QuadAttn,
Light7QuadAttn,
NUM_UNIFORMS NUM_UNIFORMS
}; };

@ -145,7 +145,7 @@ public:
enum TStencilFunc { never = 0, less, lessequal, equal, notequal, greaterequal, greater, always}; enum TStencilFunc { never = 0, less, lessequal, equal, notequal, greaterequal, greater, always};
// Existing drivers // Existing drivers
enum TDriver { Direct3d = 0, OpenGl, OpenGlEs }; enum TDriver { Direct3d = 0, OpenGl, OpenGlEs, OpenGl3 };
public: public:
/// The EventServer of this driver. Init after setDisplay()!! /// The EventServer of this driver. Init after setDisplay()!!

@ -0,0 +1,121 @@
/*
Copyright (C) 2015 Jan Boon <jan.boon@kaetemi.be>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NL_UNIFORM_BUFFER_H
#define NL_UNIFORM_BUFFER_H
#include <nel/misc/types_nl.h>
#include <nel/misc/smart_ptr.h>
#include <nel/misc/vector.h>
#include <nel/misc/vector_2f.h>
#include <nel/misc/vector_h.h>
#include <nel/misc/matrix.h>
#include <nel/3d/uniform_buffer_format.h>
#define NL3D_UNIFORM_BUFFER_DEBUG 1
namespace NLMISC {
class CMatrix;
}
namespace NL3D {
class CUniformBuffer;
class IUBDrvInfos;
typedef std::list<IUBDrvInfos*> TUBDrvInfoPtrList;
typedef TUBDrvInfoPtrList::iterator ItUBDrvInfoPtrList;
/*
**** IMPORTANT ********************
**** IF YOU MODIFY THE STRUCTURE OF THIS CLASS, PLEASE INCREMENT IDriver::InterfaceVersion TO INVALIDATE OLD DRIVER DLL
***********************************
*/
#if NL3D_UNIFORM_BUFFER_DEBUG
#define NL3D_UNIFORM_BUFFER_ASSERT_LOCKED(ub) nlassert(ub->Locked)
#else
#define NL3D_UNIFORM_BUFFER_ASSERT_LOCKED(ub) /* ub->Locked doesn't exist when NL3D_UNIFORM_BUFFER_DEBUG is 0 */
#endif
// Uniform buffer
class CUniformBuffer : public NLMISC::CRefCount
{
public:
CUniformBuffer();
~CUniformBuffer();
void *lock();
void unlock();
inline void set(sint offset, float f) { NL3D_UNIFORM_BUFFER_ASSERT_LOCKED(this); reinterpret_cast<float &>(m_HostMemory[offset]) = f; }
inline void set(sint offset, float f0, float f1) { NL3D_UNIFORM_BUFFER_ASSERT_LOCKED(this); float *f = reinterpret_cast<float *>(&m_HostMemory[offset]); f[0] = f0; f[1] = f1; }
inline void set(sint offset, float f0, float f1, float f2) { NL3D_UNIFORM_BUFFER_ASSERT_LOCKED(this); float *f = reinterpret_cast<float *>(&m_HostMemory[offset]); f[0] = f0; f[1] = f1; f[2] = f2; }
inline void set(sint offset, float f0, float f1, float f2, float f3) { NL3D_UNIFORM_BUFFER_ASSERT_LOCKED(this); float *f = reinterpret_cast<float *>(&m_HostMemory[offset]); f[0] = f0; f[1] = f1; f[2] = f2; f[3] = f3; }
inline void set(sint offset, NLMISC::CVector2f vec2) { NL3D_UNIFORM_BUFFER_ASSERT_LOCKED(this); reinterpret_cast<NLMISC::CVector2f &>(m_HostMemory[offset]) = vec2; }
inline void set(sint offset, NLMISC::CVector vec3) { NL3D_UNIFORM_BUFFER_ASSERT_LOCKED(this); reinterpret_cast<NLMISC::CVector &>(m_HostMemory[offset]) = vec3; }
inline void set(sint offset, NLMISC::CVectorH vec4) { NL3D_UNIFORM_BUFFER_ASSERT_LOCKED(this); reinterpret_cast<NLMISC::CVectorH &>(m_HostMemory[offset]) = vec4; }
inline void set(sint offset, NLMISC::CMatrix mat4) { NL3D_UNIFORM_BUFFER_ASSERT_LOCKED(this); float *f = reinterpret_cast<float *>(&m_HostMemory[offset]); mat4.get(f); }
private:
std::vector<char> m_HostMemory;
public:
CUniformBufferFormat Format;
public: // Driver-only
NLMISC::CRefPtr<IUBDrvInfos> DrvInfos;
bool Touched;
#if NL3D_UNIFORM_BUFFER_DEBUG
sint Locked;
#endif
};
// TODO: Investigate if more efficient or not to do like vertex_buffer and call into driver for locking (what are best practices for updating uniform buffers?)
class IUBDrvInfos : public NLMISC::CRefCount
{
protected:
IDriver *m_Driver;
private:
ItUBDrvInfoPtrList m_DriverIterator;
public:
NLMISC::CRefPtr<CUniformBuffer> UniformBufferPtr;
IUBDrvInfos(IDriver *drv, ItUBDrvInfoPtrList it, CUniformBuffer *ub) { m_Driver = drv; m_DriverIterator = it; UniformBufferPtr = ub; }
virtual ~IUBDrvInfos();
};
} /* namespace NL3D */
#endif /* #ifndef NL_UNIFORM_BUFFER_H */
/* end of file */

@ -0,0 +1,145 @@
/*
Copyright (C) 2015 Jan Boon <jan.boon@kaetemi.be>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NL_UNIFORM_BUFFER_FORMAT_H
#define NL_UNIFORM_BUFFER_FORMAT_H
#include <nel/misc/types_nl.h>
#include <nel/misc/string_mapper.h>
namespace NL3D {
/*
**** IMPORTANT ********************
**** IF YOU MODIFY THE STRUCTURE OF THIS CLASS, PLEASE INCREMENT IDriver::InterfaceVersion TO INVALIDATE OLD DRIVER DLL
***********************************
*/
// Uniform buffer format generation following glsl std140 rules
class CUniformBufferFormat
{
public:
CUniformBufferFormat() : m_Hash(0) { }
// When changing, update
// - s_TypeAlignment
// - s_TypeSize
// - NL3D::NLDRIVERGL3::s_TypeKeyword
enum TType
{
Float, // float
FloatVec2, // CVector2f
FloatVec3, // CVector
FloatVec4, // CVectorH
SInt, // sint32
SIntVec2,
SIntVec3,
SIntVec4,
UInt, // uint32
UIntVec2,
UIntVec3,
UIntVec4,
Bool,
BoolVec2,
BoolVec3,
BoolVec4,
FloatMat2,
FloatMat3,
FloatMat4, // CMatrix
FloatMat2x3,
FloatMat2x4,
FloatMat3x2,
FloatMat3x4,
FloatMat4x2,
FloatMat4x3,
};
struct CEntry
{
NLMISC::TStringId Name;
TType Type;
sint Offset;
sint Count;
inline sint stride() const
{
return Count == 1
? s_TypeSize[Type]
: ((s_TypeSize[Type] + 15) & ~0xF);
}
inline sint size() const
{
return stride() * Count;
}
inline sint offset(int i) const
{
return Offset + (stride() * i);
}
};
// Push a variable. Returns the byte offset in uniform buffer
// Note: Does not check for duplicate names. However, names must be unique
sint push(const std::string &name, TType type, sint count = 1);
inline const CEntry &get(sint i) const { return m_Entries[i]; }
inline size_t count() const { return m_Entries.size(); } // Return number of entries
inline void clear() { m_Entries.clear(); m_Hash = 0; }
inline sint size() const { return m_Entries.size() ? (((m_Entries.back().Offset + m_Entries.back().size()) + 15) & ~0xF) : 0; } // Return size of format in bytes
inline size_t hash() const { return m_Hash; }
// Get the offset by entry id (counted from 0 in the order of addition to the format) and index of array
inline sint offset(sint entry, sint index = 0) const { m_Entries[entry].offset(index); }
private:
static const sint s_TypeAlignment[];
static const sint s_TypeSize[];
typedef std::vector<CEntry> TEntries;
TEntries m_Entries;
size_t m_Hash;
};
void testUniformBufferFormat(CUniformBufferFormat &ubf);
} /* namespace NL3D */
namespace std {
template <>
struct hash<NL3D::CUniformBufferFormat>
{
size_t operator()(const NL3D::CUniformBufferFormat & v) const { return v.hash(); }
};
} /* namespace std */
#endif /* #ifndef NL_UNIFORM_BUFFER_FORMAT_H */
/* end of file */

@ -1202,7 +1202,6 @@ inline void CVertexBuffer::lock (CVertexBufferRead &accessor, uint first, uint l
if (last == 0) if (last == 0)
last = _NbVerts; last = _NbVerts;
// Can read it ? // Can read it ?
nlassertex (_Location==RAMResident, ("Try to read a write only vertex buffer"));
_LockedBuffer = DrvInfos->lock (first*_VertexSize, last*_VertexSize, true); _LockedBuffer = DrvInfos->lock (first*_VertexSize, last*_VertexSize, true);
} }
else else

@ -167,6 +167,10 @@ public:
* \param i : column index. * \param i : column index.
* \param j : line index. * \param j : line index.
*/ */
void setFlags();
void setCoefficient(float coeff, sint i, sint j) void setCoefficient(float coeff, sint i, sint j)
{ {
M[ (j<<2) + i] = coeff; M[ (j<<2) + i] = coeff;
@ -361,6 +365,9 @@ public:
/// Plane (line vector) multiplication. /// Plane (line vector) multiplication.
friend CPlane operator*(const CPlane &p, const CMatrix &m); friend CPlane operator*(const CPlane &p, const CMatrix &m);
void frustum(float left, float right, float bottom, float top, float znear, float zfar );
void ortho(float left, float right, float bottom, float top, float znear, float zfar );
private: private:
float M[16]; float M[16];

@ -45,7 +45,7 @@ const uint32 IDriver::InterfaceVersion = 0x70; // total video memory
IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" ) IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" )
{ {
_PolygonMode= Filled; _PolygonMode= Filled;
_StaticMemoryToVRAM=false; _StaticMemoryToVRAM=true;
_ResetCounter=0; _ResetCounter=0;
} }

@ -2,6 +2,10 @@ IF(WITH_DRIVER_OPENGL)
ADD_SUBDIRECTORY(opengl) ADD_SUBDIRECTORY(opengl)
ENDIF() ENDIF()
IF(WITH_DRIVER_OPENGL3)
ADD_SUBDIRECTORY(opengl3)
ENDIF(WITH_DRIVER_OPENGL3)
IF(WITH_DRIVER_OPENGLES) IF(WITH_DRIVER_OPENGLES)
ADD_SUBDIRECTORY(opengles) ADD_SUBDIRECTORY(opengles)
ENDIF() ENDIF()

@ -1960,7 +1960,7 @@ bool CDriverD3D::clearZBuffer(float zval)
// *************************************************************************** // ***************************************************************************
bool CDriverD3D::clearStencilBuffer(float stencilval) bool CDriverD3D::clearStencilBuffer(sint stencilval)
{ {
H_AUTO_D3D(CDriverD3D_clearStencilBuffer); H_AUTO_D3D(CDriverD3D_clearStencilBuffer);
nlassert (_DeviceInterface); nlassert (_DeviceInterface);

@ -932,7 +932,7 @@ public:
// Buffer // Buffer
virtual bool clear2D(CRGBA rgba); virtual bool clear2D(CRGBA rgba);
virtual bool clearZBuffer(float zval=1); virtual bool clearZBuffer(float zval=1);
virtual bool clearStencilBuffer(float stencilval=0); virtual bool clearStencilBuffer(sint stencilval=0);
virtual void setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha); virtual void setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha);
virtual bool swapBuffers(); virtual bool swapBuffers();
virtual void getBuffer (CBitmap &bitmap); // Only 32 bits back buffer supported virtual void getBuffer (CBitmap &bitmap); // Only 32 bits back buffer supported

@ -300,11 +300,6 @@ CDriverGL::CDriverGL()
for(i = 0; i < IDRV_MAT_MAXTEXTURES; i++) for(i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
{ {
_MaterialAllTextureTouchedFlag |= IDRV_TOUCHED_TEX[i]; _MaterialAllTextureTouchedFlag |= IDRV_TOUCHED_TEX[i];
#ifdef GL_NONE
_CurrentTexAddrMode[i] = GL_NONE;
#else
_CurrentTexAddrMode[i] = 0;
#endif
} }
_UserTexMatEnabled = 0; _UserTexMatEnabled = 0;
@ -825,10 +820,10 @@ bool CDriverGL::clearZBuffer(float zval)
} }
// -------------------------------------------------- // --------------------------------------------------
bool CDriverGL::clearStencilBuffer(float stencilval) bool CDriverGL::clearStencilBuffer(sint stencilval)
{ {
H_AUTO_OGL(CDriverGL_clearStencilBuffer) H_AUTO_OGL(CDriverGL_clearStencilBuffer)
glClearStencil((int)stencilval); glClearStencil(stencilval);
glClear(GL_STENCIL_BUFFER_BIT); glClear(GL_STENCIL_BUFFER_BIT);

@ -373,7 +373,7 @@ public:
virtual bool clear2D(CRGBA rgba); virtual bool clear2D(CRGBA rgba);
virtual bool clearZBuffer(float zval=1); virtual bool clearZBuffer(float zval=1);
virtual bool clearStencilBuffer(float stencilval=0); virtual bool clearStencilBuffer(sint stencilval=0);
virtual void setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha); virtual void setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha);
virtual void setDepthRange(float znear, float zfar); virtual void setDepthRange(float znear, float zfar);
virtual void getDepthRange(float &znear, float &zfar) const; virtual void getDepthRange(float &znear, float &zfar) const;

@ -0,0 +1,81 @@
FIND_PACKAGE(OpenGL REQUIRED)
IF(NOT WIN32)
IF(APPLE)
FIND_LIBRARY(CARBON NAMES Carbon)
FIND_LIBRARY(COCOA NAMES Cocoa)
ELSE(APPLE)
FIND_PACKAGE(X11)
FIND_PACKAGE(XF86VidMode)
ENDIF(APPLE)
ENDIF(NOT WIN32)
FILE(GLOB SRC *.cpp *.h *.def)
IF(APPLE)
FILE(GLOB MAC_SRC mac/*.h mac/*.m mac/*.mm mac/*.cpp)
SET(SRC ${SRC} ${MAC_SRC})
SET_SOURCE_FILES_PROPERTIES(${SRC}
PROPERTIES COMPILE_FLAGS "-x objective-c++")
ENDIF(APPLE)
IF(WIN32)
SET(NLDRV_OGL_LIB "nel_drv_opengl3_win")
ELSE(WIN32)
SET(NLDRV_OGL_LIB "nel_drv_opengl3")
ENDIF(WIN32)
NL_TARGET_DRIVER(${NLDRV_OGL_LIB} ${SRC})
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} nel3d nelmisc ${OPENGL_gl_LIBRARY})
NL_DEFAULT_PROPS(${NLDRV_OGL_LIB} "NeL, Driver, Video: OpenGL3")
NL_ADD_LIB_SUFFIX(${NLDRV_OGL_LIB})
NL_ADD_RUNTIME_FLAGS(${NLDRV_OGL_LIB})
IF(WIN32)
INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY})
ADD_DEFINITIONS(/DDRIVER_OPENGL_EXPORTS)
ENDIF(WIN32)
IF(APPLE)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${CARBON})
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${COCOA})
ENDIF(APPLE)
IF(UNIX AND NOT APPLE)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_X11_LIB})
IF(XF86VidMode_FOUND)
INCLUDE_DIRECTORIES(${XF86VidMode_INCLUDE_DIR})
ADD_DEFINITIONS(${XF86VidMode_DEFINITIONS})
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XF86VidMode_LIBRARY})
ENDIF(XF86VidMode_FOUND)
IF(X11_Xrandr_FOUND)
INCLUDE_DIRECTORIES(${X11_Xrandr_INCLUDE_PATH})
ADD_DEFINITIONS(-DHAVE_XRANDR)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xrandr_LIB})
ENDIF(X11_Xrandr_FOUND)
IF(X11_Xrender_FOUND)
INCLUDE_DIRECTORIES(${X11_Xrender_INCLUDE_PATH})
ADD_DEFINITIONS(-DHAVE_XRENDER)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xrender_LIB})
ENDIF(X11_Xrender_FOUND)
IF(X11_Xcursor_FOUND)
INCLUDE_DIRECTORIES(${X11_Xcursor_INCLUDE_PATH})
ADD_DEFINITIONS(-DHAVE_XCURSOR)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xcursor_LIB})
ENDIF(X11_Xcursor_FOUND)
ENDIF(UNIX AND NOT APPLE)
IF(WITH_PCH)
ADD_NATIVE_PRECOMPILED_HEADER(${NLDRV_OGL_LIB} ${CMAKE_CURRENT_SOURCE_DIR}/stdopengl.h ${CMAKE_CURRENT_SOURCE_DIR}/stdopengl.cpp)
ENDIF(WITH_PCH)
IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC_DRIVERS) OR NOT WITH_STATIC_DRIVERS)
INSTALL(TARGETS ${NLDRV_OGL_LIB} LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${NL_DRIVER_PREFIX} COMPONENT drivers3d)
IF(WITH_MAXPLUGIN)
INSTALL(TARGETS ${NLDRV_OGL_LIB} RUNTIME DESTINATION maxplugin COMPONENT drivers3d)
ENDIF(WITH_MAXPLUGIN)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC_DRIVERS) OR NOT WITH_STATIC_DRIVERS)

@ -0,0 +1,329 @@
/* -*- mode: c; tab-width: 8; -*- */
/* vi: set sw=4 ts=8: */
/* Reference version of egl.h for EGL 1.4.
* $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
*/
/*
** Copyright (c) 2007-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#ifndef __egl_h_
#define __egl_h_
/* All platform-dependent types and macro boilerplate (such as EGLAPI
* and EGLAPIENTRY) should go in eglplatform.h.
*/
#include <EGL/eglplatform.h>
#ifdef __cplusplus
extern "C" {
#endif
/* EGL Types */
/* EGLint is defined in eglplatform.h */
typedef unsigned int EGLBoolean;
typedef unsigned int EGLenum;
typedef void *EGLConfig;
typedef void *EGLContext;
typedef void *EGLDisplay;
typedef void *EGLSurface;
typedef void *EGLClientBuffer;
/* EGL Versioning */
#define EGL_VERSION_1_0 1
#define EGL_VERSION_1_1 1
#define EGL_VERSION_1_2 1
#define EGL_VERSION_1_3 1
#define EGL_VERSION_1_4 1
/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
* enums are assigned unique values starting at 0x3000.
*/
/* EGL aliases */
#define EGL_FALSE 0
#define EGL_TRUE 1
/* Out-of-band handle values */
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
#define EGL_NO_CONTEXT ((EGLContext)0)
#define EGL_NO_DISPLAY ((EGLDisplay)0)
#define EGL_NO_SURFACE ((EGLSurface)0)
/* Out-of-band attribute value */
#define EGL_DONT_CARE ((EGLint)-1)
/* Errors / GetError return values */
#define EGL_SUCCESS 0x3000
#define EGL_NOT_INITIALIZED 0x3001
#define EGL_BAD_ACCESS 0x3002
#define EGL_BAD_ALLOC 0x3003
#define EGL_BAD_ATTRIBUTE 0x3004
#define EGL_BAD_CONFIG 0x3005
#define EGL_BAD_CONTEXT 0x3006
#define EGL_BAD_CURRENT_SURFACE 0x3007
#define EGL_BAD_DISPLAY 0x3008
#define EGL_BAD_MATCH 0x3009
#define EGL_BAD_NATIVE_PIXMAP 0x300A
#define EGL_BAD_NATIVE_WINDOW 0x300B
#define EGL_BAD_PARAMETER 0x300C
#define EGL_BAD_SURFACE 0x300D
#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */
/* Reserved 0x300F-0x301F for additional errors */
/* Config attributes */
#define EGL_BUFFER_SIZE 0x3020
#define EGL_ALPHA_SIZE 0x3021
#define EGL_BLUE_SIZE 0x3022
#define EGL_GREEN_SIZE 0x3023
#define EGL_RED_SIZE 0x3024
#define EGL_DEPTH_SIZE 0x3025
#define EGL_STENCIL_SIZE 0x3026
#define EGL_CONFIG_CAVEAT 0x3027
#define EGL_CONFIG_ID 0x3028
#define EGL_LEVEL 0x3029
#define EGL_MAX_PBUFFER_HEIGHT 0x302A
#define EGL_MAX_PBUFFER_PIXELS 0x302B
#define EGL_MAX_PBUFFER_WIDTH 0x302C
#define EGL_NATIVE_RENDERABLE 0x302D
#define EGL_NATIVE_VISUAL_ID 0x302E
#define EGL_NATIVE_VISUAL_TYPE 0x302F
#define EGL_SAMPLES 0x3031
#define EGL_SAMPLE_BUFFERS 0x3032
#define EGL_SURFACE_TYPE 0x3033
#define EGL_TRANSPARENT_TYPE 0x3034
#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
#define EGL_TRANSPARENT_RED_VALUE 0x3037
#define EGL_NONE 0x3038 /* Attrib list terminator */
#define EGL_BIND_TO_TEXTURE_RGB 0x3039
#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
#define EGL_MIN_SWAP_INTERVAL 0x303B
#define EGL_MAX_SWAP_INTERVAL 0x303C
#define EGL_LUMINANCE_SIZE 0x303D
#define EGL_ALPHA_MASK_SIZE 0x303E
#define EGL_COLOR_BUFFER_TYPE 0x303F
#define EGL_RENDERABLE_TYPE 0x3040
#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */
#define EGL_CONFORMANT 0x3042
/* Reserved 0x3041-0x304F for additional config attributes */
/* Config attribute values */
#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */
#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */
#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */
#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */
#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */
/* More config attribute values, for EGL_TEXTURE_FORMAT */
#define EGL_NO_TEXTURE 0x305C
#define EGL_TEXTURE_RGB 0x305D
#define EGL_TEXTURE_RGBA 0x305E
#define EGL_TEXTURE_2D 0x305F
/* Config attribute mask bits */
#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */
#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */
#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */
#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */
#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */
#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */
#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */
#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */
/* QueryString targets */
#define EGL_VENDOR 0x3053
#define EGL_VERSION 0x3054
#define EGL_EXTENSIONS 0x3055
#define EGL_CLIENT_APIS 0x308D
/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
#define EGL_HEIGHT 0x3056
#define EGL_WIDTH 0x3057
#define EGL_LARGEST_PBUFFER 0x3058
#define EGL_TEXTURE_FORMAT 0x3080
#define EGL_TEXTURE_TARGET 0x3081
#define EGL_MIPMAP_TEXTURE 0x3082
#define EGL_MIPMAP_LEVEL 0x3083
#define EGL_RENDER_BUFFER 0x3086
#define EGL_VG_COLORSPACE 0x3087
#define EGL_VG_ALPHA_FORMAT 0x3088
#define EGL_HORIZONTAL_RESOLUTION 0x3090
#define EGL_VERTICAL_RESOLUTION 0x3091
#define EGL_PIXEL_ASPECT_RATIO 0x3092
#define EGL_SWAP_BEHAVIOR 0x3093
#define EGL_MULTISAMPLE_RESOLVE 0x3099
/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
#define EGL_BACK_BUFFER 0x3084
#define EGL_SINGLE_BUFFER 0x3085
/* OpenVG color spaces */
#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */
#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */
/* OpenVG alpha formats */
#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */
#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */
/* Constant scale factor by which fractional display resolutions &
* aspect ratio are scaled when queried as integer values.
*/
#define EGL_DISPLAY_SCALING 10000
/* Unknown display resolution/aspect ratio */
#define EGL_UNKNOWN ((EGLint)-1)
/* Back buffer swap behaviors */
#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */
#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */
/* CreatePbufferFromClientBuffer buffer types */
#define EGL_OPENVG_IMAGE 0x3096
/* QueryContext targets */
#define EGL_CONTEXT_CLIENT_TYPE 0x3097
/* CreateContext attributes */
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
/* Multisample resolution behaviors */
#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */
#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */
/* BindAPI/QueryAPI targets */
#define EGL_OPENGL_ES_API 0x30A0
#define EGL_OPENVG_API 0x30A1
#define EGL_OPENGL_API 0x30A2
/* GetCurrentSurface targets */
#define EGL_DRAW 0x3059
#define EGL_READ 0x305A
/* WaitNative engines */
#define EGL_CORE_NATIVE_ENGINE 0x305B
/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
#define EGL_COLORSPACE EGL_VG_COLORSPACE
#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT
#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB
#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR
#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE
#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE
/* EGL extensions must request enum blocks from the Khronos
* API Registrar, who maintains the enumerant registry. Submit
* a bug in Khronos Bugzilla against task "Registry".
*/
/* EGL Functions */
EGLAPI EGLint EGLAPIENTRY eglGetError(void);
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
EGLint config_size, EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
EGLConfig *configs, EGLint config_size,
EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
EGLint attribute, EGLint *value);
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
EGLNativeWindowType win,
const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
EGLNativePixmapType pixmap,
const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
EGLConfig config, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
EGLint attribute, EGLint value);
EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
EGLContext share_context,
const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
EGLSurface read, EGLContext ctx);
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
EGLNativePixmapType target);
/* This is a generic function pointer type, whose name indicates it must
* be cast to the proper type *and calling convention* before use.
*/
typedef void (*__eglMustCastToProperFunctionPointerType)(void);
/* Now, define eglGetProcAddress using the generic function ptr. type */
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
eglGetProcAddress(const char *procname);
#ifdef __cplusplus
}
#endif
#endif /* __egl_h_ */

@ -0,0 +1,488 @@
#ifndef __eglext_h_
#define __eglext_h_
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2007-2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#include <EGL/eglplatform.h>
/*************************************************************/
/* Header file version number */
/* Current version at http://www.khronos.org/registry/egl/ */
/* $Revision: 19332 $ on $Date: 2012-09-28 17:56:20 -0700 (Fri, 28 Sep 2012) $ */
#define EGL_EGLEXT_VERSION 14
#ifndef EGL_KHR_config_attribs
#define EGL_KHR_config_attribs 1
#define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */
#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */
#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */
#endif
#ifndef EGL_KHR_lock_surface
#define EGL_KHR_lock_surface 1
#define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */
#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */
#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */
#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */
#define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */
#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */
#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */
#define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */
#define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */
#define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */
#define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */
#define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);
#endif
#ifndef EGL_KHR_image
#define EGL_KHR_image 1
#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */
typedef void *EGLImageKHR;
#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
#endif
#ifndef EGL_KHR_vg_parent_image
#define EGL_KHR_vg_parent_image 1
#define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */
#endif
#ifndef EGL_KHR_gl_texture_2D_image
#define EGL_KHR_gl_texture_2D_image 1
#define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */
#endif
#ifndef EGL_KHR_gl_texture_cubemap_image
#define EGL_KHR_gl_texture_cubemap_image 1
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */
#endif
#ifndef EGL_KHR_gl_texture_3D_image
#define EGL_KHR_gl_texture_3D_image 1
#define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */
#endif
#ifndef EGL_KHR_gl_renderbuffer_image
#define EGL_KHR_gl_renderbuffer_image 1
#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */
#ifndef EGL_KHR_reusable_sync
#define EGL_KHR_reusable_sync 1
typedef void* EGLSyncKHR;
typedef khronos_utime_nanoseconds_t EGLTimeKHR;
#define EGL_SYNC_STATUS_KHR 0x30F1
#define EGL_SIGNALED_KHR 0x30F2
#define EGL_UNSIGNALED_KHR 0x30F3
#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5
#define EGL_CONDITION_SATISFIED_KHR 0x30F6
#define EGL_SYNC_TYPE_KHR 0x30F7
#define EGL_SYNC_REUSABLE_KHR 0x30FA
#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR <flags> bitfield */
#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull
#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0)
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
#endif
#endif
#ifndef EGL_KHR_image_base
#define EGL_KHR_image_base 1
/* Most interfaces defined by EGL_KHR_image_pixmap above */
#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */
#endif
#ifndef EGL_KHR_image_pixmap
#define EGL_KHR_image_pixmap 1
/* Interfaces defined by EGL_KHR_image above */
#endif
#ifndef EGL_IMG_context_priority
#define EGL_IMG_context_priority 1
#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100
#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101
#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102
#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
#endif
#ifndef EGL_KHR_lock_surface2
#define EGL_KHR_lock_surface2 1
#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110
#endif
#ifndef EGL_NV_coverage_sample
#define EGL_NV_coverage_sample 1
#define EGL_COVERAGE_BUFFERS_NV 0x30E0
#define EGL_COVERAGE_SAMPLES_NV 0x30E1
#endif
#ifndef EGL_NV_depth_nonlinear
#define EGL_NV_depth_nonlinear 1
#define EGL_DEPTH_ENCODING_NV 0x30E2
#define EGL_DEPTH_ENCODING_NONE_NV 0
#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */
#ifndef EGL_NV_sync
#define EGL_NV_sync 1
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6
#define EGL_SYNC_STATUS_NV 0x30E7
#define EGL_SIGNALED_NV 0x30E8
#define EGL_UNSIGNALED_NV 0x30E9
#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001
#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull
#define EGL_ALREADY_SIGNALED_NV 0x30EA
#define EGL_TIMEOUT_EXPIRED_NV 0x30EB
#define EGL_CONDITION_SATISFIED_NV 0x30EC
#define EGL_SYNC_TYPE_NV 0x30ED
#define EGL_SYNC_CONDITION_NV 0x30EE
#define EGL_SYNC_FENCE_NV 0x30EF
#define EGL_NO_SYNC_NV ((EGLSyncNV)0)
typedef void* EGLSyncNV;
typedef khronos_utime_nanoseconds_t EGLTimeNV;
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync);
EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync);
EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync);
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value);
#endif
#endif
#if KHRONOS_SUPPORT_INT64 /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */
#ifndef EGL_KHR_fence_sync
#define EGL_KHR_fence_sync 1
/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
#define EGL_SYNC_CONDITION_KHR 0x30F8
#define EGL_SYNC_FENCE_KHR 0x30F9
#endif
#endif
#ifndef EGL_HI_clientpixmap
#define EGL_HI_clientpixmap 1
/* Surface Attribute */
#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74
/*
* Structure representing a client pixmap
* (pixmap's data is in client-space memory).
*/
struct EGLClientPixmapHI
{
void* pData;
EGLint iWidth;
EGLint iHeight;
EGLint iStride;
};
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
#endif /* EGL_HI_clientpixmap */
#ifndef EGL_HI_colorformats
#define EGL_HI_colorformats 1
/* Config Attribute */
#define EGL_COLOR_FORMAT_HI 0x8F70
/* Color Formats */
#define EGL_COLOR_RGB_HI 0x8F71
#define EGL_COLOR_RGBA_HI 0x8F72
#define EGL_COLOR_ARGB_HI 0x8F73
#endif /* EGL_HI_colorformats */
#ifndef EGL_MESA_drm_image
#define EGL_MESA_drm_image 1
#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 /* CreateDRMImageMESA attribute */
#define EGL_DRM_BUFFER_USE_MESA 0x31D1 /* CreateDRMImageMESA attribute */
#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 /* EGL_IMAGE_FORMAT_MESA attribute value */
#define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */
#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4
#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */
#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
#endif
#ifndef EGL_NV_post_sub_buffer
#define EGL_NV_post_sub_buffer 1
#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
#endif
#ifndef EGL_ANDROID_image_native_buffer
#define EGL_ANDROID_image_native_buffer 1
struct ANativeWindowBuffer;
#define EGL_NATIVE_BUFFER_ANDROID 0x3140 /* eglCreateImageKHR target */
#endif
#ifndef EGL_ANDROID_swap_rectangle
#define EGL_ANDROID_swap_rectangle 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglSetSwapRectangleANDROID (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSWAPRECTANGLEANDROIDPROC) (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif
#ifndef EGL_ANDROID_recordable
#define EGL_ANDROID_recordable 1
#define EGL_RECORDABLE_ANDROID 0x3142 /* EGLConfig attribute */
#endif
#ifndef EGL_ANGLE_query_surface_pointer
#define EGL_ANGLE_query_surface_pointer 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
#endif
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
#endif
#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
#endif
#ifndef EGL_NV_coverage_sample_resolve
#define EGL_NV_coverage_sample_resolve 1
#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131
#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLuint64NV requires 64-bit uint support */
#ifndef EGL_NV_system_time
#define EGL_NV_system_time 1
typedef khronos_utime_nanoseconds_t EGLuint64NV;
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);
#endif
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */
#ifndef EGL_KHR_stream
#define EGL_KHR_stream 1
typedef void* EGLStreamKHR;
typedef khronos_uint64_t EGLuint64KHR;
#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0)
#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210
#define EGL_PRODUCER_FRAME_KHR 0x3212
#define EGL_CONSUMER_FRAME_KHR 0x3213
#define EGL_STREAM_STATE_KHR 0x3214
#define EGL_STREAM_STATE_CREATED_KHR 0x3215
#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216
#define EGL_STREAM_STATE_EMPTY_KHR 0x3217
#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218
#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219
#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A
#define EGL_BAD_STREAM_KHR 0x321B
#define EGL_BAD_STATE_KHR 0x321C
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
#endif
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_consumer_gltexture
#define EGL_KHR_stream_consumer_gltexture 1
#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
#endif
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_producer_eglsurface
#define EGL_KHR_stream_producer_eglsurface 1
#define EGL_STREAM_BIT_KHR 0x0800
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
#endif
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_producer_aldatalocator
#define EGL_KHR_stream_producer_aldatalocator 1
#endif
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_fifo
#define EGL_KHR_stream_fifo 1
/* reuse EGLTimeKHR */
#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC
#define EGL_STREAM_TIME_NOW_KHR 0x31FD
#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE
#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
#endif
#endif
#ifndef EGL_EXT_create_context_robustness
#define EGL_EXT_create_context_robustness 1
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138
#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE
#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF
#endif
#ifndef EGL_ANGLE_d3d_share_handle_client_buffer
#define EGL_ANGLE_d3d_share_handle_client_buffer 1
/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */
#endif
#ifndef EGL_KHR_create_context
#define EGL_KHR_create_context 1
#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
#define EGL_CONTEXT_FLAGS_KHR 0x30FC
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
#define EGL_OPENGL_ES3_BIT_KHR 0x00000040
#endif
#ifndef EGL_KHR_surfaceless_context
#define EGL_KHR_surfaceless_context 1
/* No tokens/entry points, just relaxes an error condition */
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_cross_process_fd
#define EGL_KHR_stream_cross_process_fd 1
typedef int EGLNativeFileDescriptorKHR;
#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1))
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
#endif
#endif
#ifndef EGL_EXT_multiview_window
#define EGL_EXT_multiview_window 1
#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134
#endif
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,115 @@
#ifndef __eglplatform_h_
#define __eglplatform_h_
/*
** Copyright (c) 2007-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Platform-specific types and definitions for egl.h
* $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "EGL" component "Registry".
*/
#include <KHR/khrplatform.h>
/* Macros used in EGL function prototype declarations.
*
* EGL functions should be prototyped as:
*
* EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
*
* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
*/
#ifndef EGLAPI
#define EGLAPI KHRONOS_APICALL
#endif
#ifndef EGLAPIENTRY
#define EGLAPIENTRY KHRONOS_APIENTRY
#endif
#define EGLAPIENTRYP EGLAPIENTRY*
/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
* are aliases of window-system-dependent types, such as X Display * or
* Windows Device Context. They must be defined in platform-specific
* code below. The EGL-prefixed versions of Native*Type are the same
* types, renamed in EGL 1.3 so all types in the API start with "EGL".
*
* Khronos STRONGLY RECOMMENDS that you use the default definitions
* provided below, since these changes affect both binary and source
* portability of applications using EGL running on different EGL
* implementations.
*/
#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType;
#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
typedef int EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType;
#elif defined(__unix__)
/* X11 (tentative) */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
typedef Window EGLNativeWindowType;
#else
#error "Platform not recognized"
#endif
/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
typedef EGLNativeDisplayType NativeDisplayType;
typedef EGLNativePixmapType NativePixmapType;
typedef EGLNativeWindowType NativeWindowType;
/* Define EGLint. This must be a signed integral type large enough to contain
* all legal attribute names and values passed into and out of EGL, whether
* their type is boolean, bitmask, enumerant (symbolic constant), integer,
* handle, or other. While in general a 32-bit integer will suffice, if
* handles are 64 bit types, then EGLint should be defined as a signed 64-bit
* integer type.
*/
typedef khronos_int32_t EGLint;
#endif /* __eglplatform_h */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,943 @@
#ifndef __wglext_h_
#define __wglext_h_
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2007-2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Function declaration macros - to move into glplatform.h */
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GLAPI
#define GLAPI extern
#endif
/*************************************************************/
/* Header file version number */
/* wglext.h last updated 2012/01/04 */
/* Current version at http://www.opengl.org/registry/ */
#define WGL_WGLEXT_VERSION 24
#ifndef WGL_ARB_buffer_region
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002
#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004
#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008
#endif
#ifndef WGL_ARB_multisample
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#endif
#ifndef WGL_ARB_extensions_string
#endif
#ifndef WGL_ARB_pixel_format
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
#define WGL_ACCELERATION_ARB 0x2003
#define WGL_NEED_PALETTE_ARB 0x2004
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
#define WGL_SWAP_METHOD_ARB 0x2007
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
#define WGL_TRANSPARENT_ARB 0x200A
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
#define WGL_SHARE_DEPTH_ARB 0x200C
#define WGL_SHARE_STENCIL_ARB 0x200D
#define WGL_SHARE_ACCUM_ARB 0x200E
#define WGL_SUPPORT_GDI_ARB 0x200F
#define WGL_SUPPORT_OPENGL_ARB 0x2010
#define WGL_DOUBLE_BUFFER_ARB 0x2011
#define WGL_STEREO_ARB 0x2012
#define WGL_PIXEL_TYPE_ARB 0x2013
#define WGL_COLOR_BITS_ARB 0x2014
#define WGL_RED_BITS_ARB 0x2015
#define WGL_RED_SHIFT_ARB 0x2016
#define WGL_GREEN_BITS_ARB 0x2017
#define WGL_GREEN_SHIFT_ARB 0x2018
#define WGL_BLUE_BITS_ARB 0x2019
#define WGL_BLUE_SHIFT_ARB 0x201A
#define WGL_ALPHA_BITS_ARB 0x201B
#define WGL_ALPHA_SHIFT_ARB 0x201C
#define WGL_ACCUM_BITS_ARB 0x201D
#define WGL_ACCUM_RED_BITS_ARB 0x201E
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
#define WGL_DEPTH_BITS_ARB 0x2022
#define WGL_STENCIL_BITS_ARB 0x2023
#define WGL_AUX_BUFFERS_ARB 0x2024
#define WGL_NO_ACCELERATION_ARB 0x2025
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
#define WGL_FULL_ACCELERATION_ARB 0x2027
#define WGL_SWAP_EXCHANGE_ARB 0x2028
#define WGL_SWAP_COPY_ARB 0x2029
#define WGL_SWAP_UNDEFINED_ARB 0x202A
#define WGL_TYPE_RGBA_ARB 0x202B
#define WGL_TYPE_COLORINDEX_ARB 0x202C
#endif
#ifndef WGL_ARB_make_current_read
#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
#endif
#ifndef WGL_ARB_pbuffer
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
#define WGL_PBUFFER_LARGEST_ARB 0x2033
#define WGL_PBUFFER_WIDTH_ARB 0x2034
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
#define WGL_PBUFFER_LOST_ARB 0x2036
#endif
#ifndef WGL_ARB_render_texture
#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
#define WGL_TEXTURE_FORMAT_ARB 0x2072
#define WGL_TEXTURE_TARGET_ARB 0x2073
#define WGL_MIPMAP_TEXTURE_ARB 0x2074
#define WGL_TEXTURE_RGB_ARB 0x2075
#define WGL_TEXTURE_RGBA_ARB 0x2076
#define WGL_NO_TEXTURE_ARB 0x2077
#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
#define WGL_TEXTURE_1D_ARB 0x2079
#define WGL_TEXTURE_2D_ARB 0x207A
#define WGL_MIPMAP_LEVEL_ARB 0x207B
#define WGL_CUBE_MAP_FACE_ARB 0x207C
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
#define WGL_FRONT_LEFT_ARB 0x2083
#define WGL_FRONT_RIGHT_ARB 0x2084
#define WGL_BACK_LEFT_ARB 0x2085
#define WGL_BACK_RIGHT_ARB 0x2086
#define WGL_AUX0_ARB 0x2087
#define WGL_AUX1_ARB 0x2088
#define WGL_AUX2_ARB 0x2089
#define WGL_AUX3_ARB 0x208A
#define WGL_AUX4_ARB 0x208B
#define WGL_AUX5_ARB 0x208C
#define WGL_AUX6_ARB 0x208D
#define WGL_AUX7_ARB 0x208E
#define WGL_AUX8_ARB 0x208F
#define WGL_AUX9_ARB 0x2090
#endif
#ifndef WGL_ARB_pixel_format_float
#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0
#endif
#ifndef WGL_ARB_framebuffer_sRGB
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
#endif
#ifndef WGL_ARB_create_context
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define ERROR_INVALID_VERSION_ARB 0x2095
#endif
#ifndef WGL_ARB_create_context_profile
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#define ERROR_INVALID_PROFILE_ARB 0x2096
#endif
#ifndef WGL_ARB_create_context_robustness
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
#endif
#ifndef WGL_EXT_make_current_read
#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
#endif
#ifndef WGL_EXT_pixel_format
#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
#define WGL_DRAW_TO_WINDOW_EXT 0x2001
#define WGL_DRAW_TO_BITMAP_EXT 0x2002
#define WGL_ACCELERATION_EXT 0x2003
#define WGL_NEED_PALETTE_EXT 0x2004
#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
#define WGL_SWAP_METHOD_EXT 0x2007
#define WGL_NUMBER_OVERLAYS_EXT 0x2008
#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
#define WGL_TRANSPARENT_EXT 0x200A
#define WGL_TRANSPARENT_VALUE_EXT 0x200B
#define WGL_SHARE_DEPTH_EXT 0x200C
#define WGL_SHARE_STENCIL_EXT 0x200D
#define WGL_SHARE_ACCUM_EXT 0x200E
#define WGL_SUPPORT_GDI_EXT 0x200F
#define WGL_SUPPORT_OPENGL_EXT 0x2010
#define WGL_DOUBLE_BUFFER_EXT 0x2011
#define WGL_STEREO_EXT 0x2012
#define WGL_PIXEL_TYPE_EXT 0x2013
#define WGL_COLOR_BITS_EXT 0x2014
#define WGL_RED_BITS_EXT 0x2015
#define WGL_RED_SHIFT_EXT 0x2016
#define WGL_GREEN_BITS_EXT 0x2017
#define WGL_GREEN_SHIFT_EXT 0x2018
#define WGL_BLUE_BITS_EXT 0x2019
#define WGL_BLUE_SHIFT_EXT 0x201A
#define WGL_ALPHA_BITS_EXT 0x201B
#define WGL_ALPHA_SHIFT_EXT 0x201C
#define WGL_ACCUM_BITS_EXT 0x201D
#define WGL_ACCUM_RED_BITS_EXT 0x201E
#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
#define WGL_DEPTH_BITS_EXT 0x2022
#define WGL_STENCIL_BITS_EXT 0x2023
#define WGL_AUX_BUFFERS_EXT 0x2024
#define WGL_NO_ACCELERATION_EXT 0x2025
#define WGL_GENERIC_ACCELERATION_EXT 0x2026
#define WGL_FULL_ACCELERATION_EXT 0x2027
#define WGL_SWAP_EXCHANGE_EXT 0x2028
#define WGL_SWAP_COPY_EXT 0x2029
#define WGL_SWAP_UNDEFINED_EXT 0x202A
#define WGL_TYPE_RGBA_EXT 0x202B
#define WGL_TYPE_COLORINDEX_EXT 0x202C
#endif
#ifndef WGL_EXT_pbuffer
#define WGL_DRAW_TO_PBUFFER_EXT 0x202D
#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E
#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030
#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031
#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
#define WGL_PBUFFER_LARGEST_EXT 0x2033
#define WGL_PBUFFER_WIDTH_EXT 0x2034
#define WGL_PBUFFER_HEIGHT_EXT 0x2035
#endif
#ifndef WGL_EXT_depth_float
#define WGL_DEPTH_FLOAT_EXT 0x2040
#endif
#ifndef WGL_3DFX_multisample
#define WGL_SAMPLE_BUFFERS_3DFX 0x2060
#define WGL_SAMPLES_3DFX 0x2061
#endif
#ifndef WGL_EXT_multisample
#define WGL_SAMPLE_BUFFERS_EXT 0x2041
#define WGL_SAMPLES_EXT 0x2042
#endif
#ifndef WGL_I3D_digital_video_control
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
#endif
#ifndef WGL_I3D_gamma
#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E
#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F
#endif
#ifndef WGL_I3D_genlock
#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045
#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046
#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047
#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
#endif
#ifndef WGL_I3D_image_buffer
#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002
#endif
#ifndef WGL_I3D_swap_frame_lock
#endif
#ifndef WGL_NV_render_depth_texture
#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
#define WGL_DEPTH_COMPONENT_NV 0x20A7
#endif
#ifndef WGL_NV_render_texture_rectangle
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
#define WGL_TEXTURE_RECTANGLE_NV 0x20A2
#endif
#ifndef WGL_ATI_pixel_format_float
#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
#endif
#ifndef WGL_NV_float_buffer
#define WGL_FLOAT_COMPONENTS_NV 0x20B0
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
#define WGL_TEXTURE_FLOAT_R_NV 0x20B5
#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6
#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7
#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8
#endif
#ifndef WGL_3DL_stereo_control
#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055
#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
#endif
#ifndef WGL_EXT_pixel_format_packed_float
#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
#endif
#ifndef WGL_EXT_framebuffer_sRGB
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
#endif
#ifndef WGL_NV_present_video
#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0
#endif
#ifndef WGL_NV_video_out
#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0
#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1
#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2
#define WGL_VIDEO_OUT_COLOR_NV 0x20C3
#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4
#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5
#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
#define WGL_VIDEO_OUT_FRAME 0x20C8
#define WGL_VIDEO_OUT_FIELD_1 0x20C9
#define WGL_VIDEO_OUT_FIELD_2 0x20CA
#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB
#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC
#endif
#ifndef WGL_NV_swap_group
#endif
#ifndef WGL_NV_gpu_affinity
#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
#endif
#ifndef WGL_AMD_gpu_association
#define WGL_GPU_VENDOR_AMD 0x1F00
#define WGL_GPU_RENDERER_STRING_AMD 0x1F01
#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
#define WGL_GPU_RAM_AMD 0x21A3
#define WGL_GPU_CLOCK_AMD 0x21A4
#define WGL_GPU_NUM_PIPES_AMD 0x21A5
#define WGL_GPU_NUM_SIMD_AMD 0x21A6
#define WGL_GPU_NUM_RB_AMD 0x21A7
#define WGL_GPU_NUM_SPI_AMD 0x21A8
#endif
#ifndef WGL_NV_video_capture
#define WGL_UNIQUE_ID_NV 0x20CE
#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
#endif
#ifndef WGL_NV_copy_image
#endif
#ifndef WGL_NV_multisample_coverage
#define WGL_COVERAGE_SAMPLES_NV 0x2042
#define WGL_COLOR_SAMPLES_NV 0x20B9
#endif
#ifndef WGL_EXT_create_context_es2_profile
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
#endif
#ifndef WGL_NV_DX_interop
#define WGL_ACCESS_READ_ONLY_NV 0x00000000
#define WGL_ACCESS_READ_WRITE_NV 0x00000001
#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002
#endif
#ifndef WGL_NV_DX_interop2
#endif
#ifndef WGL_EXT_swap_control_tear
#endif
/*************************************************************/
#ifndef WGL_ARB_pbuffer
DECLARE_HANDLE(HPBUFFERARB);
#endif
#ifndef WGL_EXT_pbuffer
DECLARE_HANDLE(HPBUFFEREXT);
#endif
#ifndef WGL_NV_present_video
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
#endif
#ifndef WGL_NV_video_output
DECLARE_HANDLE(HPVIDEODEV);
#endif
#ifndef WGL_NV_gpu_affinity
DECLARE_HANDLE(HPGPUNV);
DECLARE_HANDLE(HGPUNV);
typedef struct _GPU_DEVICE {
DWORD cb;
CHAR DeviceName[32];
CHAR DeviceString[128];
DWORD Flags;
RECT rcVirtualScreen;
} GPU_DEVICE, *PGPU_DEVICE;
#endif
#ifndef WGL_NV_video_capture
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
#endif
#ifndef WGL_ARB_buffer_region
#define WGL_ARB_buffer_region 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType);
extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion);
extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height);
extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
#endif
#ifndef WGL_ARB_multisample
#define WGL_ARB_multisample 1
#endif
#ifndef WGL_ARB_extensions_string
#define WGL_ARB_extensions_string 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern const char * WINAPI wglGetExtensionsStringARB (HDC hdc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
#endif
#ifndef WGL_ARB_pixel_format
#define WGL_ARB_pixel_format 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
extern BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif
#ifndef WGL_ARB_make_current_read
#define WGL_ARB_make_current_read 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
extern HDC WINAPI wglGetCurrentReadDCARB (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
#endif
#ifndef WGL_ARB_pbuffer
#define WGL_ARB_pbuffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer);
extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC);
extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer);
extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
#endif
#ifndef WGL_ARB_render_texture
#define WGL_ARB_render_texture 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
#endif
#ifndef WGL_ARB_pixel_format_float
#define WGL_ARB_pixel_format_float 1
#endif
#ifndef WGL_ARB_framebuffer_sRGB
#define WGL_ARB_framebuffer_sRGB 1
#endif
#ifndef WGL_ARB_create_context
#define WGL_ARB_create_context 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
#endif
#ifndef WGL_ARB_create_context_profile
#define WGL_ARB_create_context_profile 1
#endif
#ifndef WGL_ARB_create_context_robustness
#define WGL_ARB_create_context_robustness 1
#endif
#ifndef WGL_EXT_display_color_table
#define WGL_EXT_display_color_table 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id);
extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length);
extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id);
extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
#endif
#ifndef WGL_EXT_extensions_string
#define WGL_EXT_extensions_string 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern const char * WINAPI wglGetExtensionsStringEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
#endif
#ifndef WGL_EXT_make_current_read
#define WGL_EXT_make_current_read 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
extern HDC WINAPI wglGetCurrentReadDCEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
#endif
#ifndef WGL_EXT_pbuffer
#define WGL_EXT_pbuffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer);
extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC);
extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer);
extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
#endif
#ifndef WGL_EXT_pixel_format
#define WGL_EXT_pixel_format 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
extern BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif
#ifndef WGL_EXT_swap_control
#define WGL_EXT_swap_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglSwapIntervalEXT (int interval);
extern int WINAPI wglGetSwapIntervalEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
#endif
#ifndef WGL_EXT_depth_float
#define WGL_EXT_depth_float 1
#endif
#ifndef WGL_NV_vertex_array_range
#define WGL_NV_vertex_array_range 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern void* WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
extern void WINAPI wglFreeMemoryNV (void *pointer);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
#endif
#ifndef WGL_3DFX_multisample
#define WGL_3DFX_multisample 1
#endif
#ifndef WGL_EXT_multisample
#define WGL_EXT_multisample 1
#endif
#ifndef WGL_OML_sync_control
#define WGL_OML_sync_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
extern BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator);
extern INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
extern BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
extern BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
#endif
#ifndef WGL_I3D_digital_video_control
#define WGL_I3D_digital_video_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue);
extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
#endif
#ifndef WGL_I3D_gamma
#define WGL_I3D_gamma 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue);
extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue);
extern BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
extern BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
#endif
#ifndef WGL_I3D_genlock
#define WGL_I3D_genlock 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnableGenlockI3D (HDC hDC);
extern BOOL WINAPI wglDisableGenlockI3D (HDC hDC);
extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag);
extern BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource);
extern BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource);
extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge);
extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge);
extern BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate);
extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate);
extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay);
extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay);
extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
#endif
#ifndef WGL_I3D_image_buffer
#define WGL_I3D_image_buffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags);
extern BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress);
extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
#endif
#ifndef WGL_I3D_swap_frame_lock
#define WGL_I3D_swap_frame_lock 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnableFrameLockI3D (void);
extern BOOL WINAPI wglDisableFrameLockI3D (void);
extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag);
extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
#endif
#ifndef WGL_I3D_swap_frame_usage
#define WGL_I3D_swap_frame_usage 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetFrameUsageI3D (float *pUsage);
extern BOOL WINAPI wglBeginFrameTrackingI3D (void);
extern BOOL WINAPI wglEndFrameTrackingI3D (void);
extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
#endif
#ifndef WGL_ATI_pixel_format_float
#define WGL_ATI_pixel_format_float 1
#endif
#ifndef WGL_NV_float_buffer
#define WGL_NV_float_buffer 1
#endif
#ifndef WGL_3DL_stereo_control
#define WGL_3DL_stereo_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);
#endif
#ifndef WGL_EXT_pixel_format_packed_float
#define WGL_EXT_pixel_format_packed_float 1
#endif
#ifndef WGL_EXT_framebuffer_sRGB
#define WGL_EXT_framebuffer_sRGB 1
#endif
#ifndef WGL_NV_present_video
#define WGL_NV_present_video 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
extern BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
extern BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
#endif
#ifndef WGL_NV_video_output
#define WGL_NV_video_output 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice);
extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer);
extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);
typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);
typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif
#ifndef WGL_NV_swap_group
#define WGL_NV_swap_group 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group);
extern BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier);
extern BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier);
extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
extern BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count);
extern BOOL WINAPI wglResetFrameCountNV (HDC hDC);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);
typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);
typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);
typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
#endif
#ifndef WGL_NV_gpu_affinity
#define WGL_NV_gpu_affinity 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu);
extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList);
extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
extern BOOL WINAPI wglDeleteDCNV (HDC hdc);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);
typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);
typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);
#endif
#ifndef WGL_AMD_gpu_association
#define WGL_AMD_gpu_association 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids);
extern INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data);
extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc);
extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id);
extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList);
extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc);
extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc);
extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void);
extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);
typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data);
typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);
typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);
typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);
typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
#ifndef WGL_NV_video_capture
#define WGL_NV_video_capture 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
#endif
#ifndef WGL_NV_copy_image
#define WGL_NV_copy_image 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif
#ifndef WGL_NV_multisample_coverage
#define WGL_NV_multisample_coverage 1
#endif
#ifndef WGL_NV_DX_interop
#define WGL_NV_DX_interop 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle);
extern HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice);
extern BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice);
extern HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
extern BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject);
extern BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access);
extern BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
extern BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);
typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);
typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);
typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);
typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);
typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
#endif
#ifndef WGL_NV_DX_interop2
#define WGL_NV_DX_interop2 1
#endif
#ifndef WGL_EXT_swap_control_tear
#define WGL_EXT_swap_control_tear 1
#endif
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,15 @@
/*
* Skeleton egl.h to provide compatibility for early GLES 1.0
* applications. Several early implementations included gl.h
* in egl.h leading applications to include only egl.h
*
* $Revision: 6252 $ on $Date:: 2008-08-06 16:35:08 -0700 #$
*/
#ifndef __legacy_egl_h_
#define __legacy_egl_h_
#include <EGL/egl.h>
#include <GLES/gl.h>
#endif /* __legacy_egl_h_ */

@ -0,0 +1,770 @@
#ifndef __gl_h_
#define __gl_h_
/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */
#include <GLES/glplatform.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
typedef void GLvoid;
typedef char GLchar;
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef khronos_int8_t GLbyte;
typedef short GLshort;
typedef int GLint;
typedef int GLsizei;
typedef khronos_uint8_t GLubyte;
typedef unsigned short GLushort;
typedef unsigned int GLuint;
typedef khronos_float_t GLfloat;
typedef khronos_float_t GLclampf;
typedef khronos_int32_t GLfixed;
typedef khronos_int32_t GLclampx;
typedef khronos_intptr_t GLintptr;
typedef khronos_ssize_t GLsizeiptr;
/*************************************************************/
/* OpenGL ES core versions */
#define GL_VERSION_ES_CM_1_0 1
#define GL_VERSION_ES_CL_1_0 1
#define GL_VERSION_ES_CM_1_1 1
#define GL_VERSION_ES_CL_1_1 1
/* ClearBufferMask */
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_COLOR_BUFFER_BIT 0x00004000
/* Boolean */
#define GL_FALSE 0
#define GL_TRUE 1
/* BeginMode */
#define GL_POINTS 0x0000
#define GL_LINES 0x0001
#define GL_LINE_LOOP 0x0002
#define GL_LINE_STRIP 0x0003
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_STRIP 0x0005
#define GL_TRIANGLE_FAN 0x0006
/* AlphaFunction */
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
#define GL_EQUAL 0x0202
#define GL_LEQUAL 0x0203
#define GL_GREATER 0x0204
#define GL_NOTEQUAL 0x0205
#define GL_GEQUAL 0x0206
#define GL_ALWAYS 0x0207
/* BlendingFactorDest */
#define GL_ZERO 0
#define GL_ONE 1
#define GL_SRC_COLOR 0x0300
#define GL_ONE_MINUS_SRC_COLOR 0x0301
#define GL_SRC_ALPHA 0x0302
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
#define GL_DST_ALPHA 0x0304
#define GL_ONE_MINUS_DST_ALPHA 0x0305
/* BlendingFactorSrc */
/* GL_ZERO */
/* GL_ONE */
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA_SATURATE 0x0308
/* GL_SRC_ALPHA */
/* GL_ONE_MINUS_SRC_ALPHA */
/* GL_DST_ALPHA */
/* GL_ONE_MINUS_DST_ALPHA */
/* ClipPlaneName */
#define GL_CLIP_PLANE0 0x3000
#define GL_CLIP_PLANE1 0x3001
#define GL_CLIP_PLANE2 0x3002
#define GL_CLIP_PLANE3 0x3003
#define GL_CLIP_PLANE4 0x3004
#define GL_CLIP_PLANE5 0x3005
/* ColorMaterialFace */
/* GL_FRONT_AND_BACK */
/* ColorMaterialParameter */
/* GL_AMBIENT_AND_DIFFUSE */
/* ColorPointerType */
/* GL_UNSIGNED_BYTE */
/* GL_FLOAT */
/* GL_FIXED */
/* CullFaceMode */
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_FRONT_AND_BACK 0x0408
/* DepthFunction */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* EnableCap */
#define GL_FOG 0x0B60
#define GL_LIGHTING 0x0B50
#define GL_TEXTURE_2D 0x0DE1
#define GL_CULL_FACE 0x0B44
#define GL_ALPHA_TEST 0x0BC0
#define GL_BLEND 0x0BE2
#define GL_COLOR_LOGIC_OP 0x0BF2
#define GL_DITHER 0x0BD0
#define GL_STENCIL_TEST 0x0B90
#define GL_DEPTH_TEST 0x0B71
/* GL_LIGHT0 */
/* GL_LIGHT1 */
/* GL_LIGHT2 */
/* GL_LIGHT3 */
/* GL_LIGHT4 */
/* GL_LIGHT5 */
/* GL_LIGHT6 */
/* GL_LIGHT7 */
#define GL_POINT_SMOOTH 0x0B10
#define GL_LINE_SMOOTH 0x0B20
#define GL_SCISSOR_TEST 0x0C11
#define GL_COLOR_MATERIAL 0x0B57
#define GL_NORMALIZE 0x0BA1
#define GL_RESCALE_NORMAL 0x803A
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_VERTEX_ARRAY 0x8074
#define GL_NORMAL_ARRAY 0x8075
#define GL_COLOR_ARRAY 0x8076
#define GL_TEXTURE_COORD_ARRAY 0x8078
#define GL_MULTISAMPLE 0x809D
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
#define GL_SAMPLE_COVERAGE 0x80A0
/* ErrorCode */
#define GL_NO_ERROR 0
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_OPERATION 0x0502
#define GL_STACK_OVERFLOW 0x0503
#define GL_STACK_UNDERFLOW 0x0504
#define GL_OUT_OF_MEMORY 0x0505
/* FogMode */
/* GL_LINEAR */
#define GL_EXP 0x0800
#define GL_EXP2 0x0801
/* FogParameter */
#define GL_FOG_DENSITY 0x0B62
#define GL_FOG_START 0x0B63
#define GL_FOG_END 0x0B64
#define GL_FOG_MODE 0x0B65
#define GL_FOG_COLOR 0x0B66
/* FrontFaceDirection */
#define GL_CW 0x0900
#define GL_CCW 0x0901
/* GetPName */
#define GL_CURRENT_COLOR 0x0B00
#define GL_CURRENT_NORMAL 0x0B02
#define GL_CURRENT_TEXTURE_COORDS 0x0B03
#define GL_POINT_SIZE 0x0B11
#define GL_POINT_SIZE_MIN 0x8126
#define GL_POINT_SIZE_MAX 0x8127
#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
#define GL_POINT_DISTANCE_ATTENUATION 0x8129
#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
#define GL_LINE_WIDTH 0x0B21
#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_SHADE_MODEL 0x0B54
#define GL_DEPTH_RANGE 0x0B70
#define GL_DEPTH_WRITEMASK 0x0B72
#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_DEPTH_FUNC 0x0B74
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_FUNC 0x0B92
#define GL_STENCIL_VALUE_MASK 0x0B93
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_REF 0x0B97
#define GL_STENCIL_WRITEMASK 0x0B98
#define GL_MATRIX_MODE 0x0BA0
#define GL_VIEWPORT 0x0BA2
#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
#define GL_PROJECTION_STACK_DEPTH 0x0BA4
#define GL_TEXTURE_STACK_DEPTH 0x0BA5
#define GL_MODELVIEW_MATRIX 0x0BA6
#define GL_PROJECTION_MATRIX 0x0BA7
#define GL_TEXTURE_MATRIX 0x0BA8
#define GL_ALPHA_TEST_FUNC 0x0BC1
#define GL_ALPHA_TEST_REF 0x0BC2
#define GL_BLEND_DST 0x0BE0
#define GL_BLEND_SRC 0x0BE1
#define GL_LOGIC_OP_MODE 0x0BF0
#define GL_SCISSOR_BOX 0x0C10
#define GL_SCISSOR_TEST 0x0C11
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_MAX_LIGHTS 0x0D31
#define GL_MAX_CLIP_PLANES 0x0D32
#define GL_MAX_TEXTURE_SIZE 0x0D33
#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
#define GL_MAX_VIEWPORT_DIMS 0x0D3A
#define GL_MAX_TEXTURE_UNITS 0x84E2
#define GL_SUBPIXEL_BITS 0x0D50
#define GL_RED_BITS 0x0D52
#define GL_GREEN_BITS 0x0D53
#define GL_BLUE_BITS 0x0D54
#define GL_ALPHA_BITS 0x0D55
#define GL_DEPTH_BITS 0x0D56
#define GL_STENCIL_BITS 0x0D57
#define GL_POLYGON_OFFSET_UNITS 0x2A00
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_VERTEX_ARRAY_SIZE 0x807A
#define GL_VERTEX_ARRAY_TYPE 0x807B
#define GL_VERTEX_ARRAY_STRIDE 0x807C
#define GL_NORMAL_ARRAY_TYPE 0x807E
#define GL_NORMAL_ARRAY_STRIDE 0x807F
#define GL_COLOR_ARRAY_SIZE 0x8081
#define GL_COLOR_ARRAY_TYPE 0x8082
#define GL_COLOR_ARRAY_STRIDE 0x8083
#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
#define GL_VERTEX_ARRAY_POINTER 0x808E
#define GL_NORMAL_ARRAY_POINTER 0x808F
#define GL_COLOR_ARRAY_POINTER 0x8090
#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
/* GL_TEXTURE_MIN_FILTER */
/* GL_TEXTURE_WRAP_S */
/* GL_TEXTURE_WRAP_T */
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
/* HintMode */
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
/* HintTarget */
#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
#define GL_POINT_SMOOTH_HINT 0x0C51
#define GL_LINE_SMOOTH_HINT 0x0C52
#define GL_FOG_HINT 0x0C54
#define GL_GENERATE_MIPMAP_HINT 0x8192
/* LightModelParameter */
#define GL_LIGHT_MODEL_AMBIENT 0x0B53
#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
/* LightParameter */
#define GL_AMBIENT 0x1200
#define GL_DIFFUSE 0x1201
#define GL_SPECULAR 0x1202
#define GL_POSITION 0x1203
#define GL_SPOT_DIRECTION 0x1204
#define GL_SPOT_EXPONENT 0x1205
#define GL_SPOT_CUTOFF 0x1206
#define GL_CONSTANT_ATTENUATION 0x1207
#define GL_LINEAR_ATTENUATION 0x1208
#define GL_QUADRATIC_ATTENUATION 0x1209
/* DataType */
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
#define GL_UNSIGNED_SHORT 0x1403
#define GL_FLOAT 0x1406
#define GL_FIXED 0x140C
/* LogicOp */
#define GL_CLEAR 0x1500
#define GL_AND 0x1501
#define GL_AND_REVERSE 0x1502
#define GL_COPY 0x1503
#define GL_AND_INVERTED 0x1504
#define GL_NOOP 0x1505
#define GL_XOR 0x1506
#define GL_OR 0x1507
#define GL_NOR 0x1508
#define GL_EQUIV 0x1509
#define GL_INVERT 0x150A
#define GL_OR_REVERSE 0x150B
#define GL_COPY_INVERTED 0x150C
#define GL_OR_INVERTED 0x150D
#define GL_NAND 0x150E
#define GL_SET 0x150F
/* MaterialFace */
/* GL_FRONT_AND_BACK */
/* MaterialParameter */
#define GL_EMISSION 0x1600
#define GL_SHININESS 0x1601
#define GL_AMBIENT_AND_DIFFUSE 0x1602
/* GL_AMBIENT */
/* GL_DIFFUSE */
/* GL_SPECULAR */
/* MatrixMode */
#define GL_MODELVIEW 0x1700
#define GL_PROJECTION 0x1701
#define GL_TEXTURE 0x1702
/* NormalPointerType */
/* GL_BYTE */
/* GL_SHORT */
/* GL_FLOAT */
/* GL_FIXED */
/* PixelFormat */
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
/* PixelStoreParameter */
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_ALIGNMENT 0x0D05
/* PixelType */
/* GL_UNSIGNED_BYTE */
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
/* ShadingModel */
#define GL_FLAT 0x1D00
#define GL_SMOOTH 0x1D01
/* StencilFunction */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* StencilOp */
/* GL_ZERO */
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
#define GL_DECR 0x1E03
/* GL_INVERT */
/* StringName */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
/* TexCoordPointerType */
/* GL_SHORT */
/* GL_FLOAT */
/* GL_FIXED */
/* GL_BYTE */
/* TextureEnvMode */
#define GL_MODULATE 0x2100
#define GL_DECAL 0x2101
/* GL_BLEND */
#define GL_ADD 0x0104
/* GL_REPLACE */
/* TextureEnvParameter */
#define GL_TEXTURE_ENV_MODE 0x2200
#define GL_TEXTURE_ENV_COLOR 0x2201
/* TextureEnvTarget */
#define GL_TEXTURE_ENV 0x2300
/* TextureMagFilter */
#define GL_NEAREST 0x2600
#define GL_LINEAR 0x2601
/* TextureMinFilter */
/* GL_NEAREST */
/* GL_LINEAR */
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
/* TextureParameterName */
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
#define GL_GENERATE_MIPMAP 0x8191
/* TextureTarget */
/* GL_TEXTURE_2D */
/* TextureUnit */
#define GL_TEXTURE0 0x84C0
#define GL_TEXTURE1 0x84C1
#define GL_TEXTURE2 0x84C2
#define GL_TEXTURE3 0x84C3
#define GL_TEXTURE4 0x84C4
#define GL_TEXTURE5 0x84C5
#define GL_TEXTURE6 0x84C6
#define GL_TEXTURE7 0x84C7
#define GL_TEXTURE8 0x84C8
#define GL_TEXTURE9 0x84C9
#define GL_TEXTURE10 0x84CA
#define GL_TEXTURE11 0x84CB
#define GL_TEXTURE12 0x84CC
#define GL_TEXTURE13 0x84CD
#define GL_TEXTURE14 0x84CE
#define GL_TEXTURE15 0x84CF
#define GL_TEXTURE16 0x84D0
#define GL_TEXTURE17 0x84D1
#define GL_TEXTURE18 0x84D2
#define GL_TEXTURE19 0x84D3
#define GL_TEXTURE20 0x84D4
#define GL_TEXTURE21 0x84D5
#define GL_TEXTURE22 0x84D6
#define GL_TEXTURE23 0x84D7
#define GL_TEXTURE24 0x84D8
#define GL_TEXTURE25 0x84D9
#define GL_TEXTURE26 0x84DA
#define GL_TEXTURE27 0x84DB
#define GL_TEXTURE28 0x84DC
#define GL_TEXTURE29 0x84DD
#define GL_TEXTURE30 0x84DE
#define GL_TEXTURE31 0x84DF
#define GL_ACTIVE_TEXTURE 0x84E0
#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
/* TextureWrapMode */
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
/* VertexPointerType */
/* GL_SHORT */
/* GL_FLOAT */
/* GL_FIXED */
/* GL_BYTE */
/* LightName */
#define GL_LIGHT0 0x4000
#define GL_LIGHT1 0x4001
#define GL_LIGHT2 0x4002
#define GL_LIGHT3 0x4003
#define GL_LIGHT4 0x4004
#define GL_LIGHT5 0x4005
#define GL_LIGHT6 0x4006
#define GL_LIGHT7 0x4007
/* Buffer Objects */
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
/* Texture combine + dot3 */
#define GL_SUBTRACT 0x84E7
#define GL_COMBINE 0x8570
#define GL_COMBINE_RGB 0x8571
#define GL_COMBINE_ALPHA 0x8572
#define GL_RGB_SCALE 0x8573
#define GL_ADD_SIGNED 0x8574
#define GL_INTERPOLATE 0x8575
#define GL_CONSTANT 0x8576
#define GL_PRIMARY_COLOR 0x8577
#define GL_PREVIOUS 0x8578
#define GL_OPERAND0_RGB 0x8590
#define GL_OPERAND1_RGB 0x8591
#define GL_OPERAND2_RGB 0x8592
#define GL_OPERAND0_ALPHA 0x8598
#define GL_OPERAND1_ALPHA 0x8599
#define GL_OPERAND2_ALPHA 0x859A
#define GL_ALPHA_SCALE 0x0D1C
#define GL_SRC0_RGB 0x8580
#define GL_SRC1_RGB 0x8581
#define GL_SRC2_RGB 0x8582
#define GL_SRC0_ALPHA 0x8588
#define GL_SRC1_ALPHA 0x8589
#define GL_SRC2_ALPHA 0x858A
#define GL_DOT3_RGB 0x86AE
#define GL_DOT3_RGBA 0x86AF
/*------------------------------------------------------------------------*
* required OES extension tokens
*------------------------------------------------------------------------*/
/* OES_read_format */
#ifndef GL_OES_read_format
#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
#endif
/* GL_OES_compressed_paletted_texture */
#ifndef GL_OES_compressed_paletted_texture
#define GL_PALETTE4_RGB8_OES 0x8B90
#define GL_PALETTE4_RGBA8_OES 0x8B91
#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
#define GL_PALETTE4_RGBA4_OES 0x8B93
#define GL_PALETTE4_RGB5_A1_OES 0x8B94
#define GL_PALETTE8_RGB8_OES 0x8B95
#define GL_PALETTE8_RGBA8_OES 0x8B96
#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
#define GL_PALETTE8_RGBA4_OES 0x8B98
#define GL_PALETTE8_RGB5_A1_OES 0x8B99
#endif
/* OES_point_size_array */
#ifndef GL_OES_point_size_array
#define GL_POINT_SIZE_ARRAY_OES 0x8B9C
#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A
#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B
#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C
#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F
#endif
/* GL_OES_point_sprite */
#ifndef GL_OES_point_sprite
#define GL_POINT_SPRITE_OES 0x8861
#define GL_COORD_REPLACE_OES 0x8862
#endif
/*************************************************************/
/* Available only in Common profile */
GL_API void GL_APIENTRY glAlphaFunc (GLenum func, GLclampf ref);
GL_API void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
GL_API void GL_APIENTRY glClearDepthf (GLclampf depth);
GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation);
GL_API void GL_APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
GL_API void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
GL_API void GL_APIENTRY glFogf (GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glFogfv (GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat eqn[4]);
GL_API void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetTexEnvfv (GLenum env, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glLightModelf (GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glLightModelfv (GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glLightf (GLenum light, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glLineWidth (GLfloat width);
GL_API void GL_APIENTRY glLoadMatrixf (const GLfloat *m);
GL_API void GL_APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glMultMatrixf (const GLfloat *m);
GL_API void GL_APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
GL_API void GL_APIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz);
GL_API void GL_APIENTRY glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glPointParameterf (GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glPointSize (GLfloat size);
GL_API void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
GL_API void GL_APIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
GL_API void GL_APIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z);
GL_API void GL_APIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z);
/* Available in both Common and Common-Lite profiles */
GL_API void GL_APIENTRY glActiveTexture (GLenum texture);
GL_API void GL_APIENTRY glAlphaFuncx (GLenum func, GLclampx ref);
GL_API void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
GL_API void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
GL_API void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
GL_API void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
GL_API void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
GL_API void GL_APIENTRY glClear (GLbitfield mask);
GL_API void GL_APIENTRY glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
GL_API void GL_APIENTRY glClearDepthx (GLclampx depth);
GL_API void GL_APIENTRY glClearStencil (GLint s);
GL_API void GL_APIENTRY glClientActiveTexture (GLenum texture);
GL_API void GL_APIENTRY glClipPlanex (GLenum plane, const GLfixed *equation);
GL_API void GL_APIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
GL_API void GL_APIENTRY glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
GL_API void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
GL_API void GL_APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
GL_API void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
GL_API void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
GL_API void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GL_API void GL_APIENTRY glCullFace (GLenum mode);
GL_API void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
GL_API void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
GL_API void GL_APIENTRY glDepthFunc (GLenum func);
GL_API void GL_APIENTRY glDepthMask (GLboolean flag);
GL_API void GL_APIENTRY glDepthRangex (GLclampx zNear, GLclampx zFar);
GL_API void GL_APIENTRY glDisable (GLenum cap);
GL_API void GL_APIENTRY glDisableClientState (GLenum array);
GL_API void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
GL_API void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
GL_API void GL_APIENTRY glEnable (GLenum cap);
GL_API void GL_APIENTRY glEnableClientState (GLenum array);
GL_API void GL_APIENTRY glFinish (void);
GL_API void GL_APIENTRY glFlush (void);
GL_API void GL_APIENTRY glFogx (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glFogxv (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glFrontFace (GLenum mode);
GL_API void GL_APIENTRY glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
GL_API void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *params);
GL_API void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetClipPlanex (GLenum pname, GLfixed eqn[4]);
GL_API void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
GL_API void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures);
GL_API GLenum GL_APIENTRY glGetError (void);
GL_API void GL_APIENTRY glGetFixedv (GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetLightxv (GLenum light, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetPointerv (GLenum pname, GLvoid **params);
GL_API const GLubyte * GL_APIENTRY glGetString (GLenum name);
GL_API void GL_APIENTRY glGetTexEnviv (GLenum env, GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glHint (GLenum target, GLenum mode);
GL_API GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
GL_API GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
GL_API GLboolean GL_APIENTRY glIsTexture (GLuint texture);
GL_API void GL_APIENTRY glLightModelx (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glLightModelxv (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glLightx (GLenum light, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glLightxv (GLenum light, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glLineWidthx (GLfixed width);
GL_API void GL_APIENTRY glLoadIdentity (void);
GL_API void GL_APIENTRY glLoadMatrixx (const GLfixed *m);
GL_API void GL_APIENTRY glLogicOp (GLenum opcode);
GL_API void GL_APIENTRY glMaterialx (GLenum face, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glMaterialxv (GLenum face, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glMatrixMode (GLenum mode);
GL_API void GL_APIENTRY glMultMatrixx (const GLfixed *m);
GL_API void GL_APIENTRY glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
GL_API void GL_APIENTRY glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz);
GL_API void GL_APIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
GL_API void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
GL_API void GL_APIENTRY glPointParameterx (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glPointParameterxv (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glPointSizex (GLfixed size);
GL_API void GL_APIENTRY glPolygonOffsetx (GLfixed factor, GLfixed units);
GL_API void GL_APIENTRY glPopMatrix (void);
GL_API void GL_APIENTRY glPushMatrix (void);
GL_API void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
GL_API void GL_APIENTRY glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
GL_API void GL_APIENTRY glSampleCoveragex (GLclampx value, GLboolean invert);
GL_API void GL_APIENTRY glScalex (GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
GL_API void GL_APIENTRY glShadeModel (GLenum mode);
GL_API void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
GL_API void GL_APIENTRY glStencilMask (GLuint mask);
GL_API void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
GL_API void GL_APIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param);
GL_API void GL_APIENTRY glTexEnvx (GLenum target, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params);
GL_API void GL_APIENTRY glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
GL_API void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
GL_API void GL_APIENTRY glTexParameterx (GLenum target, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);
GL_API void GL_APIENTRY glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
GL_API void GL_APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
/*------------------------------------------------------------------------*
* Required OES extension functions
*------------------------------------------------------------------------*/
/* GL_OES_read_format */
#ifndef GL_OES_read_format
#define GL_OES_read_format 1
#endif
/* GL_OES_compressed_paletted_texture */
#ifndef GL_OES_compressed_paletted_texture
#define GL_OES_compressed_paletted_texture 1
#endif
/* GL_OES_point_size_array */
#ifndef GL_OES_point_size_array
#define GL_OES_point_size_array 1
GL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer);
#endif
/* GL_OES_point_sprite */
#ifndef GL_OES_point_sprite
#define GL_OES_point_sprite 1
#endif
#ifdef __cplusplus
}
#endif
#endif /* __gl_h_ */

File diff suppressed because it is too large Load Diff

@ -0,0 +1,30 @@
#ifndef __glplatform_h_
#define __glplatform_h_
/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/* Platform-specific types and definitions for OpenGL ES 1.X gl.h
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "OpenGL-ES" component "Registry".
*/
#include <KHR/khrplatform.h>
#ifndef GL_API
#define GL_API KHRONOS_APICALL
#endif
#ifndef GL_APIENTRY
#define GL_APIENTRY KHRONOS_APIENTRY
#endif
#endif /* __glplatform_h_ */

@ -0,0 +1,302 @@
#ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Khronos platform-specific types and definitions.
*
* $Revision: 1.5 $ on $Date: 2010/06/03 16:51:55 $
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
* group so that they can be included in future versions of this file.
* Please submit changes by sending them to the public Khronos Bugzilla
* (http://khronos.org/bugzilla) by filing a bug against product
* "Khronos (general)" component "Registry".
*
* A predefined template which fills in some of the bug fields can be
* reached using http://tinyurl.com/khrplatform-h-bugreport, but you
* must create a Bugzilla login first.
*
*
* See the Implementer's Guidelines for information about where this file
* should be located on your system and for more details of its use:
* http://www.khronos.org/registry/implementers_guide.pdf
*
* This file should be included as
* #include <KHR/khrplatform.h>
* by Khronos client API header files that use its types and defines.
*
* The types in khrplatform.h should only be used to define API-specific types.
*
* Types defined in khrplatform.h:
* khronos_int8_t signed 8 bit
* khronos_uint8_t unsigned 8 bit
* khronos_int16_t signed 16 bit
* khronos_uint16_t unsigned 16 bit
* khronos_int32_t signed 32 bit
* khronos_uint32_t unsigned 32 bit
* khronos_int64_t signed 64 bit
* khronos_uint64_t unsigned 64 bit
* khronos_intptr_t signed same number of bits as a pointer
* khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_ssize_t signed size
* khronos_usize_t unsigned size
* khronos_float_t signed 32 bit floating point
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* nanoseconds
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
* khronos_boolean_enum_t enumerated boolean type. This should
* only be used as a base type when a client API's boolean type is
* an enum. Client APIs which use an integer or other type for
* booleans cannot use this as the base type for their boolean.
*
* Tokens defined in khrplatform.h:
*
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
*
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
*
* Calling convention macros defined in this file:
* KHRONOS_APICALL
* KHRONOS_APIENTRY
* KHRONOS_APIATTRIBUTES
*
* These may be used in function prototypes as:
*
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* int arg1,
* int arg2) KHRONOS_APIATTRIBUTES;
*/
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if (defined(_WIN32) || defined(__VC32__)) && !defined(__SCITECH_SNAP__) && !defined(__WINSCW__)
# if defined (_DLL_EXPORTS)
# define KHRONOS_APICALL __declspec(dllexport)
# else
# define KHRONOS_APICALL __declspec(dllimport)
# endif
#elif defined (__SYMBIAN32__)
# if defined (__GCC32__)
# define KHRONOS_APICALL __declspec(dllexport)
# else
# define KHRONOS_APICALL IMPORT_C
# endif
#else
# define KHRONOS_APICALL
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY
*-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function
* name in the function prototype.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) && !defined(__WINSCW__)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES
*-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments.
*/
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
#if defined(__SYMBIAN32__)
#include <e32def.h>
typedef TInt32 khronos_int32_t;
typedef TUint32 khronos_uint32_t;
typedef TInt64 khronos_int64_t;
typedef TUint64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/*
* Using <stdint.h>
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__VMS ) || defined(__sgi)
/*
* Using <inttypes.h>
*/
#include <inttypes.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/*
* Win32
*/
typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t;
typedef unsigned __int64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__sun__) || defined(__digital__)
/*
* Sun or Digital
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int khronos_int64_t;
typedef unsigned long int khronos_uint64_t;
#else
typedef long long int khronos_int64_t;
typedef unsigned long long int khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_UITRON_)
/*
* uITRON
*/
typedef signed int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
typedef long long khronos_int64_t;
typedef unsigned long long khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif 0
/*
* Hypothetical platform with no float or int64 support
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0
#define KHRONOS_SUPPORT_FLOAT 0
#else
/*
* Generic fallback
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#endif
/*
* Types that are (so far) the same on all platforms
*/
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#if KHRONOS_SUPPORT_FLOAT
/*
* Float type
*/
typedef float khronos_float_t;
#endif
#if KHRONOS_SUPPORT_INT64
/* Time types
*
* These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned.
*/
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif
/*
* Dummy value used to pad enum types to 32 bits.
*/
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif
/*
* Enumerated boolean type
*
* Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE.
*/
typedef enum {
KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;
#endif /* __khrplatform_h_ */

@ -0,0 +1,618 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#if 0
#include "stdopengl.h"
#include "driver_glsl_shader_generator.h"
#include <sstream>
#include "nel/3d/vertex_buffer.h"
#include "driver_opengl_program.h"
#include "driver_opengl_shader_desc.h"
namespace NL3D
{
const char *shaderNames[] =
{
"Normal",
"Bump",
"Usercolor",
"Lightmap",
"Specular",
"Caustics",
"Per-Pixel Lighting",
"Per-Pixel Lighting, no specular",
"Cloud",
"Water"
};
CGLSLShaderGenerator::CGLSLShaderGenerator()
{
reset();
}
CGLSLShaderGenerator::~CGLSLShaderGenerator()
{
}
void CGLSLShaderGenerator::reset()
{
material = NULL;
desc = NULL;
ss.str("");
ss.clear();
}
void CGLSLShaderGenerator::addAmbient()
{
ss << "uniform vec4 ambientColor;" << std::endl;
}
void CGLSLShaderGenerator::addDiffuse()
{
ss << "uniform vec4 diffuseColor;" << std::endl;
}
void CGLSLShaderGenerator::addSpecular()
{
ss << "uniform vec4 specularColor;" << std::endl;
}
void CGLSLShaderGenerator::addColor()
{
ss << "uniform vec4 materialColor;" << std::endl;
}
void CGLSLShaderGenerator::addConstants()
{
ss << "uniform vec4 constant0;" << std::endl;
ss << "uniform vec4 constant1;" << std::endl;
ss << "uniform vec4 constant2;" << std::endl;
ss << "uniform vec4 constant3;" << std::endl;
}
void CGLSLShaderGenerator::addNormalMatrix()
{
ss << "uniform mat3 normalMatrix;" << std::endl;
}
void CGLSLShaderGenerator::addViewMatrix()
{
ss << "uniform mat4 viewMatrix;" << std::endl;
}
void CGLSLShaderGenerator::addAlphaTreshold()
{
ss << "uniform float alphaTreshold;" << std::endl;
}
void CGLSLShaderGenerator::addAlphaTest()
{
if (material->getAlphaTest())
ss << "if (fragColor.a <= (alphaTreshold - 0.0001)) discard;" << std::endl;
}
void CGLSLShaderGenerator::addFogUniform()
{
if (!desc->fogEnabled())
return;
ss << "uniform float fogStart;" << std::endl;
ss << "uniform float fogEnd;" << std::endl;
ss << "uniform vec4 fogColor;" << std::endl;
if (desc->getFogMode() == CShaderDesc::Linear)
return;
ss << "uniform float fogDensity;" << std::endl;
}
void CGLSLShaderGenerator::addFogFunction()
{
if (!desc->fogEnabled())
return;
switch(desc->getFogMode())
{
case CShaderDesc::Linear:
ss << "vec4 applyFog(vec4 col)" << std::endl;
ss << "{" << std::endl;
ss << "float z = ecPos.z / ecPos.w;" << std::endl;
ss << "z = abs(z);" << std::endl;
ss << "float fogFactor = (fogEnd - z) / (fogEnd - fogStart);" << std::endl;
ss << "fogFactor = clamp(fogFactor, 0.0, 1.0);" << std::endl;
ss << "vec4 fColor = mix(fogColor, col, fogFactor);" << std::endl;
ss << "return fColor;" << std::endl;
ss << "}" << std::endl;
ss << std::endl;
break;
}
}
void CGLSLShaderGenerator::addFog()
{
ss << "fragColor = applyFog(fragColor);" << std::endl;
}
/////////////////////////////////////////////////////////// Lights ////////////////////////////////////////////////////////////////////
void CGLSLShaderGenerator::addLightUniformsFS()
{
for (int i = 0; i < NL_OPENGL3_MAX_LIGHT; i++)
{
switch(desc->getLight(i))
{
case CShaderDesc::Nolight:
continue;
break;
case CShaderDesc::Directional:
break;
}
}
}
void CGLSLShaderGenerator::addLightInsFS()
{
ss << "smooth in vec4 lightColor;" << std::endl;
}
void CGLSLShaderGenerator::addLightsFunctionFS()
{
ss << "vec4 applyLights(vec4 col)" << std::endl;
ss << "{" << std::endl;
ss << "return col * lightColor;" << std::endl;
ss << "}" << std::endl;
}
void CGLSLShaderGenerator::addLightsFS()
{
ss << "fragColor = applyLights(fragColor);" << std::endl;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*void CGLSLShaderGenerator::generateSpecularVS()
{
ss << "uniform mat4 modelView;" << std::endl;
ss << "uniform mat4 texMatrix0;" << std::endl;
ss << "smooth out vec3 cubeTexCoords;" << std::endl;
if (desc->fogEnabled() || desc->hasPointLight())
{
ss << "vec4 ecPos4;" << std::endl;
}
if (desc->fogEnabled())
ss << "smooth out vec4 ecPos;" << std::endl;
ss << std::endl;
if (desc->lightingEnabled())
{
addViewMatrix();
addNormalMatrix();
addLightUniformsVS();
addLightOutsVS();
ss << std::endl;
addLightsFunctionVS();
ss << std::endl;
}
ss << "vec3 ReflectionMap(const in vec3 eyePos, const in vec3 normal)" << std::endl;
ss << "{" << std::endl;
ss << "vec3 u = normalize(eyePos);" << std::endl;
ss << "return reflect(u, normal);" << std::endl;
ss << "}" << std::endl;
ss << std::endl;
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
ss << "vec4 eyePosition = modelView * v" << g_AttribNames[ 0 ] << ";" << std::endl;
if (desc->hasPointLight())
ss << "ecPos4 = eyePosition;" << std::endl;
if (desc->fogEnabled())
ss << "ecPos = eyePosition;" << std::endl;
ss << "vec3 ep = eyePosition.xyz / eyePosition.w;" << std::endl;
ss << "vec3 n = vnormal.xyz;" << std::endl;
ss << "cubeTexCoords = ReflectionMap(ep, n);" << std::endl;
ss << "vec4 t = vec4(cubeTexCoords, 1.0);" << std::endl;
ss << "t = t * texMatrix0;" << std::endl;
ss << "cubeTexCoords = t.xyz;" << std::endl;
ss << "gl_Position = modelViewProjection * v" << g_AttribNames[ 0 ] << ";" << std::endl;
if (desc->lightingEnabled())
addLightsVS();
for (int i = Weight; i < NumOffsets; i++)
{
if (hasFlag(vbFormat, g_VertexFlags[i]))
{
ss << g_AttribNames[i];
ss << " = ";
ss << "v" << g_AttribNames[i] << ";" << std::endl;
}
}
ss << "}" << std::endl;
}
void CGLSLShaderGenerator::generatePPLVS()
{
ss << "uniform vec4 lightPosition;" << std::endl;
if (material->getShader() == CMaterial::PerPixelLighting)
{
ss << "uniform vec4 viewerPos;" << std::endl;
ss << "uniform mat4 invModelMat;" << std::endl;
}
ss << std::endl;
ss << "smooth out vec3 cubeTexCoords0;" << std::endl;
if (material->getShader() == CMaterial::PerPixelLighting)
ss << "smooth out vec3 cubeTexCoords2;" << std::endl;
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
ss << "gl_Position = modelViewProjection * v" << g_AttribNames[ 0 ] << ";" << std::endl;
for (int i = Weight; i < NumOffsets; i++)
{
if (hasFlag(vbFormat, g_VertexFlags[i]))
{
ss << g_AttribNames[i];
ss << " = ";
ss << "v" << g_AttribNames[i] << ";" << std::endl;
}
}
ss << "vec4 n = normalize(vnormal); //normalized normal" << std::endl;
ss << "vec4 T; // second basis, Tangent" << std::endl;
ss << "T = texCoord1;" << std::endl;
ss << "T = T - n * dot(N, T); // Gramm-Schmidt process" << std::endl;
ss << "T = normalize(T);" << std::endl;
ss << "vec4 B;" << std::endl;
ss << "B.xyz = cross(n.xyz, T.xyz); // B = N x T" << std::endl;
ss << "vec4 L = lightPos - vposition; //Inverse light vector" << std::endl;
ss << "L = normalize(L);" << std::endl;
ss << "L * [ T B N ]" << std::endl;
ss << "cubeTexCoords0.x = dot(T.xyz, L.xyz);" << std::endl;
ss << "cubeTexCoords0.y = dot(B.xyz, L.xyz);" << std::endl;
ss << "cubeTexCoords0.z = dot(n.xyz, L.xyz);" << std::endl;
if (material->getShader() == CMaterial::PerPixelLighting)
{
ss << "vec4 V = invModelMat * viewerPos - vposition;" << std::endl;
ss << "V = normalize(V);" << std::endl;
ss << "vec4 H = L + V; // half-angle" << std::endl;
ss << "vec4 H = normalize(H);" << std::endl;
ss << "cubeTexCoords2.x = dot(T, H);" << std::endl;
ss << "cubeTexCoords2.y = dot(B, H);" << std::endl;
ss << "cubeTexCoords2.w = dot(n, H);" << std::endl;
}
ss << "}" << std::endl;
}
void CGLSLShaderGenerator::generateWaterVS()
{
bool diffuse = false;
if (material->getTexture(3))
diffuse = true;
ss << "smooth out vec4 texCoord0;" << std::endl;
ss << "smooth out vec4 texCoord1;" << std::endl;
ss << "smooth out vec4 texCoord2;" << std::endl;
ss << "flat out vec4 bump0ScaleBias;" << std::endl;
ss << "flat out vec4 bump1ScaleBias;" << std::endl;
if (diffuse)
ss << "smooth out vec4 texCoord3;" << std::endl;
ss << std::endl;
if (diffuse)
{
ss << "uniform vec4 diffuseMapVector0;" << std::endl;
ss << "uniform vec4 diffuseMapVector1;" << std::endl;
}
ss << "uniform vec4 bumpMap0Scale;" << std::endl;
ss << "uniform vec4 bumpMap1Scale;" << std::endl;
ss << "uniform vec4 bumpMap0Offset;" << std::endl;
ss << "uniform vec4 bumpMap1Offset;" << std::endl;
// no fog yet
//ss << "uniform mat4 modelView;" << std::endl;
ss << std::endl;
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
ss << "vec4 eye = vposition;" << std::endl; // FIXME
ss << "vec4 position = vposition;" << std::endl; // FIXME
ss << "gl_Position = modelViewProjection * position;" << std::endl;
ss << "bump0ScaleBias = bumpMap0Scale;" << std::endl;
ss << "bump1ScaleBias = bumpMap1Scale;" << std::endl;
// no fog yet
//ss << "vec4 v = modelView[ 3 ];" << std::endl;
//fog.x = dot(position, v);
ss << "texCoord0 = position * bumpMap0Scale + bumpMap0Offset;" << std::endl;
ss << "texCoord1 = position * bumpMap1Scale + bumpMap1Offset;" << std::endl;
ss << "vec4 eyeDirection = normalize(eye - position);" << std::endl;
ss << "texCoord2 = -1 * eyeDirection * vec4(0.5, 0.05, 0.0, 1.0) + vec4(0.5, 0.05, 0.0, 1.0);" << std::endl;
if (diffuse)
{
ss << "texCoord3.x = dot(position, diffuseMapVector0);" << std::endl;
ss << "texCoord3.y = dot(position, diffuseMapVector1);" << std::endl;
}
ss << "}" << std::endl;
}*/
void CGLSLShaderGenerator::generateLightMapPS()
{
#if 0
int ls = material->_LightMaps.size();
ls++; // lightmaps + color texture
int ntextures = 0;
for (int i = TexCoord0; i < TexCoord4; i++)
{
if (hasFlag(desc->vbFlags, g_VertexFlags[i]))
ntextures++;
}
ntextures = std::max(ntextures, ls);
for (int i = 0; i < ntextures; i++)
ss << "uniform sampler2D sampler" << i << ";" << std::endl;
addConstants();
addDiffuse();
addAlphaTreshold();
addFogUniform();
if (desc->fogEnabled())
ss << "smooth in vec4 ecPos;" << std::endl;
ss << std::endl;
if (desc->lightingEnabled())
{
addLightUniformsFS();
addLightInsFS();
ss << std::endl;
addLightsFunctionFS();
ss << std::endl;
}
if (desc->fogEnabled())
addFogFunction();
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
// Lightmap UV coords are at position 1
for (int i = 0; i < ntextures - 1; i++)
{
ss << "vec4 texel" << i;
ss << " = texture(sampler" << i;
ss << ", " << g_AttribNames[ TexCoord1 ] << ".st);" << std::endl;
}
// Color map UV coords are at position 0
ss << "vec4 texel" << ntextures - 1 << " = texture(sampler" << ntextures - 1 << ", " << g_AttribNames[ TexCoord0 ] << ".st);" << std::endl;
//ss << "vec4 texel = diffuseColor;" << std::endl;
//ss << "vec4 texel = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl;
ss << "vec4 texel = vec4(0.0, 0.0, 0.0, 1.0);" << std::endl;
// Lightmaps
for (int i = 0; i < ntextures - 1; i++)
{
ss << "texel.rgb = " << g_TexelNames[i] << ".rgb * " << g_ConstantNames[i] << ".rgb + texel.rgb;" << std::endl;
ss << "texel.a = " << g_TexelNames[i] << ".a * texel.a + texel.a;" << std::endl;
}
// Texture
ss << "texel.rgb = " << g_TexelNames[ ntextures - 1 ] << ".rgb * texel.rgb;" << std::endl;
ss << "texel.a = " << g_TexelNames[ ntextures - 1] << ".a;" << std::endl;
if (material->_LightMapsMulx2)
{
ss << "texel.rgb = texel.rgb * 2.0;" << std::endl;
ss << "texel.a = texel.a * 2.0;" << std::endl;
}
ss << "fragColor = texel;" << std::endl;
if (desc->lightingEnabled())
addLightsFS();
if (desc->fogEnabled())
addFog();
addAlphaTest();
// ss << "fragColor.r = 0.5;" << std::endl;
ss << "}" << std::endl;
ss << std::endl;
#endif
}
void CGLSLShaderGenerator::generatePPLPS()
{
#if 0
ss << "smooth in vec3 cubeTexCoords0;" << std::endl;
if (material->getShader() == CMaterial::PerPixelLighting)
ss << "smooth in vec3 cubeTexCoords2;" << std::endl;
ss << std::endl;
ss << "uniform samplerCube sampler0;" << std::endl;
ss << "uniform sampler2D sampler1;" << std::endl;
if (material->getShader() == CMaterial::PerPixelLighting)
ss << "uniform samplerCube sampler2;" << std::endl;
addDiffuse();
addConstants();
addAlphaTreshold();
ss << std::endl;
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
ss << "vec4 texel0 = texture(sampler0, cubeTexCoords0);" << std::endl;
ss << "vec4 texel1 = texture(sampler1, texCoord1.st);" << std::endl;
if (material->getShader() == CMaterial::PerPixelLighting)
ss << "vec4 texel2 = texture(sampler2, cubeTexCoords2);" << std::endl;
ss << "vec4 texel;" << std::endl;
if (material->getShader() == CMaterial::PerPixelLighting)
{
ss << "texel.rgb = texel0.rgb * constant0.rgb + constant0.rgb;" << std::endl;
ss << "texel.rgb = texel1.rgb * texel.rgb;" << std::endl;
ss << "texel.rgb = texel2.rgb * constant2.rgb + texel.rgb;" << std::endl;
ss << "texel.a = texel0.a * diffuseColor.a" << std::endl;
ss << "texel.a = texel1.a * texel.a;" << std::endl;
}
else
{
ss << "texel.rgb = texel0.rgb * constant0.rgb + color.rgb;" << std::endl;
ss << "texel.rgb = texel1.rgb * texel.rgb;" << std::endl;
ss << "texel.a = texel0.a * diffuseColor.a;" << std::endl;
ss << "texel.a = texel1.a * diffuseColor.a;" << std::endl;
}
ss << "fragColor = texel;" << std::endl;
addAlphaTest();
ss << "}" << std::endl;
#endif
}
void CGLSLShaderGenerator::generateWaterPS()
{
#if 0
bool diffuse = false;
if (material->getTexture(3) != NULL)
diffuse = true;
ss << "smooth in vec4 texCoord0;" << std::endl;
ss << "smooth in vec4 texCoord1;" << std::endl;
ss << "smooth in vec4 texCoord2;" << std::endl;
if (diffuse)
ss << "smooth in vec4 texCoord3;" << std::endl;
ss << "flat in vec4 bump0ScaleBias;" << std::endl;
ss << "flat in vec4 bump1ScaleBias;" << std::endl;
ss << std::endl;
ss << "uniform sampler2D sampler0;" << std::endl;
ss << "uniform sampler2D sampler1;" << std::endl;
ss << "uniform sampler2D sampler2;" << std::endl;
if (diffuse)
ss << "uniform sampler2D sampler3;" << std::endl;
addAlphaTreshold();
ss << std::endl;
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
ss << "vec4 texel0 = texture(sampler0, texCoord0.st);" << std::endl;
ss << "texel0 = texel0 * bump0ScaleBias.xxxx + bump0ScaleBias.yyzz;" << std::endl;
ss << "texel0 = texel0 + texCoord1;" << std::endl;
ss << "vec4 texel1 = texture(sampler1, texel0.st);" << std::endl;
ss << "texel1 = texel1 * bump1ScaleBias.xxxx + bump1ScaleBias.yyzz;" << std::endl;
ss << "texel1 = texel1 + texCoord2;" << std::endl;
ss << "vec4 texel2 = texture(sampler2, texel1.st);" << std::endl;
if (diffuse)
{
ss << "vec4 texel3 = texture(sampler3, texCoord3.st);" << std::endl;
ss << "texel3 = texel3 * texel2;" << std::endl;
}
// No fog yet, so for later
//vec4 tmpFog = clamp(fogValue.x * fogFactor.x + fogFactor.y);
//vec4 fragColor = mix(texel3, fogColor, tmpFog.x);
if (diffuse)
ss << "fragColor = texel3;" << std::endl;
else
ss << "fragColor = texel2;" << std::endl;
addAlphaTest();
ss << "}" << std::endl;
ss << std::endl;
#endif
}
void CGLSLShaderGenerator::generateCloudPS()
{
#if 0
ss << "uniform sampler2D sampler0;" << std::endl;
ss << "uniform sampler2D sampler1;" << std::endl;
addDiffuse();
addAlphaTreshold();
ss << std::endl;
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
ss << "vec4 tex0 = texture(sampler0, texCoord0.st);" << std::endl;
ss << "vec4 tex1 = texture(sampler1, texCoord1.st);" << std::endl;
ss << "vec4 tex = mix(tex0, tex1, diffuse.a);" << std::endl;
ss << "tex.a = 0;" << std::endl;
ss << "fragColor = tex;" << std::endl;
addAlphaTest();
ss << "}" << std::endl;
ss << std::endl;
#endif
}
}
#endif

@ -0,0 +1,155 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef GLSL_SHADER_GENERATOR
#define GLSL_SHADER_GENERATOR
#include <string>
#include <sstream>
namespace NL3D
{
class CMaterial;
class CShaderDesc;
/// GLSL 330+ shader program generator
class CGLSLShaderGenerator
{
public:
CGLSLShaderGenerator();
~CGLSLShaderGenerator();
/// Resets the generator to 0.
void reset();
/// Generate Pixel Shader based on the data provided in material, descriptor and vertexbuffer flags
void generatePS(std::string &ps);
void setMaterial(CMaterial *mat) { material = mat; }
void setShaderDesc(CShaderDesc *d) { desc = d; }
private:
/// Adds ambient color constant uniform declaration to the program
void addAmbient();
/// Adds diffuse constant uniform declaration to the program
void addDiffuse();
/// Adds specular color constant uniform declaration to the program
void addSpecular();
/// Adds Color constant uniform declaration to the program
void addColor();
/// Adds constant uniform declarations to the program
void addConstants();
/// Adds the normal matrix declaration to the program
void addNormalMatrix();
void addViewMatrix();
//////////////////////////// Alpha Threshold //////////////////
/// Adds the alpha threshold uniform to the program
void addAlphaTreshold();
/// Adds the actual alpha test to the program (discards fragment if below threshold)
void addAlphaTest();
//////////////////////////////////////////////////////////////
/////////////////////////// Fog ///////////////////////////////
/// Adds the fog uniforms to the program
void addFogUniform();
/// Adds the fog function to the program
void addFogFunction();
/// Adds the fog call to the program
void addFog();
///////////////////////////////////////////////////////////////
//////////////////////////// Lights ///////////////////////////
/// Adds the Vertex Shader light uniforms to the program
void addLightUniformsVS();
/// Adds the Pixel Shader light uniforms to the program
void addLightUniformsFS();
/// Adds the Pixel Shader light output variables to the program
void addLightInsFS();
/// Adds the appropriate light functions to the Pixel Shader
void addLightsFunctionFS();
/// Adds the lights to the Fragment Shader (calls the appropriate functions)
void addLightsFS();
//////////////////////////////////////////////////////////////
//////////////////////////////////////// Vertex Shader generation ////////////////////////////////////
void generateSpecularVS();
/// Per-Pixel Lighting
void generatePPLVS();
void generateWaterVS();
///////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// Pixel Shader generation ///////////////////////////////////////
void generateInvalidPS();
void generateNormalPS();
// output texop3
void generateTexEnv();
void generateSpecular();
void generateLightMapPS();
void generateSpecularPS();
/// Per-Pixel Lighting
void generatePPLPS();
void generateWaterPS();
void generateCloudPS();
////////////////////////////////////////////////////////////////////////////////////////////////////////
std::stringstream ss;
CMaterial const *material;
CShaderDesc const *desc;
};
}
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,2 @@
EXPORTS NL3D_createIDriverInstance
EXPORTS NL3D_interfaceVersion

File diff suppressed because it is too large Load Diff

@ -0,0 +1,807 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include "driver_opengl.h"
#include "driver_opengl_extension.h"
#include "nel/misc/common.h"
#include "nel/3d/material.h"
using namespace std;
using namespace NLMISC;
// ***************************************************************************
#if defined(NL_OS_WINDOWS)
#define nglGetProcAddress wglGetProcAddress
#elif defined(NL_OS_MAC)
// #include <mach-o/dyld.h>
// glXGetProcAddressARB doesn't work correctly on MAC
// void *nglGetProcAddress(const char *name)
// {
// NSSymbol symbol;
// char *symbolName;
// symbolName = (char*)malloc (strlen (name) + 2);
// strcpy(symbolName + 1, name);
// symbolName[0] = '_';
// symbol = NULL;
// if (NSIsSymbolNameDefined (symbolName)) symbol = NSLookupAndBindSymbol (symbolName);
// free (symbolName);
// return symbol ? NSAddressOfSymbol (symbol) : NULL;
// }
// NSAddressOfSymbol, NSIsSymbolNameDefined, NSLookupAndBindSymbol are deprecated
#include <dlfcn.h>
void *nglGetProcAddress(const char *name)
{
return dlsym(RTLD_DEFAULT, name);
}
#elif defined (NL_OS_UNIX)
void (*nglGetProcAddress(const char *procName))()
{
return glXGetProcAddressARB((const GLubyte *)procName);
}
#endif // NL_OS_WINDOWS
// ***************************************************************************
// The exported function names
// Core 3.30
PFNGLGETSTRINGIPROC nglGetStringi;
PFNGLCLEARBUFFERIVPROC nglClearBufferiv;
PFNGLCLEARBUFFERUIVPROC nglClearBufferuiv;
PFNGLCLEARBUFFERFVPROC nglClearBufferfv;
PFNGLCLEARBUFFERFIPROC nglClearBufferfi;
PFNGLATTACHSHADERPROC nglAttachShader;
PFNGLCOMPILESHADERPROC nglCompileShader;
PFNGLCREATEPROGRAMPROC nglCreateProgram;
PFNGLCREATESHADERPROC nglCreateShader;
PFNGLDELETEPROGRAMPROC nglDeleteProgram;
PFNGLDELETESHADERPROC nglDeleteShader;
PFNGLDETACHSHADERPROC nglDetachShader;
PFNGLDISABLEVERTEXATTRIBARRAYPROC nglDisableVertexAttribArray;
PFNGLENABLEVERTEXATTRIBARRAYPROC nglEnableVertexAttribArray;
PFNGLGETATTACHEDSHADERSPROC nglGetAttachedShaders;
PFNGLGETPROGRAMIVPROC nglGetProgramiv;
PFNGLGETPROGRAMINFOLOGPROC nglGetProgramInfoLog;
PFNGLGETSHADERIVPROC nglGetShaderiv;
PFNGLGETSHADERINFOLOGPROC nglGetShaderInfoLog;
PFNGLGETUNIFORMLOCATIONPROC nglGetUniformLocation;
PFNGLISPROGRAMPROC nglIsProgram;
PFNGLISSHADERPROC nglIsShader;
PFNGLLINKPROGRAMPROC nglLinkProgram;
PFNGLSHADERSOURCEPROC nglShaderSource;
PFNGLUSEPROGRAMPROC nglUseProgram;
PFNGLVALIDATEPROGRAMPROC nglValidateProgram;
/*PFNGLUNIFORM1FPROC nglUniform1f;
PFNGLUNIFORM2FPROC nglUniform2f;
PFNGLUNIFORM3FPROC nglUniform3f;
PFNGLUNIFORM4FPROC nglUniform4f;
PFNGLUNIFORM1IPROC nglUniform1i;
PFNGLUNIFORM2IPROC nglUniform2i;
PFNGLUNIFORM3IPROC nglUniform3i;
PFNGLUNIFORM4IPROC nglUniform4i;
PFNGLUNIFORM1FVPROC nglUniform1fv;
PFNGLUNIFORM2FVPROC nglUniform2fv;
PFNGLUNIFORM3FVPROC nglUniform3fv;
PFNGLUNIFORM4FVPROC nglUniform4fv;
PFNGLUNIFORM1IVPROC nglUniform1iv;
PFNGLUNIFORM2IVPROC nglUniform2iv;
PFNGLUNIFORM3IVPROC nglUniform3iv;
PFNGLUNIFORM4IVPROC nglUniform4iv;
PFNGLUNIFORMMATRIX2FVPROC nglUniformMatrix2fv;
PFNGLUNIFORMMATRIX3FVPROC nglUniformMatrix3fv;
PFNGLUNIFORMMATRIX4FVPROC nglUniformMatrix4fv;*/
PFNGLVERTEXATTRIBPOINTERPROC nglVertexAttribPointer;
PFNGLBINDBUFFERPROC nglBindBuffer;
PFNGLDELETEBUFFERSPROC nglDeleteBuffers;
PFNGLGENBUFFERSPROC nglGenBuffers;
PFNGLISBUFFERPROC nglIsBuffer;
PFNGLBUFFERDATAPROC nglBufferData;
PFNGLBUFFERSUBDATAPROC nglBufferSubData;
PFNGLGETBUFFERSUBDATAPROC nglGetBufferSubData;
PFNGLMAPBUFFERPROC nglMapBuffer;
PFNGLUNMAPBUFFERPROC nglUnmapBuffer;
PFNGLGETBUFFERPARAMETERIVPROC nglGetBufferParameteriv;
PFNGLGETBUFFERPOINTERVPROC nglGetBufferPointerv;
PFNGLMAPBUFFERRANGEPROC nglMapBufferRange;
PFNGLFLUSHMAPPEDBUFFERRANGEPROC nglFlushMappedBufferRange;
PFNGLGENQUERIESPROC nglGenQueries;
PFNGLDELETEQUERIESPROC nglDeleteQueries;
PFNGLISQUERYPROC nglIsQuery;
PFNGLBEGINQUERYPROC nglBeginQuery;
PFNGLENDQUERYPROC nglEndQuery;
PFNGLGETQUERYIVPROC nglGetQueryiv;
PFNGLGETQUERYOBJECTIVPROC nglGetQueryObjectiv;
PFNGLGETQUERYOBJECTUIVPROC nglGetQueryObjectuiv;
/*PFNGLISRENDERBUFFERPROC nglIsRenderbuffer;
PFNGLBINDRENDERBUFFERPROC nglBindRenderbuffer;
PFNGLDELETERENDERBUFFERSPROC nglDeleteRenderbuffers;
PFNGLGENRENDERBUFFERSPROC nglGenRenderbuffers;
PFNGLRENDERBUFFERSTORAGEPROC nglRenderbufferStorage;
PFNGLGETRENDERBUFFERPARAMETERIVPROC nglGetRenderbufferParameteriv;
PFNGLISFRAMEBUFFERPROC nglIsFramebuffer;
PFNGLBINDFRAMEBUFFERPROC nglBindFramebuffer;
PFNGLDELETEFRAMEBUFFERSPROC nglDeleteFramebuffers;
PFNGLGENFRAMEBUFFERSPROC nglGenFramebuffers;
PFNGLCHECKFRAMEBUFFERSTATUSPROC nglCheckFramebufferStatus;
PFNGLFRAMEBUFFERTEXTURE1DPROC nglFramebufferTexture1D;
PFNGLFRAMEBUFFERTEXTURE2DPROC nglFramebufferTexture2D;
PFNGLFRAMEBUFFERTEXTURE3DPROC nglFramebufferTexture3D;
PFNGLFRAMEBUFFERRENDERBUFFERPROC nglFramebufferRenderbuffer;
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC nglGetFramebufferAttachmentParameteriv;
PFNGLGENERATEMIPMAPPROC nglGenerateMipmap;
PFNGLBLITFRAMEBUFFERPROC nglBlitFramebuffer;
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC nglRenderbufferStorageMultisample;
PFNGLFRAMEBUFFERTEXTURELAYERPROC nglFramebufferTextureLayer;*/
PFNGLACTIVETEXTUREPROC nglActiveTexture;
PFNGLCOMPRESSEDTEXIMAGE3DPROC nglCompressedTexImage3D;
PFNGLCOMPRESSEDTEXIMAGE2DPROC nglCompressedTexImage2D;
PFNGLCOMPRESSEDTEXIMAGE1DPROC nglCompressedTexImage1D;
PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC nglCompressedTexSubImage3D;
PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC nglCompressedTexSubImage2D;
PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC nglCompressedTexSubImage1D;
PFNGLGETCOMPRESSEDTEXIMAGEPROC nglGetCompressedTexImage;
PFNGLBLENDCOLORPROC nglBlendColor;
PFNGLFENCESYNCPROC nglFenceSync;
PFNGLISSYNCPROC nglIsSync;
PFNGLDELETESYNCPROC nglDeleteSync;
PFNGLCLIENTWAITSYNCPROC nglClientWaitSync;
PFNGLWAITSYNCPROC nglWaitSync;
PFNGLGETINTEGER64VPROC nglGetInteger64v;
PFNGLGETSYNCIVPROC nglGetSynciv;
// GL_ARB_separate_shader_objects
PFNGLUSEPROGRAMSTAGESPROC nglUseProgramStages;
PFNGLACTIVESHADERPROGRAMPROC nglActiveShaderProgram;
PFNGLCREATESHADERPROGRAMVPROC nglCreateShaderProgramv;
PFNGLBINDPROGRAMPIPELINEPROC nglBindProgramPipeline;
PFNGLDELETEPROGRAMPIPELINESPROC nglDeleteProgramPipelines;
PFNGLGENPROGRAMPIPELINESPROC nglGenProgramPipelines;
PFNGLISPROGRAMPIPELINEPROC nglIsProgramPipeline;
PFNGLGETPROGRAMPIPELINEIVPROC nglGetProgramPipelineiv;
PFNGLPROGRAMUNIFORM1IPROC nglProgramUniform1i;
PFNGLPROGRAMUNIFORM1IVPROC nglProgramUniform1iv;
PFNGLPROGRAMUNIFORM1FPROC nglProgramUniform1f;
PFNGLPROGRAMUNIFORM1FVPROC nglProgramUniform1fv;
PFNGLPROGRAMUNIFORM1DPROC nglProgramUniform1d;
PFNGLPROGRAMUNIFORM1DVPROC nglProgramUniform1dv;
PFNGLPROGRAMUNIFORM1UIPROC nglProgramUniform1ui;
PFNGLPROGRAMUNIFORM1UIVPROC nglProgramUniform1uiv;
PFNGLPROGRAMUNIFORM2IPROC nglProgramUniform2i;
PFNGLPROGRAMUNIFORM2IVPROC nglProgramUniform2iv;
PFNGLPROGRAMUNIFORM2FPROC nglProgramUniform2f;
PFNGLPROGRAMUNIFORM2FVPROC nglProgramUniform2fv;
PFNGLPROGRAMUNIFORM2DPROC nglProgramUniform2d;
PFNGLPROGRAMUNIFORM2DVPROC nglProgramUniform2dv;
PFNGLPROGRAMUNIFORM2UIPROC nglProgramUniform2ui;
PFNGLPROGRAMUNIFORM2UIVPROC nglProgramUniform2uiv;
PFNGLPROGRAMUNIFORM3IPROC nglProgramUniform3i;
PFNGLPROGRAMUNIFORM3IVPROC nglProgramUniform3iv;
PFNGLPROGRAMUNIFORM3FPROC nglProgramUniform3f;
PFNGLPROGRAMUNIFORM3FVPROC nglProgramUniform3fv;
PFNGLPROGRAMUNIFORM3DPROC nglProgramUniform3d;
PFNGLPROGRAMUNIFORM3DVPROC nglProgramUniform3dv;
PFNGLPROGRAMUNIFORM3UIPROC nglProgramUniform3ui;
PFNGLPROGRAMUNIFORM3UIVPROC nglProgramUniform3uiv;
PFNGLPROGRAMUNIFORM4IPROC nglProgramUniform4i;
PFNGLPROGRAMUNIFORM4IVPROC nglProgramUniform4iv;
PFNGLPROGRAMUNIFORM4FPROC nglProgramUniform4f;
PFNGLPROGRAMUNIFORM4FVPROC nglProgramUniform4fv;
PFNGLPROGRAMUNIFORM4DPROC nglProgramUniform4d;
PFNGLPROGRAMUNIFORM4DVPROC nglProgramUniform4dv;
PFNGLPROGRAMUNIFORM4UIPROC nglProgramUniform4ui;
PFNGLPROGRAMUNIFORM4UIVPROC nglProgramUniform4uiv;
PFNGLPROGRAMUNIFORMMATRIX2FVPROC nglProgramUniformMatrix2fv;
PFNGLPROGRAMUNIFORMMATRIX3FVPROC nglProgramUniformMatrix3fv;
PFNGLPROGRAMUNIFORMMATRIX4FVPROC nglProgramUniformMatrix4fv;
PFNGLPROGRAMUNIFORMMATRIX2DVPROC nglProgramUniformMatrix2dv;
PFNGLPROGRAMUNIFORMMATRIX3DVPROC nglProgramUniformMatrix3dv;
PFNGLPROGRAMUNIFORMMATRIX4DVPROC nglProgramUniformMatrix4dv;
PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC nglProgramUniformMatrix2x3fv;
PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC nglProgramUniformMatrix3x2fv;
PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC nglProgramUniformMatrix2x4fv;
PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC nglProgramUniformMatrix4x2fv;
PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC nglProgramUniformMatrix3x4fv;
PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC nglProgramUniformMatrix4x3fv;
PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC nglProgramUniformMatrix2x3dv;
PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC nglProgramUniformMatrix3x2dv;
PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC nglProgramUniformMatrix2x4dv;
PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC nglProgramUniformMatrix4x2dv;
PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC nglProgramUniformMatrix3x4dv;
PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC nglProgramUniformMatrix4x3dv;
PFNGLVALIDATEPROGRAMPIPELINEPROC nglValidateProgramPipeline;
PFNGLGETPROGRAMPIPELINEINFOLOGPROC nglGetProgramPipelineInfoLog;
#ifdef NL_OS_WINDOWS
PFNWGLALLOCATEMEMORYNVPROC nwglAllocateMemoryNV;
PFNWGLFREEMEMORYNVPROC nwglFreeMemoryNV;
// Pbuffer extension
PFNWGLCREATEPBUFFERARBPROC nwglCreatePbufferARB;
PFNWGLGETPBUFFERDCARBPROC nwglGetPbufferDCARB;
PFNWGLRELEASEPBUFFERDCARBPROC nwglReleasePbufferDCARB;
PFNWGLDESTROYPBUFFERARBPROC nwglDestroyPbufferARB;
PFNWGLQUERYPBUFFERARBPROC nwglQueryPbufferARB;
// Get Pixel format extension
PFNWGLGETPIXELFORMATATTRIBIVARBPROC nwglGetPixelFormatAttribivARB;
PFNWGLGETPIXELFORMATATTRIBFVARBPROC nwglGetPixelFormatAttribfvARB;
PFNWGLCHOOSEPIXELFORMATARBPROC nwglChoosePixelFormatARB;
// Swap control extension
PFNWGLSWAPINTERVALEXTPROC nwglSwapIntervalEXT;
PFNWGLGETSWAPINTERVALEXTPROC nwglGetSwapIntervalEXT;
// WGL_ARB_extensions_string
PFNWGLGETEXTENSIONSSTRINGARBPROC nwglGetExtensionsStringARB;
// WGL_ARB_create_context_profile
PFNWGLCREATECONTEXTATTRIBSARBPROC nwglCreateContextAttribsARB;
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
NEL_PFNGLXALLOCATEMEMORYNVPROC nglXAllocateMemoryNV;
NEL_PFNGLXFREEMEMORYNVPROC nglXFreeMemoryNV;
// Swap control extensions
NEL_PFNGLXSWAPINTERVALEXTPROC nglXSwapIntervalEXT;
PFNGLXSWAPINTERVALSGIPROC nglXSwapIntervalSGI;
NEL_PFNGLXSWAPINTERVALMESAPROC nglXSwapIntervalMESA;
NEL_PFNGLXGETSWAPINTERVALMESAPROC nglXGetSwapIntervalMESA;
#endif
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
namespace NL3D {
namespace NLDRIVERGL3 {
#define CHECK_EXT(ext_str) \
if (strstr(glext, ext_str)==NULL) { nlwarning("3D: OpengGL extension '%s' was not found", ext_str); return false; } else { nldebug("3D: OpengGL Extension '%s' found", ext_str); }
bool checkExt2(std::vector<const char *> &glext, const char *ext_str)
{
for (int i = 0; i < glext.size(); ++i)
{
if (strcmp(glext[i], ext_str) == 0)
return true;
}
return false;
}
#define CHECK_EXT_2(ext_str) \
if (!checkExt2(glext, ext_str)) { nlwarning("3D: OpengGL extension '%s' was not found", ext_str); return false; } else { nldebug("3D: OpengGL Extension '%s' found", ext_str); }
// Debug: don't return false if the procaddr returns 0
// It means that it can crash if nel calls this extension but at least we have a warning to know why the extension is available but not the procaddr
#define CHECK_ADDRESS(type, ext) \
n##ext=(type)nglGetProcAddress(#ext); \
if (!n##ext) { nlwarning("3D: GetProcAddress(\"%s\") returns NULL", #ext); return false; } else { /*nldebug("3D: GetProcAddress(\"%s\") succeed", #ext);*/ }
// ***************************************************************************
// Extensions registrations, and Windows function Registration.
// *********************************
static bool setupEXTTextureCompressionS3TC(std::vector<const char *> &glext)
{
H_AUTO_OGL(setupEXTTextureCompressionS3TC);
CHECK_EXT_2("GL_EXT_texture_compression_s3tc");
// TODO: check also for GL_S3_s3tc, GL_EXT_texture_compression_dxt1
return true;
}
// *********************************
static bool setupWGLARBPBuffer(const char *glext)
{
H_AUTO_OGL(setupWGLARBPBuffer);
CHECK_EXT("WGL_ARB_pbuffer");
#ifdef NL_OS_WINDOWS
CHECK_ADDRESS(PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB);
CHECK_ADDRESS(PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB);
CHECK_ADDRESS(PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB);
CHECK_ADDRESS(PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB);
CHECK_ADDRESS(PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB);
#endif
return true;
}
#ifdef NL_OS_WINDOWS
// *********************************
static bool setupWGLARBPixelFormat (const char *glext)
{
H_AUTO_OGL(setupWGLARBPixelFormat);
CHECK_EXT("WGL_ARB_pixel_format");
CHECK_ADDRESS(PFNWGLGETPIXELFORMATATTRIBIVARBPROC, wglGetPixelFormatAttribivARB);
CHECK_ADDRESS(PFNWGLGETPIXELFORMATATTRIBFVARBPROC, wglGetPixelFormatAttribfvARB);
CHECK_ADDRESS(PFNWGLCHOOSEPIXELFORMATARBPROC, wglChoosePixelFormatARB);
return true;
}
#endif
// ***************************************************************************
static bool setupEXTTextureFilterAnisotropic(std::vector<const char *> &glext)
{
H_AUTO_OGL(setupEXTTextureFilterAnisotropic);
CHECK_EXT_2("GL_EXT_texture_filter_anisotropic");
return true;
}
static bool setupGLCore(std::vector<const char *> &glext)
{
CHECK_ADDRESS(PFNGLCLEARBUFFERIVPROC, glClearBufferiv);
CHECK_ADDRESS(PFNGLCLEARBUFFERUIVPROC, glClearBufferuiv);
CHECK_ADDRESS(PFNGLCLEARBUFFERFVPROC, glClearBufferfv);
CHECK_ADDRESS(PFNGLCLEARBUFFERFIPROC, glClearBufferfi);
CHECK_ADDRESS(PFNGLATTACHSHADERPROC, glAttachShader);
CHECK_ADDRESS(PFNGLCOMPILESHADERPROC, glCompileShader);
CHECK_ADDRESS(PFNGLCREATEPROGRAMPROC, glCreateProgram);
CHECK_ADDRESS(PFNGLCREATESHADERPROC, glCreateShader);
CHECK_ADDRESS(PFNGLDELETEPROGRAMPROC, glDeleteProgram);
CHECK_ADDRESS(PFNGLDELETESHADERPROC, glDeleteShader);
CHECK_ADDRESS(PFNGLDETACHSHADERPROC, glDetachShader);
CHECK_ADDRESS(PFNGLDISABLEVERTEXATTRIBARRAYPROC, glDisableVertexAttribArray);
CHECK_ADDRESS(PFNGLENABLEVERTEXATTRIBARRAYPROC, glEnableVertexAttribArray);
CHECK_ADDRESS(PFNGLGETATTACHEDSHADERSPROC, glGetAttachedShaders);
CHECK_ADDRESS(PFNGLGETPROGRAMIVPROC, glGetProgramiv);
CHECK_ADDRESS(PFNGLGETPROGRAMINFOLOGPROC, glGetProgramInfoLog);
CHECK_ADDRESS(PFNGLGETSHADERIVPROC, glGetShaderiv);
CHECK_ADDRESS(PFNGLGETSHADERINFOLOGPROC, glGetShaderInfoLog);
CHECK_ADDRESS(PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation);
CHECK_ADDRESS(PFNGLISPROGRAMPROC, glIsProgram);
CHECK_ADDRESS(PFNGLISSHADERPROC, glIsShader);
CHECK_ADDRESS(PFNGLLINKPROGRAMPROC, glLinkProgram);
CHECK_ADDRESS(PFNGLSHADERSOURCEPROC, glShaderSource);
CHECK_ADDRESS(PFNGLUSEPROGRAMPROC, glUseProgram);
CHECK_ADDRESS(PFNGLVALIDATEPROGRAMPROC, glValidateProgram);
/*CHECK_ADDRESS(PFNGLUNIFORM1FPROC, glUniform1f);
CHECK_ADDRESS(PFNGLUNIFORM2FPROC, glUniform2f);
CHECK_ADDRESS(PFNGLUNIFORM3FPROC, glUniform3f);
CHECK_ADDRESS(PFNGLUNIFORM4FPROC, glUniform4f);
CHECK_ADDRESS(PFNGLUNIFORM1IPROC, glUniform1i);
CHECK_ADDRESS(PFNGLUNIFORM2IPROC, glUniform2i);
CHECK_ADDRESS(PFNGLUNIFORM3IPROC, glUniform3i);
CHECK_ADDRESS(PFNGLUNIFORM4IPROC, glUniform4i);
CHECK_ADDRESS(PFNGLUNIFORM1FVPROC, glUniform1fv);
CHECK_ADDRESS(PFNGLUNIFORM2FVPROC, glUniform2fv);
CHECK_ADDRESS(PFNGLUNIFORM3FVPROC, glUniform3fv);
CHECK_ADDRESS(PFNGLUNIFORM4FVPROC, glUniform4fv);
CHECK_ADDRESS(PFNGLUNIFORM1IVPROC, glUniform1iv);
CHECK_ADDRESS(PFNGLUNIFORM2IVPROC, glUniform2iv);
CHECK_ADDRESS(PFNGLUNIFORM3IVPROC, glUniform3iv);
CHECK_ADDRESS(PFNGLUNIFORM4IVPROC, glUniform4iv);
CHECK_ADDRESS(PFNGLUNIFORMMATRIX2FVPROC, glUniformMatrix2fv);
CHECK_ADDRESS(PFNGLUNIFORMMATRIX3FVPROC, glUniformMatrix3fv);
CHECK_ADDRESS(PFNGLUNIFORMMATRIX4FVPROC, glUniformMatrix4fv);*/
CHECK_ADDRESS(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer);
CHECK_ADDRESS(PFNGLBINDBUFFERPROC, glBindBuffer);
CHECK_ADDRESS(PFNGLDELETEBUFFERSPROC, glDeleteBuffers);
CHECK_ADDRESS(PFNGLGENBUFFERSPROC, glGenBuffers);
CHECK_ADDRESS(PFNGLISBUFFERPROC, glIsBuffer);
CHECK_ADDRESS(PFNGLBUFFERDATAPROC, glBufferData);
CHECK_ADDRESS(PFNGLBUFFERSUBDATAPROC, glBufferSubData);
CHECK_ADDRESS(PFNGLGETBUFFERSUBDATAPROC, glGetBufferSubData);
CHECK_ADDRESS(PFNGLMAPBUFFERPROC, glMapBuffer);
CHECK_ADDRESS(PFNGLUNMAPBUFFERPROC, glUnmapBuffer);
CHECK_ADDRESS(PFNGLGETBUFFERPARAMETERIVPROC, glGetBufferParameteriv);
CHECK_ADDRESS(PFNGLGETBUFFERPOINTERVPROC, glGetBufferPointerv);
CHECK_ADDRESS(PFNGLMAPBUFFERRANGEPROC, glMapBufferRange);
CHECK_ADDRESS(PFNGLFLUSHMAPPEDBUFFERRANGEPROC, glFlushMappedBufferRange);
CHECK_ADDRESS(PFNGLGENQUERIESPROC, glGenQueries);
CHECK_ADDRESS(PFNGLDELETEQUERIESPROC, glDeleteQueries);
CHECK_ADDRESS(PFNGLISQUERYPROC, glIsQuery);
CHECK_ADDRESS(PFNGLBEGINQUERYPROC, glBeginQuery);
CHECK_ADDRESS(PFNGLENDQUERYPROC, glEndQuery);
CHECK_ADDRESS(PFNGLGETQUERYIVPROC, glGetQueryiv);
CHECK_ADDRESS(PFNGLGETQUERYOBJECTIVPROC, glGetQueryObjectiv);
CHECK_ADDRESS(PFNGLGETQUERYOBJECTUIVPROC, glGetQueryObjectuiv);
/*CHECK_ADDRESS(PFNGLISRENDERBUFFERPROC, glIsRenderbuffer);
CHECK_ADDRESS(PFNGLBINDRENDERBUFFERPROC, glBindRenderbuffer);
CHECK_ADDRESS(PFNGLDELETERENDERBUFFERSPROC, glDeleteRenderbuffers);
CHECK_ADDRESS(PFNGLGENRENDERBUFFERSPROC, glGenRenderbuffers);
CHECK_ADDRESS(PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage);
CHECK_ADDRESS(PFNGLGETRENDERBUFFERPARAMETERIVPROC, glGetRenderbufferParameteriv);
CHECK_ADDRESS(PFNGLISFRAMEBUFFERPROC, glIsFramebuffer);
CHECK_ADDRESS(PFNGLBINDFRAMEBUFFERPROC, glBindFramebuffer);
CHECK_ADDRESS(PFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffers);
CHECK_ADDRESS(PFNGLGENFRAMEBUFFERSPROC, glGenFramebuffers);
CHECK_ADDRESS(PFNGLCHECKFRAMEBUFFERSTATUSPROC, glCheckFramebufferStatus);
CHECK_ADDRESS(PFNGLFRAMEBUFFERTEXTURE1DPROC, glFramebufferTexture1D);
CHECK_ADDRESS(PFNGLFRAMEBUFFERTEXTURE2DPROC, glFramebufferTexture2D);
CHECK_ADDRESS(PFNGLFRAMEBUFFERTEXTURE3DPROC, glFramebufferTexture3D);
CHECK_ADDRESS(PFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbuffer);
CHECK_ADDRESS(PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC, glGetFramebufferAttachmentParameteriv);
CHECK_ADDRESS(PFNGLGENERATEMIPMAPPROC, glGenerateMipmap);
CHECK_ADDRESS(PFNGLBLITFRAMEBUFFERPROC, glBlitFramebuffer);
CHECK_ADDRESS(PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample);
CHECK_ADDRESS(PFNGLFRAMEBUFFERTEXTURELAYERPROC, glFramebufferTextureLayer);*/
CHECK_ADDRESS(PFNGLACTIVETEXTUREPROC, glActiveTexture);
CHECK_ADDRESS(PFNGLCOMPRESSEDTEXIMAGE3DPROC, glCompressedTexImage3D);
CHECK_ADDRESS(PFNGLCOMPRESSEDTEXIMAGE2DPROC, glCompressedTexImage2D);
CHECK_ADDRESS(PFNGLCOMPRESSEDTEXIMAGE1DPROC, glCompressedTexImage1D);
CHECK_ADDRESS(PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedTexSubImage3D);
CHECK_ADDRESS(PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC, glCompressedTexSubImage2D);
CHECK_ADDRESS(PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC, glCompressedTexSubImage1D);
CHECK_ADDRESS(PFNGLGETCOMPRESSEDTEXIMAGEPROC, glGetCompressedTexImage);
CHECK_ADDRESS(PFNGLBLENDCOLORPROC, glBlendColor);
CHECK_ADDRESS(PFNGLFENCESYNCPROC, glFenceSync);
CHECK_ADDRESS(PFNGLISSYNCPROC, glIsSync);
CHECK_ADDRESS(PFNGLDELETESYNCPROC, glDeleteSync);
CHECK_ADDRESS(PFNGLCLIENTWAITSYNCPROC, glClientWaitSync);
CHECK_ADDRESS(PFNGLWAITSYNCPROC, glWaitSync);
CHECK_ADDRESS(PFNGLGETINTEGER64VPROC, glGetInteger64v);
CHECK_ADDRESS(PFNGLGETSYNCIVPROC, glGetSynciv);
return true;
}
static bool setupARBSeparateShaderObjects(std::vector<const char *> &glext)
{
CHECK_EXT_2("GL_ARB_separate_shader_objects");
CHECK_ADDRESS(PFNGLUSEPROGRAMSTAGESPROC, glUseProgramStages);
CHECK_ADDRESS(PFNGLACTIVESHADERPROGRAMPROC, glActiveShaderProgram);
CHECK_ADDRESS(PFNGLCREATESHADERPROGRAMVPROC, glCreateShaderProgramv);
CHECK_ADDRESS(PFNGLBINDPROGRAMPIPELINEPROC, glBindProgramPipeline);
CHECK_ADDRESS(PFNGLDELETEPROGRAMPIPELINESPROC, glDeleteProgramPipelines);
CHECK_ADDRESS(PFNGLGENPROGRAMPIPELINESPROC, glGenProgramPipelines);
CHECK_ADDRESS(PFNGLISPROGRAMPIPELINEPROC, glIsProgramPipeline);
CHECK_ADDRESS(PFNGLGETPROGRAMPIPELINEIVPROC, glGetProgramPipelineiv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1IPROC, glProgramUniform1i);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1IVPROC, glProgramUniform1iv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1FPROC, glProgramUniform1f);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1FVPROC, glProgramUniform1fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1DPROC, glProgramUniform1d);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1DVPROC, glProgramUniform1dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1UIPROC, glProgramUniform1ui);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM1UIVPROC, glProgramUniform1uiv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2IPROC, glProgramUniform2i);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2IVPROC, glProgramUniform2iv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2FPROC, glProgramUniform2f);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2FVPROC, glProgramUniform2fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2DPROC, glProgramUniform2d);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2DVPROC, glProgramUniform2dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2UIPROC, glProgramUniform2ui);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM2UIVPROC, glProgramUniform2uiv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3IPROC, glProgramUniform3i);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3IVPROC, glProgramUniform3iv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3FPROC, glProgramUniform3f);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3FVPROC, glProgramUniform3fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3DPROC, glProgramUniform3d);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3DVPROC, glProgramUniform3dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3UIPROC, glProgramUniform3ui);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM3UIVPROC, glProgramUniform3uiv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4IPROC, glProgramUniform4i);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4IVPROC, glProgramUniform4iv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4FPROC, glProgramUniform4f);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4FVPROC, glProgramUniform4fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4DPROC, glProgramUniform4d);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4DVPROC, glProgramUniform4dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4UIPROC, glProgramUniform4ui);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORM4UIVPROC, glProgramUniform4uiv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2FVPROC, glProgramUniformMatrix2fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3FVPROC, glProgramUniformMatrix3fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4FVPROC, glProgramUniformMatrix4fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2DVPROC, glProgramUniformMatrix2dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3DVPROC, glProgramUniformMatrix3dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4DVPROC, glProgramUniformMatrix4dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC, glProgramUniformMatrix2x3fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC, glProgramUniformMatrix3x2fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC, glProgramUniformMatrix2x4fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC, glProgramUniformMatrix4x2fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC, glProgramUniformMatrix3x4fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC, glProgramUniformMatrix4x3fv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC, glProgramUniformMatrix2x3dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC, glProgramUniformMatrix3x2dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC, glProgramUniformMatrix2x4dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC, glProgramUniformMatrix4x2dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC, glProgramUniformMatrix3x4dv);
CHECK_ADDRESS(PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC, glProgramUniformMatrix4x3dv);
CHECK_ADDRESS(PFNGLVALIDATEPROGRAMPIPELINEPROC, glValidateProgramPipeline);
CHECK_ADDRESS(PFNGLGETPROGRAMPIPELINEINFOLOGPROC, glGetProgramPipelineInfoLog);
return true;
}
static bool setupAMDPinnedMemory(std::vector<const char *> &glext)
{
CHECK_EXT_2("GL_AMD_pinned_memory");
return true;
}
// ***************************************************************************
// Extension Check.
bool registerGlExtensions(CGlExtensions &ext)
{
H_AUTO_OGL(registerGlExtensions);
nldebug("Register OpenGL extensions");
const char *nglVersion= (const char *)glGetString (GL_VERSION);
sint a=0, b=0;
sscanf(nglVersion, "%d.%d", &a, &b);
if ((a < 3) || ((a == 3) && (b < 3)))
{
nlinfo("OpenGL version is less than 3.3!");
nlinfo("Version string: %s",nglVersion);
nlassert(false);
}
nldebug("OpenGL version is OK");
// Extensions.
/*const char *glext= (const char*)glGetString(GL_EXTENSIONS);
GLint ntext;*/
// Get proc address
CHECK_ADDRESS(PFNGLGETSTRINGIPROC, glGetStringi);
nldebug("GL3: glGetStringi found!");
std::vector<const char *> glext;
GLint numExt;
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
nldebug("GL3: GL_NUM_EXTENSIONS = %i", numExt);
glext.resize(numExt);
for (GLint i = 0; i < numExt; ++i)
{
glext[i] = static_cast<const char *>(static_cast<const void *>(nglGetStringi(GL_EXTENSIONS, i)));
}
nldebug("3D: Available OpenGL Extensions:");
if (DebugLog)
{
//vector<string> exts;
//explode(string(glext), string(" "), exts);
for (uint i = 0; i < glext.size(); i++)
{
if (i%5==0) DebugLog->displayRaw("3D: ");
DebugLog->displayRaw(string(string(glext[i]) + " ").c_str());
if (i%5==4) DebugLog->displayRaw("\n");
}
DebugLog->displayRaw("\n");
}
// Check 3.30 Core
ext.GLCore = setupGLCore(glext);
// Check GL_ARB_separate_shader_objects
ext.ARBSeparateShaderObjects = setupARBSeparateShaderObjects(glext);
// Compression S3TC
ext.EXTTextureCompressionS3TC = setupEXTTextureCompressionS3TC(glext);
// Check GL_EXT_texture_filter_anisotropic
ext.EXTTextureFilterAnisotropic = setupEXTTextureFilterAnisotropic(glext);
if (ext.EXTTextureFilterAnisotropic)
{
// get the maximum value
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &ext.EXTTextureFilterAnisotropicMaximum);
}
// Check GL_AMD_pinned_memory
ext.AMDPinnedMemory = false; // setupAMDPinnedMemory(glext); // TODO: Proper frame sync check
// Get the maximum fragment texture unites
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &ext.MaxFragmentTextureImageUnits);
if (ext.MaxFragmentTextureImageUnits < 8)
{
nlwarning("GL_MAX_TEXTURE_IMAGE_UNITS must be greater than or equal to 8, value returned by driver is %i", ext.MaxFragmentTextureImageUnits);
}
return true;
}
// *********************************
static bool setupWGLEXTSwapControl(const char *glext)
{
H_AUTO_OGL(setupWGLEXTSwapControl);
CHECK_EXT("WGL_EXT_swap_control");
#ifdef NL_OS_WINDOWS
CHECK_ADDRESS(PFNWGLSWAPINTERVALEXTPROC, wglSwapIntervalEXT);
CHECK_ADDRESS(PFNWGLGETSWAPINTERVALEXTPROC, wglGetSwapIntervalEXT);
#endif
return true;
}
// *********************************
static bool setupWGLARBCreateContextProfile(const char *glext)
{
H_AUTO_OGL(setupWGLARBCreateContextProfile);
CHECK_EXT("WGL_ARB_create_context_profile");
#ifdef NL_OS_WINDOWS
CHECK_ADDRESS(PFNWGLCREATECONTEXTATTRIBSARBPROC, wglCreateContextAttribsARB);
#endif
return true;
}
// *********************************
static bool setupGLXEXTSwapControl(const char *glext)
{
H_AUTO_OGL(setupGLXEXTSwapControl);
CHECK_EXT("GLX_EXT_swap_control");
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
CHECK_ADDRESS(NEL_PFNGLXSWAPINTERVALEXTPROC, glXSwapIntervalEXT);
#endif
return true;
}
// *********************************
static bool setupGLXSGISwapControl(const char *glext)
{
H_AUTO_OGL(setupGLXSGISwapControl);
CHECK_EXT("GLX_SGI_swap_control");
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
CHECK_ADDRESS(PFNGLXSWAPINTERVALSGIPROC, glXSwapIntervalSGI);
#endif
return true;
}
// *********************************
static bool setupGLXMESASwapControl(const char *glext)
{
H_AUTO_OGL(setupGLXMESASwapControl);
CHECK_EXT("GLX_MESA_swap_control");
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
CHECK_ADDRESS(NEL_PFNGLXSWAPINTERVALMESAPROC, glXSwapIntervalMESA);
CHECK_ADDRESS(NEL_PFNGLXGETSWAPINTERVALMESAPROC, glXGetSwapIntervalMESA);
#endif
return true;
}
#if defined(NL_OS_WINDOWS)
// ***************************************************************************
bool registerWGlExtensions(CGlExtensions &ext, HDC hDC)
{
H_AUTO_OGL(registerWGlExtensions);
// Get proc address
CHECK_ADDRESS(PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB);
// Get extension string
const char *glext = nwglGetExtensionsStringARB (hDC);
if (glext == NULL)
{
nlwarning ("nwglGetExtensionsStringARB failed");
return false;
}
nldebug("3D: Available WGL Extensions:");
if (DebugLog)
{
vector<string> exts;
explode(string(glext), string(" "), exts);
for (uint i = 0; i < exts.size(); i++)
{
if (i%5==0) DebugLog->displayRaw("3D: ");
DebugLog->displayRaw(string(exts[i]+" ").c_str());
if (i%5==4) DebugLog->displayRaw("\n");
}
DebugLog->displayRaw("\n");
}
// Check for pbuffer
ext.WGLARBPBuffer = setupWGLARBPBuffer(glext);
// Check for pixel format
ext.WGLARBPixelFormat = setupWGLARBPixelFormat(glext);
// Check for swap control
ext.WGLEXTSwapControl = setupWGLEXTSwapControl(glext);
// Check for create context profile
ext.WGLARBCreateContextProfile = setupWGLARBCreateContextProfile(glext);
return true;
}
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
// ***************************************************************************
bool registerGlXExtensions(CGlExtensions &ext, Display *dpy, sint screen)
{
H_AUTO_OGL(registerGlXExtensions);
// Get extension string
const char *glext = glXQueryExtensionsString(dpy, screen);
if (glext == NULL)
{
nlwarning ("glXQueryExtensionsString failed");
return false;
}
nldebug("3D: Available GLX Extensions:");
if (DebugLog)
{
vector<string> exts;
explode(string(glext), string(" "), exts);
for (uint i = 0; i < exts.size(); i++)
{
if (i%5==0) DebugLog->displayRaw("3D: ");
DebugLog->displayRaw(string(exts[i]+" ").c_str());
if (i%5==4) DebugLog->displayRaw("\n");
}
DebugLog->displayRaw("\n");
}
// Check for pbuffer
// ext.WGLARBPBuffer= setupWGLARBPBuffer(glext);
// Check for pixel format
// ext.WGLARBPixelFormat= setupWGLARBPixelFormat(glext);
// Check for swap control
ext.GLXEXTSwapControl= setupGLXEXTSwapControl(glext);
ext.GLXSGISwapControl= setupGLXSGISwapControl(glext);
ext.GLXMESASwapControl= setupGLXMESASwapControl(glext);
return true;
}
#endif
} // NLDRIVERGL3
} // NL3D

@ -0,0 +1,376 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_OPENGL_EXTENSION_H
#define NL_OPENGL_EXTENSION_H
#include "nel/misc/types_nl.h"
#include "nel/misc/string_common.h"
#include "driver_opengl_extension_def.h"
namespace NL3D {
namespace NLDRIVERGL3 {
// ***************************************************************************
/// The extensions used by NL3D.
struct CGlExtensions
{
std::string GLVersion;
// Required extensions
bool GLCore;
bool ARBSeparateShaderObjects;
GLint MaxFragmentTextureImageUnits;
// Optional extensions
bool EXTTextureCompressionS3TC;
bool EXTTextureFilterAnisotropic;
float EXTTextureFilterAnisotropicMaximum;
bool AMDPinnedMemory;
// Required Extensions. (old)
bool ARBMultiTexture;
// WGL ARB extensions, true if supported
bool WGLARBPBuffer;
bool WGLARBPixelFormat;
bool WGLEXTSwapControl;
bool WGLARBCreateContextProfile;
// GLX extensions, true if supported
bool GLXEXTSwapControl;
bool GLXSGISwapControl;
bool GLXMESASwapControl;
public:
CGlExtensions()
{
// Fill all false by default.
GLCore = false;
ARBSeparateShaderObjects = false;
MaxFragmentTextureImageUnits = 0;
EXTTextureCompressionS3TC = false;
EXTTextureFilterAnisotropic = false;
EXTTextureFilterAnisotropicMaximum = 0.f;
AMDPinnedMemory = false;
ARBMultiTexture= false;
WGLARBPBuffer = false;
WGLARBPixelFormat = false;
WGLEXTSwapControl = false;
WGLARBCreateContextProfile = false;
GLXEXTSwapControl = false;
GLXSGISwapControl = false;
GLXMESASwapControl = false;
}
std::string toString()
{
std::string result = "OpenGL version ";
result += GLVersion;
result += "; Available extensions:";
result += "\n Core: ";
result += GLCore ? "GLCore " : "";
result += "\n Programs: ";
result += ARBSeparateShaderObjects ? "ARBSeparateShaderObjects " : "";
result += "\n Texturing: ";
result += ARBMultiTexture ? "ARBMultiTexture " : "";
result += EXTTextureCompressionS3TC ? "EXTTextureCompressionS3TC " : "";
result += EXTTextureFilterAnisotropic ? "EXTTextureFilterAnisotropic (Maximum = " + NLMISC::toString(EXTTextureFilterAnisotropicMaximum) + ") " : "";
result += "fragment texture units(*) = ";
result += NLMISC::toString(MaxFragmentTextureImageUnits);
result += "\n Buffers: ";
result += AMDPinnedMemory ? "AMDPinnedMemory " : "";
#ifdef NL_OS_WINDOWS
result += "\n WindowsGL: ";
result += WGLARBPBuffer ? "WGLARBPBuffer " : "";
result += WGLARBPixelFormat ? "WGLARBPixelFormat " : "";
result += WGLEXTSwapControl ? "WGLEXTSwapControl " : "";
result += WGLARBCreateContextProfile ? "WGLARBCreateContextProfile" : "";
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
result += "\n GLX: ";
result += GLXEXTSwapControl ? "GLXEXTSwapControl " : "";
result += GLXSGISwapControl ? "GLXSGISwapControl " : "";
result += GLXMESASwapControl ? "GLXMESASwapControl " : "";
#endif
return result;
}
};
// ***************************************************************************
#if defined(NL_OS_WINDOWS)
/// This function will test and register WGL functions before than the gl context is created
bool registerWGlExtensions(CGlExtensions &ext, HDC hDC);
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
/// This function will test and register GLX functions before than the gl context is created
bool registerGlXExtensions(CGlExtensions &ext, Display *dpy, sint screen);
#endif // NL_OS_WINDOWS
/// This function test and register the extensions for the current GL context.
bool registerGlExtensions(CGlExtensions &ext);
} // NLDRIVERGL3
} // NL3D
// ***************************************************************************
// The exported function names
/* NB: We named all like nglActiveTexture (n for NEL :)
to avoid compilation conflict with future version of gl.h
eg: gl.h Version 1.2 define glActiveTexture so we can't use it.
NB: we do it for all (EXT, NV, ARB extension) even it should be useful only for ARB ones.
*/
// Core 3.30
extern PFNGLGETSTRINGIPROC nglGetStringi;
extern PFNGLCLEARBUFFERIVPROC nglClearBufferiv;
extern PFNGLCLEARBUFFERUIVPROC nglClearBufferuiv;
extern PFNGLCLEARBUFFERFVPROC nglClearBufferfv;
extern PFNGLCLEARBUFFERFIPROC nglClearBufferfi;
extern PFNGLATTACHSHADERPROC nglAttachShader;
extern PFNGLCOMPILESHADERPROC nglCompileShader;
extern PFNGLCREATEPROGRAMPROC nglCreateProgram;
extern PFNGLCREATESHADERPROC nglCreateShader;
extern PFNGLDELETEPROGRAMPROC nglDeleteProgram;
extern PFNGLDELETESHADERPROC nglDeleteShader;
extern PFNGLDETACHSHADERPROC nglDetachShader;
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC nglDisableVertexAttribArray;
extern PFNGLENABLEVERTEXATTRIBARRAYPROC nglEnableVertexAttribArray;
extern PFNGLGETATTACHEDSHADERSPROC nglGetAttachedShaders;
extern PFNGLGETPROGRAMIVPROC nglGetProgramiv;
extern PFNGLGETPROGRAMINFOLOGPROC nglGetProgramInfoLog;
extern PFNGLGETSHADERIVPROC nglGetShaderiv;
extern PFNGLGETSHADERINFOLOGPROC nglGetShaderInfoLog;
extern PFNGLGETUNIFORMLOCATIONPROC nglGetUniformLocation;
extern PFNGLISPROGRAMPROC nglIsProgram;
extern PFNGLISSHADERPROC nglIsShader;
extern PFNGLLINKPROGRAMPROC nglLinkProgram;
extern PFNGLSHADERSOURCEPROC nglShaderSource;
extern PFNGLUSEPROGRAMPROC nglUseProgram;
extern PFNGLVALIDATEPROGRAMPROC nglValidateProgram;
/*extern PFNGLUNIFORM1FPROC nglUniform1f;
extern PFNGLUNIFORM2FPROC nglUniform2f;
extern PFNGLUNIFORM3FPROC nglUniform3f;
extern PFNGLUNIFORM4FPROC nglUniform4f;
extern PFNGLUNIFORM1IPROC nglUniform1i;
extern PFNGLUNIFORM2IPROC nglUniform2i;
extern PFNGLUNIFORM3IPROC nglUniform3i;
extern PFNGLUNIFORM4IPROC nglUniform4i;
extern PFNGLUNIFORM1FVPROC nglUniform1fv;
extern PFNGLUNIFORM2FVPROC nglUniform2fv;
extern PFNGLUNIFORM3FVPROC nglUniform3fv;
extern PFNGLUNIFORM4FVPROC nglUniform4fv;
extern PFNGLUNIFORM1IVPROC nglUniform1iv;
extern PFNGLUNIFORM2IVPROC nglUniform2iv;
extern PFNGLUNIFORM3IVPROC nglUniform3iv;
extern PFNGLUNIFORM4IVPROC nglUniform4iv;
extern PFNGLUNIFORMMATRIX2FVPROC nglUniformMatrix2fv;
extern PFNGLUNIFORMMATRIX3FVPROC nglUniformMatrix3fv;
extern PFNGLUNIFORMMATRIX4FVPROC nglUniformMatrix4fv;*/
extern PFNGLVERTEXATTRIBPOINTERPROC nglVertexAttribPointer;
extern PFNGLBINDBUFFERPROC nglBindBuffer;
extern PFNGLDELETEBUFFERSPROC nglDeleteBuffers;
extern PFNGLGENBUFFERSPROC nglGenBuffers;
extern PFNGLISBUFFERPROC nglIsBuffer;
extern PFNGLBUFFERDATAPROC nglBufferData;
extern PFNGLBUFFERSUBDATAPROC nglBufferSubData;
extern PFNGLGETBUFFERSUBDATAPROC nglGetBufferSubData;
extern PFNGLMAPBUFFERPROC nglMapBuffer;
extern PFNGLUNMAPBUFFERPROC nglUnmapBuffer;
extern PFNGLGETBUFFERPARAMETERIVPROC nglGetBufferParameteriv;
extern PFNGLGETBUFFERPOINTERVPROC nglGetBufferPointerv;
extern PFNGLMAPBUFFERRANGEPROC nglMapBufferRange;
extern PFNGLFLUSHMAPPEDBUFFERRANGEPROC nglFlushMappedBufferRange;
extern PFNGLGENQUERIESPROC nglGenQueries;
extern PFNGLDELETEQUERIESPROC nglDeleteQueries;
extern PFNGLISQUERYPROC nglIsQuery;
extern PFNGLBEGINQUERYPROC nglBeginQuery;
extern PFNGLENDQUERYPROC nglEndQuery;
extern PFNGLGETQUERYIVPROC nglGetQueryiv;
extern PFNGLGETQUERYOBJECTIVPROC nglGetQueryObjectiv;
extern PFNGLGETQUERYOBJECTUIVPROC nglGetQueryObjectuiv;
/*extern PFNGLISRENDERBUFFERPROC nglIsRenderbuffer;
extern PFNGLBINDRENDERBUFFERPROC nglBindRenderbuffer;
extern PFNGLDELETERENDERBUFFERSPROC nglDeleteRenderbuffers;
extern PFNGLGENRENDERBUFFERSPROC nglGenRenderbuffers;
extern PFNGLRENDERBUFFERSTORAGEPROC nglRenderbufferStorage;
extern PFNGLGETRENDERBUFFERPARAMETERIVPROC nglGetRenderbufferParameteriv;
extern PFNGLISFRAMEBUFFERPROC nglIsFramebuffer;
extern PFNGLBINDFRAMEBUFFERPROC nglBindFramebuffer;
extern PFNGLDELETEFRAMEBUFFERSPROC nglDeleteFramebuffers;
extern PFNGLGENFRAMEBUFFERSPROC nglGenFramebuffers;
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC nglCheckFramebufferStatus;
extern PFNGLFRAMEBUFFERTEXTURE1DPROC nglFramebufferTexture1D;
extern PFNGLFRAMEBUFFERTEXTURE2DPROC nglFramebufferTexture2D;
extern PFNGLFRAMEBUFFERTEXTURE3DPROC nglFramebufferTexture3D;
extern PFNGLFRAMEBUFFERRENDERBUFFERPROC nglFramebufferRenderbuffer;
extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC nglGetFramebufferAttachmentParameteriv;
extern PFNGLGENERATEMIPMAPPROC nglGenerateMipmap;
extern PFNGLBLITFRAMEBUFFERPROC nglBlitFramebuffer;
extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC nglRenderbufferStorageMultisample;
extern PFNGLFRAMEBUFFERTEXTURELAYERPROC nglFramebufferTextureLayer;*/
extern PFNGLACTIVETEXTUREPROC nglActiveTexture;
extern PFNGLCOMPRESSEDTEXIMAGE3DPROC nglCompressedTexImage3D;
extern PFNGLCOMPRESSEDTEXIMAGE2DPROC nglCompressedTexImage2D;
extern PFNGLCOMPRESSEDTEXIMAGE1DPROC nglCompressedTexImage1D;
extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC nglCompressedTexSubImage3D;
extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC nglCompressedTexSubImage2D;
extern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC nglCompressedTexSubImage1D;
extern PFNGLGETCOMPRESSEDTEXIMAGEPROC nglGetCompressedTexImage;
extern PFNGLBLENDCOLORPROC nglBlendColor;
extern PFNGLFENCESYNCPROC nglFenceSync;
extern PFNGLISSYNCPROC nglIsSync;
extern PFNGLDELETESYNCPROC nglDeleteSync;
extern PFNGLCLIENTWAITSYNCPROC nglClientWaitSync;
extern PFNGLWAITSYNCPROC nglWaitSync;
extern PFNGLGETINTEGER64VPROC nglGetInteger64v;
extern PFNGLGETSYNCIVPROC nglGetSynciv;
// GL_ARB_separate_shader_objects
extern PFNGLUSEPROGRAMSTAGESPROC nglUseProgramStages;
extern PFNGLACTIVESHADERPROGRAMPROC nglActiveShaderProgram;
extern PFNGLCREATESHADERPROGRAMVPROC nglCreateShaderProgramv;
extern PFNGLBINDPROGRAMPIPELINEPROC nglBindProgramPipeline;
extern PFNGLDELETEPROGRAMPIPELINESPROC nglDeleteProgramPipelines;
extern PFNGLGENPROGRAMPIPELINESPROC nglGenProgramPipelines;
extern PFNGLISPROGRAMPIPELINEPROC nglIsProgramPipeline;
extern PFNGLGETPROGRAMPIPELINEIVPROC nglGetProgramPipelineiv;
extern PFNGLPROGRAMUNIFORM1IPROC nglProgramUniform1i;
extern PFNGLPROGRAMUNIFORM1IVPROC nglProgramUniform1iv;
extern PFNGLPROGRAMUNIFORM1FPROC nglProgramUniform1f;
extern PFNGLPROGRAMUNIFORM1FVPROC nglProgramUniform1fv;
extern PFNGLPROGRAMUNIFORM1DPROC nglProgramUniform1d;
extern PFNGLPROGRAMUNIFORM1DVPROC nglProgramUniform1dv;
extern PFNGLPROGRAMUNIFORM1UIPROC nglProgramUniform1ui;
extern PFNGLPROGRAMUNIFORM1UIVPROC nglProgramUniform1uiv;
extern PFNGLPROGRAMUNIFORM2IPROC nglProgramUniform2i;
extern PFNGLPROGRAMUNIFORM2IVPROC nglProgramUniform2iv;
extern PFNGLPROGRAMUNIFORM2FPROC nglProgramUniform2f;
extern PFNGLPROGRAMUNIFORM2FVPROC nglProgramUniform2fv;
extern PFNGLPROGRAMUNIFORM2DPROC nglProgramUniform2d;
extern PFNGLPROGRAMUNIFORM2DVPROC nglProgramUniform2dv;
extern PFNGLPROGRAMUNIFORM2UIPROC nglProgramUniform2ui;
extern PFNGLPROGRAMUNIFORM2UIVPROC nglProgramUniform2uiv;
extern PFNGLPROGRAMUNIFORM3IPROC nglProgramUniform3i;
extern PFNGLPROGRAMUNIFORM3IVPROC nglProgramUniform3iv;
extern PFNGLPROGRAMUNIFORM3FPROC nglProgramUniform3f;
extern PFNGLPROGRAMUNIFORM3FVPROC nglProgramUniform3fv;
extern PFNGLPROGRAMUNIFORM3DPROC nglProgramUniform3d;
extern PFNGLPROGRAMUNIFORM3DVPROC nglProgramUniform3dv;
extern PFNGLPROGRAMUNIFORM3UIPROC nglProgramUniform3ui;
extern PFNGLPROGRAMUNIFORM3UIVPROC nglProgramUniform3uiv;
extern PFNGLPROGRAMUNIFORM4IPROC nglProgramUniform4i;
extern PFNGLPROGRAMUNIFORM4IVPROC nglProgramUniform4iv;
extern PFNGLPROGRAMUNIFORM4FPROC nglProgramUniform4f;
extern PFNGLPROGRAMUNIFORM4FVPROC nglProgramUniform4fv;
extern PFNGLPROGRAMUNIFORM4DPROC nglProgramUniform4d;
extern PFNGLPROGRAMUNIFORM4DVPROC nglProgramUniform4dv;
extern PFNGLPROGRAMUNIFORM4UIPROC nglProgramUniform4ui;
extern PFNGLPROGRAMUNIFORM4UIVPROC nglProgramUniform4uiv;
extern PFNGLPROGRAMUNIFORMMATRIX2FVPROC nglProgramUniformMatrix2fv;
extern PFNGLPROGRAMUNIFORMMATRIX3FVPROC nglProgramUniformMatrix3fv;
extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC nglProgramUniformMatrix4fv;
extern PFNGLPROGRAMUNIFORMMATRIX2DVPROC nglProgramUniformMatrix2dv;
extern PFNGLPROGRAMUNIFORMMATRIX3DVPROC nglProgramUniformMatrix3dv;
extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC nglProgramUniformMatrix4dv;
extern PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC nglProgramUniformMatrix2x3fv;
extern PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC nglProgramUniformMatrix3x2fv;
extern PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC nglProgramUniformMatrix2x4fv;
extern PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC nglProgramUniformMatrix4x2fv;
extern PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC nglProgramUniformMatrix3x4fv;
extern PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC nglProgramUniformMatrix4x3fv;
extern PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC nglProgramUniformMatrix2x3dv;
extern PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC nglProgramUniformMatrix3x2dv;
extern PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC nglProgramUniformMatrix2x4dv;
extern PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC nglProgramUniformMatrix4x2dv;
extern PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC nglProgramUniformMatrix3x4dv;
extern PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC nglProgramUniformMatrix4x3dv;
extern PFNGLVALIDATEPROGRAMPIPELINEPROC nglValidateProgramPipeline;
extern PFNGLGETPROGRAMPIPELINEINFOLOGPROC nglGetProgramPipelineInfoLog;
#ifdef NL_OS_WINDOWS
// Pbuffer extension
//==================
extern PFNWGLCREATEPBUFFERARBPROC nwglCreatePbufferARB;
extern PFNWGLGETPBUFFERDCARBPROC nwglGetPbufferDCARB;
extern PFNWGLRELEASEPBUFFERDCARBPROC nwglReleasePbufferDCARB;
extern PFNWGLDESTROYPBUFFERARBPROC nwglDestroyPbufferARB;
extern PFNWGLQUERYPBUFFERARBPROC nwglQueryPbufferARB;
// Get Pixel format extension
//===========================
extern PFNWGLGETPIXELFORMATATTRIBIVARBPROC nwglGetPixelFormatAttribivARB;
extern PFNWGLGETPIXELFORMATATTRIBFVARBPROC nwglGetPixelFormatAttribfvARB;
extern PFNWGLCHOOSEPIXELFORMATARBPROC nwglChoosePixelFormatARB;
// Swap control extension
//===========================
extern PFNWGLSWAPINTERVALEXTPROC nwglSwapIntervalEXT;
extern PFNWGLGETSWAPINTERVALEXTPROC nwglGetSwapIntervalEXT;
// WGL_ARB_extensions_string
extern PFNWGLGETEXTENSIONSSTRINGARBPROC nwglGetExtensionsStringARB;
// WGL_ARB_create_context_profile
extern PFNWGLCREATECONTEXTATTRIBSARBPROC nwglCreateContextAttribsARB;
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
// Swap control extensions
//===========================
extern NEL_PFNGLXSWAPINTERVALEXTPROC nglXSwapIntervalEXT;
extern PFNGLXSWAPINTERVALSGIPROC nglXSwapIntervalSGI;
extern NEL_PFNGLXSWAPINTERVALMESAPROC nglXSwapIntervalMESA;
extern NEL_PFNGLXGETSWAPINTERVALMESAPROC nglXGetSwapIntervalMESA;
#endif
#endif // NL_OPENGL_EXTENSION_H

@ -0,0 +1,78 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_OPENGL_EXTENSION_DEF_H
#define NL_OPENGL_EXTENSION_DEF_H
#include "nel/misc/types_nl.h"
#ifdef __cplusplus
extern "C" {
#endif
// ***************************************************************************
// ***************************************************************************
// The NEL Functions Typedefs.
// Must do it for compatibilities with futures version of gl.h
// eg: version 1.2 does not define PFNGLACTIVETEXTUREARBPROC. Hence, do it now, with our special name
// ***************************************************************************
// ***************************************************************************
#define WGL_COVERAGE_SAMPLES_NV 0x2042
#define WGL_COLOR_SAMPLES_NV 0x20B9
#if defined(NL_OS_MAC)
// Mac GL extensions
#elif defined(NL_OS_UNIX)
// GLX extensions
#ifndef NL_GLX_EXT_swap_control
#define NL_GLX_EXT_swap_control 1
#ifndef GLX_EXT_swap_control
#define GLX_SWAP_INTERVAL_EXT 0x20F1
#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2
#endif
typedef GLint (APIENTRY * NEL_PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, GLint interval);
#endif // NL_GLX_EXT_swap_control
#ifndef NL_GLX_MESA_swap_control
#define NL_GLX_MESA_swap_control 1
typedef GLint (APIENTRY * NEL_PFNGLXSWAPINTERVALMESAPROC) (GLuint interval);
typedef GLint (APIENTRY * NEL_PFNGLXGETSWAPINTERVALMESAPROC) ();
#endif // NL_GLX_MESA_swap_control
#ifndef NL_GLX_NV_vertex_array_range
#define NL_GLX_NV_vertex_array_range 1
typedef void* (APIENTRY * NEL_PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
typedef void (APIENTRY * NEL_PFNGLXFREEMEMORYNVPROC) (void *pointer);
#endif // NL_GLX_NV_vertex_array_range
#endif // NL_OS_MAC
#ifdef __cplusplus
}
#endif
#endif // NL_OPENGL_EXTENSION_DEF_H

@ -0,0 +1,863 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include "driver_opengl.h"
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
# include <X11/Xatom.h>
# ifdef HAVE_XRENDER
# include <X11/extensions/Xrender.h>
# endif // HAVE_XRENDER
# ifdef HAVE_XCURSOR
# include <X11/Xcursor/Xcursor.h>
# endif // HAVE_XCURSOR
#endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
#include "nel/3d/u_driver.h"
#include "nel/misc/file.h"
using namespace std;
using namespace NLMISC;
namespace NL3D {
namespace NLDRIVERGL3 {
// *************************************************************************************
CDriverGL3::CCursor::CCursor() : ColorDepth(CDriverGL3::ColorDepth32),
OrigHeight(32),
HotspotScale(1.f),
HotspotOffsetX(0),
HotspotOffsetY(0),
HotSpotX(0),
HotSpotY(0),
Cursor(EmptyCursor),
Col(CRGBA::White),
Rot(0)
{
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
Dpy = NULL;
#endif
}
// *************************************************************************************
CDriverGL3::CCursor::~CCursor()
{
reset();
}
// *************************************************************************************
void CDriverGL3::CCursor::reset()
{
if (Cursor != EmptyCursor)
{
#ifdef NL_OS_WINDOWS
DestroyIcon(Cursor);
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
XFreeCursor(Dpy, Cursor);
XSync(Dpy, False);
#endif
}
}
// *************************************************************************************
CDriverGL3::CCursor& CDriverGL3::CCursor::operator= (const CDriverGL3::CCursor& from)
{
if (&from == this)
return *this;
Src = from.Src; // requires more than a surface copy
OrigHeight = from.OrigHeight;
HotspotScale = from.HotspotScale;
HotspotOffsetX = from.HotspotOffsetX;
HotspotOffsetY = from.HotspotOffsetY;
HotSpotX = from.HotSpotX;
HotSpotY = from.HotSpotY;
Cursor = from.Cursor;
Col = from.Col;
Rot = from.Rot;
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
Dpy = from.Dpy;
#endif
return *this;
}
// *************************************************************************************
bool CDriverGL3::isAlphaBlendedCursorSupported()
{
if (!_AlphaBlendedCursorSupportRetrieved)
{
#ifdef NL_OS_WINDOWS
// Support starts with windows 2000 (not only from XP as seen in most docs)
// NB : Additionnaly, could query D3D caps to know if
// color hardware cursor is supported, not only emulated,
// but can't be sure that using the win32 api 'SetCursor' uses the same resources
// So far, seems to be supported on any modern card used by the game anyway ...
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx(&osvi))
{
_AlphaBlendedCursorSupported = (osvi.dwMajorVersion >= 5);
}
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
_AlphaBlendedCursorSupported = false;
#ifdef HAVE_XCURSOR
if (!_AlphaBlendedCursorSupported && XcursorSupportsARGB(_dpy))
_AlphaBlendedCursorSupported = true;
#endif // HAVE_XCURSOR
if (!_AlphaBlendedCursorSupported && _xrender_version > 0)
_AlphaBlendedCursorSupported = true;
#endif
_AlphaBlendedCursorSupportRetrieved = true;
}
return _AlphaBlendedCursorSupported;
}
// *************************************************************************************
void CDriverGL3::addCursor(const std::string &name, const NLMISC::CBitmap &cursorBitmap)
{
if (!isAlphaBlendedCursorSupported()) return;
nlassert(cursorBitmap.getWidth() != 0);
nlassert(cursorBitmap.getHeight() != 0);
// find used part base on alpha, to avoid too much shrinking
const CRGBA *pixels = (const CRGBA *) &cursorBitmap.getPixels()[0];
uint minX, maxX, minY, maxY;
uint width = cursorBitmap.getWidth();
uint height = cursorBitmap.getHeight();
//
minX = 0;
for (uint x = 0; x < width; ++x)
{
bool stop = false;
minX = x;
for (uint y = 0; y < height; ++y)
{
if (pixels[x + y * width].A != 0)
{
stop = true;
break;
}
}
if (stop) break;
}
//
maxX = width - 1;
for (sint x = width - 1; x >= 0; --x)
{
bool stop = false;
maxX = (uint) x;
for (uint y = 0; y < height; ++y)
{
if (pixels[x + y * width].A != 0)
{
stop = true;
break;
}
}
if (stop) break;
}
//
minY = 0;
for (uint y = 0; y < height; ++y)
{
bool stop = false;
minY = y;
for (uint x = 0; x < width; ++x)
{
if (pixels[x + y * width].A != 0)
{
stop = true;
break;
}
}
if (stop) break;
}
//
maxY = height - 1;
for (sint y = height - 1; y >= 0; --y)
{
bool stop = false;
maxY = (uint) y;
for (uint x = 0; x < width; ++x)
{
if (pixels[x + y * width].A != 0)
{
stop = true;
break;
}
}
if (stop) break;
}
//
CCursor &curs = _Cursors[name];
curs = CCursor(); // erase possible previous cursor
uint destWidth = 32, destHeight = 32;
getBestCursorSize(width, height, destWidth, destHeight);
// build a square bitmap
uint tmpSize = std::max(maxX - minX + 1, maxY - minY + 1);
curs.Src.resize(tmpSize, tmpSize);
// blit at top left corner
curs.Src.blit(cursorBitmap, minX, minY, maxX - minX + 1, maxY - minY + 1, 0, 0);
curs.OrigHeight = cursorBitmap.getHeight();
curs.HotspotOffsetX = minX;
curs.HotspotOffsetY = minY;
//
curs.HotspotScale = _CursorScale;
clamp(curs.HotspotScale, 0.f, 1.f);
// first resampling, same for all cursors
tmpSize = (uint) (tmpSize * curs.HotspotScale);
if (tmpSize == 0) tmpSize = 1;
if (curs.HotspotScale < 1.f)
{
curs.Src.resample(tmpSize, tmpSize);
}
// shrink if necessary
if (tmpSize > destWidth || tmpSize > destHeight) // need to shrink ?
{
// constraint proportions
curs.HotspotScale *= std::min(float(destWidth) / tmpSize, float(destHeight) / tmpSize);
curs.Src.resample(destWidth, destHeight);
}
else
{
CBitmap final;
final.resize(destWidth, destHeight);
final.blit(&curs.Src, 0, 0);
curs.Src.swap(final);
}
if (name == _CurrName)
{
updateCursor();
}
}
// *************************************************************************************
void CDriverGL3::createCursors()
{
#ifdef NL_OS_WINDOWS
_DefaultCursor = LoadCursor(NULL, IDC_ARROW);
_BlankCursor = NULL;
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
_DefaultCursor = None;
if (_dpy && _win && _BlankCursor == EmptyCursor)
{
// create blank cursor
char bm_no_data[] = { 0,0,0,0,0,0,0,0 };
Pixmap pixmap_no_data = XCreateBitmapFromData (_dpy, _win, bm_no_data, 8, 8);
XColor black;
memset(&black, 0, sizeof (XColor));
black.flags = DoRed | DoGreen | DoBlue;
_BlankCursor = XCreatePixmapCursor (_dpy, pixmap_no_data, pixmap_no_data, &black, &black, 0, 0);
XFreePixmap(_dpy, pixmap_no_data);
}
#endif
}
// *************************************************************************************
void CDriverGL3::releaseCursors()
{
#ifdef NL_OS_WINDOWS
SetClassLongPtr(_win, GCLP_HCURSOR, 0);
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
XUndefineCursor(_dpy, _win);
XFreeCursor(_dpy, _BlankCursor);
#endif
_Cursors.clear();
}
// *************************************************************************************
void CDriverGL3::updateCursor(bool forceRebuild)
{
setCursor(_CurrName, _CurrCol, _CurrRot, _CurrHotSpotX, _CurrHotSpotY, forceRebuild);
}
// *************************************************************************************
void CDriverGL3::setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY, bool forceRebuild)
{
// don't update cursor if it's hidden or if custom cursors are not suppported
if (!isAlphaBlendedCursorSupported() || _CurrName == "none") return;
_CurrName = name;
_CurrCol = col;
_CurrRot = rot;
_CurrHotSpotX = hotSpotX;
_CurrHotSpotY = hotSpotY;
// cursor has to be changed next time
if (_CurrName.empty()) return;
if (rot > 3) rot = 3; // same than 'CViewRenderer::drawRotFlipBitmapTiled
TCursorMap::iterator it = _Cursors.find(name);
nlCursor cursorHandle = _DefaultCursor;
if (it != _Cursors.end())
{
// Update cursor if modified or not already built
CCursor &curs = it->second;
hotSpotX = (sint) (curs.HotspotScale * (hotSpotX - curs.HotspotOffsetX));
hotSpotY = (sint) (curs.HotspotScale * ((curs.OrigHeight - hotSpotY) - curs.HotspotOffsetY));
if (curs.Cursor == EmptyCursor ||
curs.HotSpotX != hotSpotX ||
curs.HotSpotY != hotSpotY ||
curs.Col != col ||
curs.Rot != rot ||
curs.ColorDepth != _ColorDepth ||
forceRebuild
)
{
curs.reset();
curs.Cursor = buildCursor(curs.Src, col, rot, hotSpotX, hotSpotY);
curs.Col = col;
curs.Rot = rot;
curs.HotSpotX = hotSpotX;
curs.HotSpotY = hotSpotY;
curs.ColorDepth = _ColorDepth;
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
curs.Dpy = _dpy;
#endif
}
cursorHandle = curs.Cursor ? curs.Cursor : _DefaultCursor;
}
if (isSystemCursorInClientArea() || isSystemCursorCaptured() || forceRebuild)
{
// if (CInputHandlerManager::getInstance()->hasFocus())
#ifdef NL_OS_WINDOWS
{
::SetCursor(cursorHandle);
SetClassLongPtr(_win, GCLP_HCURSOR, (LONG_PTR) cursorHandle); // set default mouse icon to the last one
}
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
if (cursorHandle == _DefaultCursor)
{
XUndefineCursor(_dpy, _win);
}
else
{
XDefineCursor(_dpy, _win, cursorHandle);
}
#endif
}
}
// *************************************************************************************
void CDriverGL3::setCursorScale(float scale)
{
_CursorScale = scale;
}
// *************************************************************************************
nlCursor CDriverGL3::buildCursor(const CBitmap &src, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY)
{
nlassert(isAlphaBlendedCursorSupported());
uint mouseW = 32, mouseH = 32;
getBestCursorSize(src.getWidth(), src.getHeight(), mouseW, mouseH);
CBitmap rotSrc = src;
if (rot > 3) rot = 3; // mimic behavior of 'CViewRenderer::drawRotFlipBitmapTiled' (why not rot & 3 ??? ...)
switch(rot)
{
case 0: break;
case 1: rotSrc.rot90CW(); break;
case 2: rotSrc.rot90CW(); rotSrc.rot90CW(); break;
case 3: rotSrc.rot90CCW(); break;
}
// create a cursor from bitmap
nlCursor result = EmptyCursor;
convertBitmapToCursor(rotSrc, result, mouseW, mouseH, _ColorDepth == ColorDepth16 ? 16:32, col, hotSpotX, hotSpotY);
return result;
}
// *************************************************************************************
void CDriverGL3::setSystemArrow()
{
H_AUTO_OGL(CDriverGL3_setSystemArrow);
#ifdef NL_OS_WINDOWS
if (isSystemCursorInClientArea() || isSystemCursorCaptured())
{
SetCursor(_DefaultCursor);
}
// set default mouse icon to the default one
SetClassLongPtr(_win, GCLP_HCURSOR, (LONG_PTR) _DefaultCursor);
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
XUndefineCursor(_dpy, _win);
#endif
}
// ***************************************************************************
void CDriverGL3::showCursor(bool b)
{
H_AUTO_OGL(CDriverGL3_showCursor);
if (_win == EmptyWindow)
return;
#ifdef NL_OS_WINDOWS
if (b)
{
// update current hardware icon to avoid to have the plain arrow
updateCursor(true);
while (ShowCursor(b) < 0)
;
}
else
{
while (ShowCursor(b) >= 0)
;
}
#elif defined(NL_OS_MAC)
// Mac OS manages a show/hide counter for the cursor, so hiding the cursor
// twice requires two calls to "show" to make the cursor visible again.
// Since other platforms seem to not do this, the functionality is masked here
// by only calling hide if the cursor is visible and only calling show if
// the cursor was hidden.
CGDisplayErr error = kCGErrorSuccess;
static bool visible = true;
if (b && !visible)
{
error = CGDisplayShowCursor(kCGDirectMainDisplay);
visible = true;
}
else if (!b && visible)
{
error = CGDisplayHideCursor(kCGDirectMainDisplay);
visible = false;
}
if (error != kCGErrorSuccess)
nlerror("cannot show / hide cursor");
#elif defined (NL_OS_UNIX)
if (!b)
{
XDefineCursor(_dpy, _win, _BlankCursor);
_CurrName = "none";
}
else
{
_CurrName = "";
}
// update current hardware icon to avoid to have the plain arrow
updateCursor(true);
#endif // NL_OS_UNIX
}
// ***************************************************************************
void CDriverGL3::setMousePos(float x, float y)
{
H_AUTO_OGL(CDriverGL3_setMousePos)
if (_win == EmptyWindow)
return;
sint x1 = (sint)((float)_CurrentMode.Width*x);
sint y1 = (sint)((float)_CurrentMode.Height*(1.0f-y));
#ifdef NL_OS_WINDOWS
// NeL window coordinate to MSWindows coordinates
POINT pt;
pt.x = x1;
pt.y = y1;
ClientToScreen (_win, &pt);
SetCursorPos(pt.x, pt.y);
#elif defined(NL_OS_MAC)
// CG wants absolute coordinates related to first screen's top left
// get the first screen's (conaints menubar) rect (this is not mainScreen)
NSRect firstScreenRect = [[[NSScreen screens] objectAtIndex:0] frame];
// get the rect (position, size) of the window
NSRect windowRect;
if ([containerView() isInFullScreenMode])
windowRect = [[[containerView() window] screen] frame];
else
windowRect = [[containerView() window] frame];
// get the view's rect for height and width
NSRect viewRect = [containerView() frame];
// set the cursor position
CGDisplayErr error = CGDisplayMoveCursorToPoint(
kCGDirectMainDisplay, CGPointMake(
windowRect.origin.x + (viewRect.size.width * x),
firstScreenRect.size.height - windowRect.origin.y -
viewRect.size.height + ((1.0 - y) * viewRect.size.height)));
if (error != kCGErrorSuccess)
nlerror("cannot set mouse position");
#elif defined (NL_OS_UNIX)
XWarpPointer (_dpy, None, _win, None, None, None, None, x1, y1);
#endif // NL_OS_UNIX
}
// ***************************************************************************
void CDriverGL3::setCapture (bool b)
{
H_AUTO_OGL(CDriverGL3_setCapture);
#ifdef NL_OS_WINDOWS
if (b && isSystemCursorInClientArea() && !isSystemCursorCaptured())
{
SetCapture(_win);
}
else if (!b && isSystemCursorCaptured())
{
// if hardware mouse and not in client area, then force to update its aspect by updating its pos
if (!isSystemCursorInClientArea())
{
// force update
showCursor(true);
}
ReleaseCapture();
}
#elif defined(NL_OS_MAC)
// no need to capture
_MouseCaptured = b;
#elif defined (NL_OS_UNIX)
if (b /* && isSystemCursorInClientArea() && !isSystemCursorCaptured()*/) // capture the cursor.
{
// capture the cursor
XGrabPointer(_dpy, _win, True, 0, GrabModeAsync, GrabModeAsync, _win, None, CurrentTime);
_MouseCaptured = true;
}
else if (!b/* && isSystemCursorCaptured()*/)
{
// release the cursor
XUngrabPointer(_dpy, CurrentTime);
_MouseCaptured = false;
}
#endif // NL_OS_UNIX
}
// ***************************************************************************
bool CDriverGL3::isSystemCursorInClientArea()
{
if (!_CurrentMode.Windowed)
{
#ifdef NL_OS_WINDOWS
return IsWindowVisible(_win) != FALSE;
#endif
}
else
{
#ifdef NL_OS_WINDOWS
POINT cursPos;
// the mouse should be in the client area of the window
if (!GetCursorPos(&cursPos))
{
return false;
}
HWND wnd = WindowFromPoint(cursPos);
if (wnd != _win)
{
return false; // not the same window
}
// want that the mouse be in the client area
RECT clientRect;
if (!GetClientRect(_win, &clientRect))
{
return false;
}
POINT tl, br;
tl.x = clientRect.left;
tl.y = clientRect.top;
br.x = clientRect.right;
br.y = clientRect.bottom;
if (!ClientToScreen(_win, &tl))
{
return false;
}
if (!ClientToScreen(_win, &br))
{
return false;
}
if ((cursPos.x < tl.x) || (cursPos.x >= br.x) || (cursPos.y < tl.y) || (cursPos.y >= br.y))
{
return false;
}
#endif
}
return true;
}
// ***************************************************************************
bool CDriverGL3::isSystemCursorCaptured()
{
H_AUTO_OGL(CDriverGL3_isSystemCursorCaptured);
#ifdef NL_OS_WINDOWS
return GetCapture() == _win;
#else
return _MouseCaptured;
#endif
}
bool CDriverGL3::getBestCursorSize(uint srcWidth, uint srcHeight, uint &dstWidth, uint &dstHeight)
{
#ifdef NL_OS_WINDOWS
// Windows provides default size for cursors
dstWidth = (uint)GetSystemMetrics(SM_CXCURSOR);
dstHeight = (uint)GetSystemMetrics(SM_CYCURSOR);
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
Status status = XQueryBestCursor(_dpy, _win, srcWidth, srcHeight, &dstWidth, &dstHeight);
if (!status)
{
nlwarning("XQueryBestCursor failed");
}
#endif
return true;
}
bool CDriverGL3::convertBitmapToCursor(const NLMISC::CBitmap &bitmap, nlCursor &cursor, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col, sint hotSpotX, sint hotSpotY)
{
#if defined(NL_OS_WINDOWS)
return convertBitmapToIcon(bitmap, cursor, iconWidth, iconHeight, iconDepth, col, hotSpotX, hotSpotY, true);
#elif defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
CBitmap src = bitmap;
// resample bitmap if necessary
if (src.getWidth() != iconWidth || src.getHeight() != iconHeight)
{
src.resample(iconWidth, iconHeight);
}
CBitmap colorBm;
colorBm.resize(iconWidth, iconHeight, CBitmap::RGBA);
const CRGBA *srcColorPtr = (CRGBA *) &(src.getPixels()[0]);
const CRGBA *srcColorPtrLast = srcColorPtr + (iconWidth * iconHeight);
CRGBA *destColorPtr = (CRGBA *) &(colorBm.getPixels()[0]);
do
{
// colorize icon
destColorPtr->modulateFromColor(*srcColorPtr, col);
// X11 wants BGRA pixels : swap red and blue channels
std::swap(destColorPtr->R, destColorPtr->B);
// premultiplied alpha
if (destColorPtr->A < 255)
{
destColorPtr->R = (destColorPtr->R * destColorPtr->A) / 255;
destColorPtr->G = (destColorPtr->G * destColorPtr->A) / 255;
destColorPtr->B = (destColorPtr->B * destColorPtr->A) / 255;
}
++ srcColorPtr;
++ destColorPtr;
}
while (srcColorPtr != srcColorPtrLast);
#ifdef HAVE_XCURSOR
if (XcursorSupportsARGB(_dpy))
{
XcursorImage *image = XcursorImageCreate(iconWidth, iconHeight);
if (!image)
{
nlwarning("Failed to create a XcusorImage with size %ux%u", iconWidth, iconHeight);
}
else
{
image->xhot = (uint)hotSpotX;
image->yhot = (uint)hotSpotY;
memcpy(image->pixels, &colorBm.getPixels(0)[0], colorBm.getSize()*4);
cursor = XcursorImageLoadCursor(_dpy, image);
XcursorImageDestroy(image);
}
}
#endif // HAVE_XCURSOR
#ifdef HAVE_XRENDER
if (_xrender_version > 0)
{
// use malloc() because X will free() data itself
CRGBA *src32 = (CRGBA*)malloc(colorBm.getSize()*4);
memcpy(src32, &colorBm.getPixels(0)[0], colorBm.getSize()*4);
uint size = iconWidth * iconHeight;
sint screen = DefaultScreen(_dpy);
Visual *visual = DefaultVisual(_dpy, screen);
if (!visual)
{
nlwarning("Failed to get a default visual for screen %d", screen);
return false;
}
// Create the icon image
XImage* image = XCreateImage(_dpy, visual, 32, ZPixmap, 0, (char*)src32, iconWidth, iconHeight, 32, 0);
if (!image)
{
nlwarning("Failed to set the window's icon");
return false;
}
// Create the icon pixmap
Pixmap pixmap = XCreatePixmap(_dpy, _win, iconWidth, iconHeight, 32 /* defDepth */);
if (!pixmap)
{
nlwarning("Failed to create a pixmap %ux%ux%d", iconWidth, iconHeight, 32);
return false;
}
// Create the icon graphic contest
GC gc = XCreateGC(_dpy, pixmap, 0, NULL);
if (!gc)
{
nlwarning("Failed to create a GC");
return false;
}
sint res = XPutImage(_dpy, pixmap, gc, image, 0, 0, 0, 0, iconWidth, iconHeight);
if (res)
{
nlwarning("XPutImage failed with code %d", res);
}
if (!XFreeGC(_dpy, gc))
{
nlwarning("XFreeGC failed");
}
if (image->data)
{
free(image->data);
image->data = NULL;
}
XDestroyImage(image);
XRenderPictFormat *format = XRenderFindStandardFormat(_dpy, PictStandardARGB32);
if (!format)
{
nlwarning("Failed to find a standard format");
return false;
}
Picture picture = XRenderCreatePicture(_dpy, pixmap, format, 0, 0);
if (!picture)
{
nlwarning("Failed to create picture");
return false;
}
cursor = XRenderCreateCursor(_dpy, picture, (uint)hotSpotX, (uint)hotSpotY);
if (!cursor)
{
nlwarning("Failed to create cursor");
return false;
}
XRenderFreePicture(_dpy, picture);
if (!XFreePixmap(_dpy, pixmap))
{
nlwarning("XFreePixmap failed");
}
return true;
}
#endif // HAVE_XRENDER
return false;
#else
return false;
#endif
}
} // NLDRIVERGL3
} // NL3D

@ -0,0 +1,202 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include "driver_opengl.h"
#include "nel/3d/light.h"
namespace NL3D {
namespace NLDRIVERGL3 {
// ***************************************************************************
uint CDriverGL3::getMaxLight () const
{
H_AUTO_OGL(CDriverGL3_getMaxLight)
// return MaxLight=8.
return MaxLight;
}
// ***************************************************************************
void CDriverGL3::setLight (uint8 num, const CLight& light)
{
H_AUTO_OGL(CDriverGL3_setLight)
// bkup real light, for lightmap dynamic lighting purpose
if (num==0)
{
_UserLight0= light;
// because the GL setup change, must dirt lightmap rendering
_LightMapDynamicLightDirty= true;
}
setLightInternal(num, light);
}
CLight CDriverGL3::getLight (uint8 num)
{
return _UserLight[ num ];
}
// ***************************************************************************
void CDriverGL3::setLightInternal(uint8 num, const CLight& light)
{
H_AUTO_OGL(CDriverGL3_setLightInternal)
// Check light count is good
// nlassert(num < MaxLight);
// Set the light
if (num < MaxLight)
{
// GL light number
GLenum lightNum = (GLenum)(GL_LIGHT0+num);
// Get light mode
CLight::TLightMode mode = light.getMode ();
// Copy the mode
_LightMode[num] = mode;
_UserLight[num] = light;
touchLightVP(num);
// Set the position
if ((mode == CLight::DirectionalLight) || (mode == CLight::SpotLight))
{
// Get the direction of the light
_WorldLightDirection[num] = light.getDirection();
}
if (mode != CLight::DirectionalLight)
{
// Get the position of the light
_WorldLightPos[num] = light.getPosition();
}
if (mode == CLight::SpotLight)
{
// Get the exponent of the spot
float exponent = light.getExponent();
// Get the cutoff of the spot
float cutoff = 180.f * (light.getCutoff() / (float)NLMISC::Pi);
}
}
}
// ***************************************************************************
void CDriverGL3::enableLight(uint8 num, bool enable)
{
H_AUTO_OGL(CDriverGL3_enableLight)
// enable the light in GL
enableLightInternal(num, enable);
// because the GL setup has changed, must dirt lightmap rendering
_LightMapDynamicLightDirty = true;
}
bool CDriverGL3::isLightEnabled (uint8 num)
{
if (num < MaxLight)
return _UserLightEnable[num];
return false;
}
// ***************************************************************************
void CDriverGL3::enableLightInternal(uint8 num, bool enable)
{
H_AUTO_OGL(CDriverGL3_enableLightInternal)
// Check light count is good
// nlassert(num < MaxLight);
// Enable glLight
if (num < MaxLight)
{
// _DriverGLStates.enableLight(num, enable); // FIXME GL3 VERTEX PROGRAM
_UserLightEnable[num] = enable;
touchLightVP(num);
}
}
// ***************************************************************************
void CDriverGL3::setAmbientColor (CRGBA color)
{
H_AUTO_OGL(CDriverGL3_setAmbientColor)
}
// ***************************************************************************
void CDriverGL3::setLightMapDynamicLight (bool enable, const CLight& light)
{
H_AUTO_OGL(CDriverGL3_setLightMapDynamicLight)
// just store, for future setup in lightmap material rendering
_LightMapDynamicLightEnabled= enable;
_LightMapDynamicLight= light;
_LightMapDynamicLightDirty= true;
}
// ***************************************************************************
void CDriverGL3::setupLightMapDynamicLighting(bool enable)
{
H_AUTO_OGL(CDriverGL3_setupLightMapDynamicLighting)
// start lightmap dynamic lighting
if (enable)
{
// disable all lights but the 0th.
for (uint i = 1; i < MaxLight; ++i)
enableLightInternal(i, false);
// if the dynamic light is really enabled
if (_LightMapDynamicLightEnabled)
{
// then setup and enable
setLightInternal(0, _LightMapDynamicLight);
enableLightInternal(0, true);
}
// else just disable also the light 0
else
{
enableLightInternal(0, false);
}
// ok it has been setup
_LightMapDynamicLightDirty = false;
}
// restore old lighting
else
{
// restore the light 0
setLightInternal(0, _UserLight0);
// restore all standard light enable states
for (uint i = 0; i < MaxLight; ++i)
enableLightInternal(i, _UserLightEnable[i]);
}
}
} // NLDRIVERGL3
} // NL3D

File diff suppressed because it is too large Load Diff

@ -0,0 +1,110 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include "driver_opengl.h"
namespace NL3D {
namespace NLDRIVERGL3 {
// ***************************************************************************
void CDriverGL3::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective)
{
H_AUTO_OGL(CDriverGL3_setFrustum);
if (perspective)
_GLProjMat.frustum(left, right, bottom, top, znear, zfar);
else
_GLProjMat.ortho(left, right, bottom, top, znear, zfar);
_OODeltaZ = 1 / (zfar - znear);
}
// ***************************************************************************
void CDriverGL3::setFrustumMatrix(CMatrix &frustumMatrix)
{
H_AUTO_OGL(CDriverGL3_setFrustum)
_GLProjMat = frustumMatrix;
}
// ***************************************************************************
CMatrix CDriverGL3::getFrustumMatrix()
{
H_AUTO_OGL(CDriverGL3_getFrustum)
return _GLProjMat;
}
// ***************************************************************************
void CDriverGL3::setupViewMatrixEx(const CMatrix& mtx, const CVector &cameraPos)
{
H_AUTO_OGL(CDriverGL3_setupViewMatrixEx)
_UserViewMtx= mtx;
// Setup the matrix to transform the CScene basis in openGL basis.
_ViewMtx = mtx;
// Reset the viewMtx position.
_ViewMtx.setPos(CVector::Null);
_PZBCameraPos= cameraPos;
_SpecularTexMtx = _ViewMtx;
_SpecularTexMtx.setPos(CVector(0.0f,0.0f,0.0f));
_SpecularTexMtx.invert();
}
// ***************************************************************************
void CDriverGL3::setupViewMatrix(const CMatrix& mtx)
{
H_AUTO_OGL(CDriverGL3_setupViewMatrix)
_UserViewMtx= mtx;
_ViewMtx = mtx;
// Just set the PZBCameraPos to 0.
_PZBCameraPos= CVector::Null;
_SpecularTexMtx = _ViewMtx;
_SpecularTexMtx.setPos(CVector(0.0f,0.0f,0.0f));
_SpecularTexMtx.invert();
}
// ***************************************************************************
CMatrix CDriverGL3::getViewMatrix(void) const
{
H_AUTO_OGL(CDriverGL3_getViewMatrix)
return _UserViewMtx;
}
// ***************************************************************************
void CDriverGL3::setupModelMatrix(const CMatrix& mtx)
{
H_AUTO_OGL(CDriverGL3_setupModelMatrix)
// profiling
_NbSetupModelMatrixCall++;
// Put the matrix in the opengl eye space, and store it.
CMatrix mat= mtx;
// remove first the _PZBCameraPos
mat.setPos(mtx.getPos() - _PZBCameraPos);
_ModelViewMatrix= _ViewMtx*mat;
}
} // NLDRIVERGL3
} // NL3D

@ -0,0 +1,807 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2014 by authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include <sstream>
#include "nel/misc/wang_hash.h"
#include "nel/3d/vertex_program.h"
#include "nel/3d/light.h"
#include "driver_opengl.h"
#include "driver_opengl_program.h"
#include "driver_opengl_vertex_buffer.h"
namespace NL3D {
namespace NLDRIVERGL3 {
namespace /* anonymous */ {
uint maxTextures(CMaterial::TShader shader)
{
switch (shader)
{
case CMaterial::Specular:
case CMaterial::UserColor: // UserColor has the same texture set up twice
return 2;
default:
return IDRV_MAT_MAXTEXTURES;
}
}
uint maxSamplers(CMaterial::TShader shader, CGlExtensions &glext)
{
switch (shader)
{
case CMaterial::LightMap:
return std::min((GLint)IDRV_PROGRAM_MAXSAMPLERS, glext.MaxFragmentTextureImageUnits);
default:
return maxTextures(shader);
}
}
bool useTexEnv(CMaterial::TShader shader)
{
return shader == CMaterial::Normal
|| shader == CMaterial::UserColor;
}
bool useTex(const CPPBuiltin &desc, uint stage)
{
return (desc.TextureActive & (1 << stage)) != 0;
}
} /* anonymous namespace */
bool operator<(const CPPBuiltin &left, const CPPBuiltin &right)
{
// Material state
if (left.Shader != right.Shader)
return left.Shader < right.Shader;
if (left.Flags != right.Flags)
return left.Flags < right.Flags;
if (left.TextureActive != right.TextureActive)
return left.TextureActive < right.TextureActive;
if (left.TexSamplerMode != right.TexSamplerMode)
return left.TexSamplerMode < right.TexSamplerMode;
uint maxTex = maxTextures(left.Shader);
if (useTexEnv(left.Shader))
for (uint stage = 0; stage < maxTex; ++stage)
if (left.TexEnvMode[stage] != right.TexEnvMode[stage])
return left.TexEnvMode[stage] < right.TexEnvMode[stage];
// Driver state
if (left.VertexFormat != right.VertexFormat)
return left.VertexFormat < right.VertexFormat;
if (left.Fog != right.Fog)
return right.Fog;
return false;
}
bool operator==(const CPPBuiltin &left, const CPPBuiltin &right)
{
// Material state
if (left.Shader != right.Shader)
return false;
if (left.Flags != right.Flags)
return false;
if (left.TextureActive != right.TextureActive)
return false;
if (left.TexSamplerMode != right.TexSamplerMode)
return false;
uint maxTex = maxTextures(left.Shader);
if (useTexEnv(left.Shader))
for (uint stage = 0; stage < maxTex; ++stage)
if (left.TexEnvMode[stage] != right.TexEnvMode[stage])
return false;
// Driver state
if (left.VertexFormat != right.VertexFormat)
return false;
if (left.Fog != right.Fog)
return false;
return true;
}
} // NLDRIVERGL3
} // NL3D
namespace std {
size_t hash<NL3D::NLDRIVERGL3::CPPBuiltin>::operator()(const NL3D::NLDRIVERGL3::CPPBuiltin & v) const
{
#if (HAVE_X86_64)
uint32 h32;
uint64 h64;
// Material state
h32 = NLMISC::wangHash((uint32)v.Shader);
h64 = NLMISC::wangHash64(((uint64)v.Flags) | ((uint64)v.TextureActive << 32));
h64 = NLMISC::wangHash64(h64 ^ (uint64)v.TexSamplerMode);
uint maxTex = NL3D::NLDRIVERGL3::maxTextures(v.Shader);
if (NL3D::NLDRIVERGL3::useTexEnv(v.Shader))
for (uint stage = 0; stage < maxTex; ++stage)
h32 = NLMISC::wangHash(h32 ^ (uint32)v.TexEnvMode[stage]);
// Driver state
h32 = NLMISC::wangHash(h32 ^ (((uint32)v.VertexFormat) | (v.Fog ? 1 << 16 : 0)));
h64 = h64 ^ h32; // NLMISC::wangHash64(h64 ^ h32);
nlctassert(sizeof(size_t) >= sizeof(uint64));
return (size_t)h64;
#else
uint32 h;
// Material state
h = NLMISC::wangHash((uint32)v.Shader);
h = NLMISC::wangHash(h ^ (uint32)v.Flags);
h = NLMISC::wangHash(h ^ (uint32)v.TextureActive);
h = NLMISC::wangHash(h ^ (uint32)(v.TexSamplerMode & 0xFFFFFFFF));
h = NLMISC::wangHash(h ^ (uint32)(v.TexSamplerMode >> 32));
uint maxTex = NL3D::maxTextures(v.Shader);
if (NL3D::useTexEnv(v.Shader))
for (uint stage = 0; stage < maxTex; ++stage)
h = NLMISC::wangHash(h ^ (uint32)v.TexEnvMode[stage]);
// Driver state
h = NLMISC::wangHash(h ^ (((uint32)v.VertexFormat) | (v.Fog ? 1 << 16 : 0)));
nlctassert(sizeof(size_t) >= sizeof(uint32));
return (size_t)h;
#endif
}
}
namespace NL3D {
namespace NLDRIVERGL3 {
namespace /* anonymous */ {
const char *s_ShaderNames[] =
{
"Normal",
"Bump",
"Usercolor",
"Lightmap",
"Specular",
"Caustics",
"Per-Pixel Lighting",
"Per-Pixel Lighting, no specular",
"Cloud",
"Water"
};
CMaterial::TShader getSupportedShader(CMaterial::TShader shader)
{
switch (shader)
{
case CMaterial::Normal:
case CMaterial::UserColor:
case CMaterial::Specular:
case CMaterial::LightMap:
return shader;
default:
return CMaterial::Normal;
}
}
void ppTexEnv(std::stringstream &ss, const CPPBuiltin &desc)
{
uint maxTex = maxTextures(desc.Shader);
CMaterial::CTexEnv texEnv;
for (uint stage = 0; stage < maxTex; ++stage)
{
if (useTex(desc, stage))
{
texEnv.EnvPacked = desc.TexEnvMode[stage];
for (uint arg = 0; arg < 3; ++arg)
{
// Texop arg
ss << "vec4 texop" << stage << "arg" << arg << ";" << std::endl;
// RGB
uint rgbArg = texEnv.getColorArg(arg);
uint rgbOp = texEnv.getColorOperand(arg);
std::stringstream rgbArgVec;
switch (rgbArg)
{
case CMaterial::Texture:
rgbArgVec << "texel" << stage;
break;
case CMaterial::Previous:
if (stage > 0)
{
rgbArgVec << "texop" << (stage - 1);
break;
}
case CMaterial::Diffuse:
rgbArgVec << "fragColor";
break;
case CMaterial::Constant:
rgbArgVec << "constant" << stage;
break;
}
ss << "texop" << stage << "arg" << arg << ".rgb = ";
switch (rgbOp) // SrcColor=0, InvSrcColor, SrcAlpha, InvSrcAlpha
{
case CMaterial::SrcColor:
ss << rgbArgVec.str() << ".rgb";
break;
case CMaterial::InvSrcColor:
ss << "vec3(1.0, 1.0, 1.0) - " << rgbArgVec.str() << ".rgb";
break;
case CMaterial::SrcAlpha:
ss << rgbArgVec.str() << ".aaa";
break;
case CMaterial::InvSrcAlpha:
ss << "(1.0 - " << rgbArgVec.str() << ").aaa";
break;
}
ss << ";" << std::endl;
// Alpha
uint alphaArg = texEnv.getAlphaArg(arg);
uint alphaOp = texEnv.getAlphaOperand(arg);
std::stringstream alphaArgVec;
switch (alphaArg)
{
case CMaterial::Texture:
alphaArgVec << "texel" << stage;
break;
case CMaterial::Previous:
if (stage > 0)
{
alphaArgVec << "texop" << (stage - 1);
break;
}
case CMaterial::Diffuse:
alphaArgVec << "fragColor";
break;
case CMaterial::Constant:
alphaArgVec << "constant" << stage;
break;
}
ss << "texop" << stage << "arg" << arg << ".a = ";
switch (alphaOp) // SrcColor=0, InvSrcColor, SrcAlpha, InvSrcAlpha
{
case CMaterial::SrcColor:
ss << alphaArgVec.str() << ".r";
break;
case CMaterial::InvSrcColor:
ss << "1.0 - " << alphaArgVec.str() << ".r";
break;
case CMaterial::SrcAlpha:
ss << alphaArgVec.str() << ".a";
break;
case CMaterial::InvSrcAlpha:
ss << "1.0 - " << alphaArgVec.str() << ".a";
break;
}
ss << ";" << std::endl;
}
ss << "vec4 texop" << stage << ";" << std::endl;
// RGB
switch (texEnv.Env.OpRGB)
{
case CMaterial::InterpolateConstant:
ss << "float texop" << stage << "rgbAs = constant" << stage << ".a;" << std::endl;
break;
case CMaterial::InterpolatePrevious:
if (stage > 0)
{
ss << "float texop" << stage << "rgbAs = texop" << (stage - 1) << ".a;" << std::endl;
break;
}
case CMaterial::InterpolateDiffuse:
ss << "float texop" << stage << "rgbAs = fragColor.a;" << std::endl;
break;
case CMaterial::InterpolateTexture:
ss << "float texop" << stage << "rgbAs = texel" << stage << ".a;" << std::endl;
break;
}
ss << "texop" << stage << ".rgb = ";
switch (texEnv.Env.OpRGB)
{
case CMaterial::Replace:
ss << "texop" << stage << "arg0.rgb";
break;
case CMaterial::Modulate:
ss << "texop" << stage << "arg0.rgb * texop" << stage << "arg1.rgb";
break;
case CMaterial::Add:
ss << "texop" << stage << "arg0.rgb + texop" << stage << "arg1.rgb";
break;
case CMaterial::AddSigned:
ss << "texop" << stage << "arg0.rgb + texop" << stage << "arg1.rgb - vec3(0.5, 0.5, 0.5)";
break;
case CMaterial::InterpolateConstant:
case CMaterial::InterpolateDiffuse:
case CMaterial::InterpolatePrevious:
case CMaterial::InterpolateTexture:
ss << "texop" << stage << "arg0.rgb * texop" << stage << "rgbAs + texop" << stage << "arg1.rgb * (1.0 - texop" << stage << "rgbAs)";
break;
case CMaterial::Mad:
ss << "texop" << stage << "arg0.rgb * texop" << stage << "arg1.rgb + texop" << stage << "arg2.rgb";
break;
}
ss << ";" << std::endl;
// Alpha
switch (texEnv.Env.OpAlpha)
{
case CMaterial::InterpolateConstant:
ss << "float texop" << stage << "alphaAs = constant" << stage << ".a;" << std::endl;
break;
case CMaterial::InterpolatePrevious:
if (stage > 0)
{
ss << "float texop" << stage << "alphaAs = texop" << (stage - 1) << ".a;" << std::endl;
break;
}
case CMaterial::InterpolateDiffuse:
ss << "float texop" << stage << "alphaAs = fragColor.a;" << std::endl;
break;
case CMaterial::InterpolateTexture:
ss << "float texop" << stage << "alphaAs = texel" << stage << ".a;" << std::endl;
break;
}
ss << "texop" << stage << ".a = ";
switch (texEnv.Env.OpAlpha)
{
case CMaterial::Replace:
ss << "texop" << stage << "arg0.a";
break;
case CMaterial::Modulate:
ss << "texop" << stage << "arg0.a * texop" << stage << "arg1.a";
break;
case CMaterial::Add:
ss << "texop" << stage << "arg0.a + texop" << stage << "arg1.a";
break;
case CMaterial::AddSigned:
ss << "texop" << stage << "arg0.a + texop" << stage << "arg1.a - 0.5";
break;
case CMaterial::InterpolateConstant:
case CMaterial::InterpolateDiffuse:
case CMaterial::InterpolatePrevious:
case CMaterial::InterpolateTexture:
ss << "texop" << stage << "arg0.a * texop" << stage << "rgbAs + texop" << stage << "arg1.a * (1.0 - texop" << stage << "rgbAs)";
break;
case CMaterial::Mad:
ss << "texop" << stage << "arg0.a * texop" << stage << "arg1.a + texop" << stage << "arg2.a";
break;
}
ss << ";" << std::endl;
}
else if (stage == 0)
{
ss << "vec4 texop" << stage << " = fragColor; // no active texture in stage" << std::endl;
}
else
{
ss << "vec4 texop" << stage << " = texop" << (stage - 1) << "; // no active texture in stage" << std::endl;
}
}
ss << "fragColor = texop" << (maxTex - 1) << ";" << std::endl;
}
void ppSpecular(std::stringstream &ss, const CPPBuiltin &desc)
{
if (useTex(desc, 0))
{
ss << "vec3 specop0 = texel0.rgb * fragColor.rgb;" << std::endl;
if (useTex(desc, 1))
{
ss << "vec4 specop1 = vec4(texel1.rgb * texel0.a + specop0, fragColor.a);" << std::endl;
}
else
{
nlwarning("Texture stage 1 (reflection) missing in Specular shader");
ss << "vec4 specop1 = vec4(specop0, fragColor.a);" << std::endl;
}
ss << "fragColor = specop1;" << std::endl;
}
else if (useTex(desc, 1))
{
nlwarning("Texture stage 0 (color) missing in Specular shader");
ss << "vec4 specop1 = vec4(texel1.rgb + fragColor.rgb, 1.0);" << std::endl;
ss << "fragColor = specop1;" << std::endl;
}
else
{
nlwarning("PP: No textures defined in Specular shader");
// do nothing
}
}
void ppLightmap(std::stringstream &ss, const CPPBuiltin &desc, CGlExtensions &glext)
{
uint nstages;
for (nstages = 0; nstages < std::min(glext.MaxFragmentTextureImageUnits, (GLint)IDRV_PROGRAM_MAXSAMPLERS); ++nstages)
if (!useTex(desc, nstages))
break;
if (nstages == 0)
{
// do nothing
nlwarning("PP: Lightmap without textures setup");
}
else if (nstages == 1)
{
// single map (doesn't support alpha)
nlwarning("PP: Lightmap material without lightmaps setup %i %i %i %i", useTex(desc, 0), useTex(desc, 1), useTex(desc, 2), useTex(desc, 3));
ss << "fragColor = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl; // HACK FIXME GL3
ss << "fragColor = texel" << (nstages - 1) << " * fragColor;" << std::endl;
}
else
{
ss << "fragColor = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl; // HACK FIXME GL3
ss << "vec4 lightmapop = vec4(0.0, 0.0, 0.0, 0.0);" << std::endl;
for (uint stage = 0; stage < (nstages - 1); ++stage)
ss << "lightmapop = lightmapop + texel" << stage << " * constant" << stage << " * texel" << (nstages - 1) << ";" << std::endl;
ss << "fragColor = fragColor * lightmapop;" << std::endl;
}
}
void ppGenerate(std::string &result, const CPPBuiltin &desc, CGlExtensions &glext)
{
std::stringstream ss;
ss << "// Builtin Pixel Shader: " << s_ShaderNames[desc.Shader] << std::endl;
ss << std::endl;
ss << "#version 330" << std::endl;
ss << "#extension GL_ARB_separate_shader_objects : enable" << std::endl;
ss << std::endl;
ss << "out vec4 fragColor;" << std::endl;
for (int i = Weight; i < NumOffsets; i++)
{
if (hasFlag(desc.VertexFormat, g_VertexFlags[i]))
{
ss << "smooth in vec4 ";
ss << g_AttribNames[i] << ";" << std::endl;
}
}
ss << std::endl;
uint maxTex = maxTextures(desc.Shader);
uint maxSam = maxSamplers(desc.Shader, glext);
for (uint stage = 0; stage < maxSam; ++stage)
{
if (stage == 1 && desc.Shader == CMaterial::UserColor)
{
ss << "// user color" << std::endl;
}
if (useTex(desc, stage))
{
uint64 samplerMode = (desc.TexSamplerMode >> (stage * 2)) & 0x3;
ss << "uniform "
<< ((samplerMode == SamplerCube) ? "samplerCube" : "sampler2D")
<< " sampler" << stage << ";" << std::endl;
}
}
ss << std::endl;
// ???
ss << "uniform vec4 materialColor;" << std::endl; // ?! what is this doing in PP
ss << std::endl;
// TexEnv
switch (desc.Shader)
{
case CMaterial::Normal:
case CMaterial::UserColor:
case CMaterial::LightMap:
for (uint stage = 0; stage < maxSam; ++stage)
{
if (useTex(desc, stage))
{
ss << "uniform vec4 constant" << stage << ";" << std::endl;
ss << std::endl;
}
}
break;
}
// Alpha test
if (desc.Flags & IDRV_MAT_ALPHA_TEST)
{
ss << "uniform float alphaRef;" << std::endl;
ss << std::endl;
}
// Fog
if (desc.Fog) // FIXME: FogMode!
{
ss << "uniform vec2 fogParams;" << std::endl; // s = start, t = end
ss << "uniform vec4 fogColor;" << std::endl;
/*if (desc->getFogMode() == CShaderDesc::Linear)
{*/
//ss << "uniform float fogDensity;" << std::endl;
/*}*/
ss << "smooth in vec4 ecPos;" << std::endl;
/*switch(desc->getFogMode())
{*/
//case CShaderDesc::Linear:
ss << "vec4 applyFog(vec4 col)" << std::endl;
ss << "{" << std::endl;
ss << "float z = ecPos.y / ecPos.w;" << std::endl;
ss << "z = abs(z);" << std::endl;
ss << "float fogFactor = (fogParams.t - z) / (fogParams.t - fogParams.s);" << std::endl;
ss << "fogFactor = clamp(fogFactor, 0.0, 1.0);" << std::endl;
ss << "vec4 fColor = mix(fogColor, col, fogFactor);" << std::endl;
ss << "fColor.a = col.a;" << std::endl;
ss << "return fColor;" << std::endl;
ss << "}" << std::endl;
ss << std::endl;
// break;
/*}*/
ss << std::endl;
}
ss << "smooth in vec4 vertexColor;" << std::endl;
ss << std::endl;
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
// Vertex color (light or unlit diffuse, primary and secondary)
ss << "fragColor = vertexColor;" << std::endl;
for (uint stage = 0; stage < maxSam; ++stage)
{
if (stage == 1 && desc.Shader == CMaterial::UserColor)
{
ss << "vec4 texel1 = texel0;" << std::endl; // UserColor has one single texture set up in two textures, we optimize this away here
}
else if (useTex(desc, stage))
{
ss << "vec4 texel" << stage << " = texture(sampler" << stage << ", ";
if (desc.Shader == CMaterial::LightMap && stage != (maxSam - 1) && useTex(desc, stage + 1) && hasFlag(desc.VertexFormat, g_VertexFlags[TexCoord1]))
{
ss << g_AttribNames[TexCoord1];
}
else if (desc.Shader == CMaterial::LightMap && hasFlag(desc.VertexFormat, g_VertexFlags[TexCoord0]))
{
ss << g_AttribNames[TexCoord0];
}
else if (stage < maxTex && hasFlag(desc.VertexFormat, g_VertexFlags[TexCoord0 + stage]))
{
ss << g_AttribNames[TexCoord0 + stage];
}
else if (hasFlag(desc.VertexFormat, g_VertexFlags[TexCoord0]))
{
ss << g_AttribNames[TexCoord0];
}
else
{
nlwarning("GL3: Pixel Program generated for material with coordinateless texture");
ss << "vec4(0.0, 0.0, 0.0, 0.0)";
}
uint64 samplerMode = (desc.TexSamplerMode >> (stage * 2)) & 0x3;
ss << ((samplerMode == SamplerCube) ? ".stp);" : ".st);");
ss << std::endl;
}
}
switch (desc.Shader)
{
case CMaterial::Normal:
case CMaterial::UserColor:
ppTexEnv(ss, desc);
break;
case CMaterial::Specular:
ppSpecular(ss, desc);
break;
case CMaterial::LightMap:
ppLightmap(ss, desc, glext);
break;
default:
nlwarning("GL3: Try to generate unknown shader type (%s)", s_ShaderNames[desc.Shader]);
// ss << "fragColor = vec(1.0, 0.0, 0.5, 1.0);" << std::endl;
break;
}
if (desc.Flags & IDRV_MAT_ALPHA_TEST)
{
ss << "if (fragColor.a < alphaRef) discard;" << std::endl; // TODO: VERIFY < or <= ?
}
if (desc.Fog)
{
ss << "fragColor = applyFog(fragColor);" << std::endl;
}
ss << "}" << std::endl;
result = ss.str();
}
} /* anonymous namespace */
void CDriverGL3::generateBuiltinPixelProgram(CMaterial &mat)
{
CMaterialDrvInfosGL3 *matDrv = static_cast<CMaterialDrvInfosGL3 *>((IMaterialDrvInfos *)(mat._MatDrvInfo));
nlassert(matDrv);
std::unordered_set<CPPBuiltin>::iterator it = m_PPBuiltinCache.find(matDrv->PPBuiltin);
if (it != m_PPBuiltinCache.end())
{
matDrv->PPBuiltin.PixelProgram = it->PixelProgram;
return;
}
std::string result;
ppGenerate(result, matDrv->PPBuiltin, _Extensions);
CPixelProgram *program = new CPixelProgram();
IProgram::CSource *src = new IProgram::CSource();
src->Profile = IProgram::glsl330f;
src->DisplayName = "Builtin Pixel Program (" + NLMISC::toString(m_PPBuiltinCache.size()) + ")";
src->setSource(result);
program->addSource(src);
nldebug("GL3: Generate '%s'", src->DisplayName.c_str());
if (!compilePixelProgram(program))
{
delete program;
program = NULL;
}
matDrv->PPBuiltin.PixelProgram = program;
m_PPBuiltinCache.insert(matDrv->PPBuiltin);
}
void CPPBuiltin::checkDriverStateTouched(CDriverGL3 *driver) // MUST NOT depend on any state set by checkMaterialStateTouched
{
// Add generated texture coordinates to vertex format // TODO: Eliminate unused flags
uint16 vertexFormat = driver->m_VPBuiltinCurrent.VertexFormat;
for (sint stage = 0; stage < IDRV_MAT_MAXTEXTURES; ++stage)
if (driver->m_VPBuiltinCurrent.TexGenMode[stage] >= 0)
vertexFormat |= g_VertexFlags[TexCoord0 + stage];
vertexFormat &= ~g_VertexFlags[PrimaryColor];
vertexFormat &= ~g_VertexFlags[SecondaryColor];
// Compare values
if (VertexFormat != vertexFormat)
{
VertexFormat = vertexFormat;
Touched = true;
}
if (Fog != driver->m_VPBuiltinCurrent.Fog)
{
Fog = driver->m_VPBuiltinCurrent.Fog;
Touched = true;
}
}
void CPPBuiltin::checkDriverMaterialStateTouched(CDriverGL3 *driver, CMaterial &mat)
{
CMaterial::TShader shader = getSupportedShader(mat.getShader());
switch (shader)
{
case CMaterial::LightMap:
// Use Textures from current driver state
uint maxSam = maxSamplers(shader, driver->_Extensions);
uint32 textureActive = 0;
uint64 texSamplerMode = 0;
for (uint stage = 0; stage < maxSam; ++stage) // NB: Limited to IDRV_PROGRAM_MAXSAMPLERS here
{
NL3D::ITexture *tex = driver->_CurrentTexture[stage];
if (tex)
{
textureActive |= (1 << stage);
texSamplerMode |= (tex->isTextureCube() ? SamplerCube : Sampler2D) << (stage * 2);
}
}
if (TextureActive != textureActive)
{
TextureActive = textureActive;
Touched = true;
}
if (TexSamplerMode != texSamplerMode)
{
TexSamplerMode = texSamplerMode;
Touched = true;
}
break;
}
}
void CPPBuiltin::checkMaterialStateTouched(CMaterial &mat) // MUST NOT depend on any state set by checkDriverStateTouched
{
// Optimize
uint32 touched = !PixelProgram ? IDRV_TOUCHED_ALL : mat.getTouched();
if (touched == 0) return;
// Compare values
CMaterial::TShader shader = getSupportedShader(mat.getShader());
if (Shader != shader)
{
Shader = shader;
Touched = true;
}
uint32 flags = mat.getFlags();
flags &= IDRV_MAT_ALPHA_TEST; // TODO: |= with the wanted flags from the VP when flags are added to the VP
if (Flags != flags)
{
Flags = flags;
Touched = true;
}
uint maxTex = maxTextures(shader);
if (touched & IDRV_TOUCHED_ALLTEX) // Note: There is a case where textures are provided where no texture coordinates are provided, this is handled gracefully by the pixel program generation (it will use a vec(0) texture coordinate). The inverse is an optimization issue
{
switch (shader)
{
case CMaterial::LightMap:
break;
default:
// Use textures directly from the CMaterial
uint32 textureActive = 0;
uint64 texSamplerMode = 0;
for (uint stage = 0; stage < maxTex; ++stage) // NB: Limited to IDRV_MAT_MAXTEXTURES here
{
NL3D::ITexture *tex = mat._Textures[stage];
if (tex)
{
textureActive |= (1 << stage);
// Issue: Due to the IDRV_TOUCHED_ALLTEX check, the sampler mode of an ITexture cannot be modified after it has been added to the CMaterial
texSamplerMode |= (tex->isTextureCube() ? SamplerCube : Sampler2D) << (stage * 2);
}
}
if (TextureActive != textureActive)
{
TextureActive = textureActive;
Touched = true;
}
if (TexSamplerMode != texSamplerMode)
{
TexSamplerMode = texSamplerMode;
Touched = true;
}
break;
}
}
if (useTexEnv(shader) && (touched & IDRV_TOUCHED_TEXENV))
{
for (uint stage = 0; stage < maxTex; ++stage)
{
if (TexEnvMode[stage] != mat._TexEnvs[stage].EnvPacked)
{
TexEnvMode[stage] = mat._TexEnvs[stage].EnvPacked;
Touched = true;
}
}
}
// Optimize
mat.clearTouched(0xFFFFFFFF);
}
} // NLDRIVERGL3
} // NL3D

@ -0,0 +1,941 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "driver_opengl.h"
#include "driver_opengl_program.h"
#include "driver_glsl_shader_generator.h"
#include "driver_opengl_vertex_buffer.h"
namespace NL3D {
namespace NLDRIVERGL3 {
const uint16 g_VertexFlags[CVertexBuffer::NumValue] =
{
CVertexBuffer::PositionFlag,
CVertexBuffer::WeightFlag,
CVertexBuffer::NormalFlag,
CVertexBuffer::PrimaryColorFlag,
CVertexBuffer::SecondaryColorFlag,
CVertexBuffer::FogFlag,
CVertexBuffer::PaletteSkinFlag,
0,
CVertexBuffer::TexCoord0Flag,
CVertexBuffer::TexCoord1Flag,
CVertexBuffer::TexCoord2Flag,
CVertexBuffer::TexCoord3Flag,
CVertexBuffer::TexCoord4Flag,
CVertexBuffer::TexCoord5Flag,
CVertexBuffer::TexCoord6Flag,
CVertexBuffer::TexCoord7Flag
};
const char *g_AttribNames[CVertexBuffer::NumValue] =
{
"position",
"weight",
"normal",
"primaryColor",
"secondaryColor",
"fog",
"paletteSkin",
"none",
"texCoord0",
"texCoord1",
"texCoord2",
"texCoord3",
"texCoord4",
"texCoord5",
"texCoord6",
"texCoord7"
};
const char *g_TexelNames[IDRV_PROGRAM_MAXSAMPLERS] =
{
"texel0",
"texel1",
"texel2",
"texel3",
"texel4",
"texel5",
"texel6",
"texel7",
"texel8",
"texel9",
"texel10",
"texel11",
"texel12",
"texel13",
"texel14",
"texel15",
"texel16",
"texel17",
"texel18",
"texel19",
"texel20",
"texel21",
"texel22",
"texel23",
"texel24",
"texel25",
"texel26",
"texel27",
"texel28",
"texel29",
"texel30",
"texel31",
};
const char *g_ConstantNames[IDRV_PROGRAM_MAXSAMPLERS] =
{
"constant0",
"constant1",
"constant2",
"constant3",
"constant4",
"constant5",
"constant6",
"constant7",
"constant8",
"constant9",
"constant10",
"constant11",
"constant12",
"constant13",
"constant14",
"constant15",
"constant16",
"constant17",
"constant18",
"constant19",
"constant20",
"constant21",
"constant22",
"constant23",
"constant24",
"constant25",
"constant26",
"constant27",
"constant28",
"constant29",
"constant30",
"constant31",
};
bool CDriverGL3::supportVertexProgram(CVertexProgram::TProfile profile) const
{
return (profile == IProgram::glsl330v);
}
bool CDriverGL3::compileVertexProgram(CVertexProgram *program)
{
if (program->m_DrvInfo != NULL)
return false;
IProgram::CSource *src = NULL;
for (int i = 0; i < program->getSourceNb(); i++)
{
src = program->getSource(i);
if (src->Profile == IProgram::glsl330v)
break;
src = NULL;
}
if (src == NULL)
return false;
const char *s = src->SourcePtr;
unsigned int id = nglCreateShaderProgramv(GL_VERTEX_SHADER, 1, &s);
if (id == 0)
return false;
GLint ok;
nglGetProgramiv(id, GL_LINK_STATUS, &ok);
if (ok == 0)
{
char errorLog[ 1024 ];
nglGetProgramInfoLog(id, 1024, NULL, errorLog);
nlwarning("GL3: %s", errorLog);
std::vector<std::string> lines;
NLMISC::explode(std::string(src->SourcePtr), std::string("\n"), lines);
for (std::vector<std::string>::size_type i = 0; i < lines.size(); ++i)
{
nldebug("GL3: %i: %s", i, lines[i].c_str());
}
return false;
}
else // debug
{
std::vector<std::string> lines;
NLMISC::explode(std::string(src->SourcePtr), std::string("\n"), lines);
for (std::vector<std::string>::size_type i = 0; i < lines.size(); ++i)
{
nldebug("GL3: %i: %s", i, lines[i].c_str());
}
}
ItGPUPrgDrvInfoPtrList it = _GPUPrgDrvInfos.insert(_GPUPrgDrvInfos.end(),(NL3D::IProgramDrvInfos*)NULL);
CProgramDrvInfosGL3 *drvInfo = new CProgramDrvInfosGL3(this, it);
*it = drvInfo;
program->m_DrvInfo = drvInfo;
drvInfo->setProgramId(id);
program->buildInfo(src);
setupInitialUniforms(program);
return true;
}
bool CDriverGL3::activeVertexProgram(CVertexProgram *program)
{
return activeVertexProgram(program, false);
}
bool CDriverGL3::activeVertexProgram(CVertexProgram *program, bool driver)
{
if (driver) nlassert(m_UserVertexProgram == NULL);
if (m_DriverVertexProgram == program)
return true;
if (program == NULL)
{
nglUseProgramStages(ppoId, GL_VERTEX_SHADER_BIT, 0);
m_UserVertexProgram = NULL;
m_DriverVertexProgram = NULL;
return true;
}
IProgramDrvInfos *di = program->m_DrvInfo;
if (di == NULL)
{
m_UserVertexProgram = NULL;
m_DriverVertexProgram = NULL;
return false;
}
CProgramDrvInfosGL3 *drvInfo = static_cast<CProgramDrvInfosGL3 *>(di);
nglUseProgramStages(ppoId, GL_VERTEX_SHADER_BIT, drvInfo->getProgramId());
if (!driver) m_UserVertexProgram = program;
m_DriverVertexProgram = program;
return true;
}
bool CDriverGL3::supportPixelProgram(IProgram::TProfile profile) const
{
if (profile == IProgram::glsl330f)
return true;
else
return false;
}
bool CDriverGL3::compilePixelProgram(CPixelProgram *program)
{
if (program->m_DrvInfo != NULL)
return false;
IProgram::CSource *src = NULL;
for (int i = 0; i < program->getSourceNb(); i++)
{
src = program->getSource(i);
if (src->Profile == IProgram::glsl330f)
break;
src = NULL;
}
if (src == NULL)
return false;
const char *s = src->SourcePtr;
unsigned int id = nglCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &s);
if (id == 0)
return false;
GLint ok;
nglGetProgramiv(id, GL_LINK_STATUS, &ok);
if (ok == 0)
{
char errorLog[ 1024 ];
nglGetProgramInfoLog(id, 1024, NULL, errorLog);
nlwarning("GL3: %s", errorLog);
std::vector<std::string> lines;
NLMISC::explode(std::string(src->SourcePtr), std::string("\n"), lines);
for (std::vector<std::string>::size_type i = 0; i < lines.size(); ++i)
{
nldebug("GL3: %i: %s", i, lines[i].c_str());
}
return false;
}
else // debug
{
std::vector<std::string> lines;
NLMISC::explode(std::string(src->SourcePtr), std::string("\n"), lines);
for (std::vector<std::string>::size_type i = 0; i < lines.size(); ++i)
{
nldebug("GL3: %i: %s", i, lines[i].c_str());
}
}
ItGPUPrgDrvInfoPtrList it = _GPUPrgDrvInfos.insert(_GPUPrgDrvInfos.end(), (NL3D::IProgramDrvInfos*)NULL);
CProgramDrvInfosGL3 *drvInfo = new CProgramDrvInfosGL3(this, it);
*it = drvInfo;
drvInfo->setProgramId(id);
program->m_DrvInfo = drvInfo;
program->buildInfo(src);
setupInitialUniforms(program);
return true;
}
bool CDriverGL3::activePixelProgram(CPixelProgram *program)
{
return activePixelProgram(program, false);
}
bool CDriverGL3::activePixelProgram(CPixelProgram *program, bool driver)
{
if (driver) nlassert(m_UserPixelProgram == NULL);
if (m_DriverPixelProgram == program)
return true;
if (program == NULL)
{
nglUseProgramStages(ppoId, GL_FRAGMENT_SHADER_BIT, 0);
m_UserPixelProgram = NULL;
m_DriverPixelProgram = NULL;
return true;
}
if (program->m_DrvInfo == NULL)
{
m_UserPixelProgram = NULL;
m_DriverPixelProgram = NULL;
return false;
}
IProgramDrvInfos *di = program->m_DrvInfo;
if (di == NULL)
{
m_UserPixelProgram = NULL;
m_DriverPixelProgram = NULL;
return false;
}
CProgramDrvInfosGL3 *drvInfo = static_cast<CProgramDrvInfosGL3 *>(di);
nglUseProgramStages(ppoId, GL_FRAGMENT_SHADER_BIT, drvInfo->getProgramId());
if (!driver) m_UserPixelProgram = program;
m_DriverPixelProgram = program;
return true;
}
uint32 CDriverGL3::getProgramId(TProgram program) const
{
IProgramDrvInfos *di;
switch(program)
{
case IDriver::VertexProgram:
if (m_DriverVertexProgram)
di = m_DriverVertexProgram->m_DrvInfo;
else
di = NULL;
break;
case IDriver::PixelProgram:
if (m_DriverPixelProgram)
di = m_DriverPixelProgram->m_DrvInfo;
else
di = NULL;
break;
default:
di = NULL;
break;
}
if (di == NULL)
return 0;
CProgramDrvInfosGL3 *drvInfo = static_cast<CProgramDrvInfosGL3 *>(di);
return drvInfo->getProgramId();
}
IProgram* CDriverGL3::getProgram(TProgram program) const
{
switch(program)
{
case IDriver::VertexProgram:
return m_DriverVertexProgram;
case IDriver::PixelProgram:
return m_DriverPixelProgram;
case IDriver::GeometryProgram:
return m_DriverGeometryProgram;
}
return NULL;
}
int CDriverGL3::getUniformLocation(TProgram program, const char *name)
{
uint32 id = getProgramId(program);
return nglGetUniformLocation(id, name);
}
void CDriverGL3::setUniform1f(TProgram program, uint index, float f0)
{
uint32 id = getProgramId(program);
nglProgramUniform1f(id, index, f0);
}
void CDriverGL3::setUniform2f(TProgram program, uint index, float f0, float f1)
{
uint32 id = getProgramId(program);
nglProgramUniform2f(id, index, f0, f1);
}
void CDriverGL3::setUniform3f(TProgram program, uint index, float f0, float f1, float f2)
{
uint32 id = getProgramId(program);
nglProgramUniform3f(id, index, f0, f1, f2);
}
void CDriverGL3::setUniform4f(TProgram program, uint index, float f0, float f1, float f2, float f3)
{
uint32 id = getProgramId(program);
nglProgramUniform4f(id, index, f0, f1, f2, f3);
}
void CDriverGL3::setUniform1i(TProgram program, uint index, sint32 i0)
{
uint32 id = getProgramId(program);
nglProgramUniform1i(id, index, i0);
}
void CDriverGL3::setUniform2i(TProgram program, uint index, sint32 i0, sint32 i1)
{
uint32 id = getProgramId(program);
nglProgramUniform2i(id, index, i0, i1);
}
void CDriverGL3::setUniform3i(TProgram program, uint index, sint32 i0, sint32 i1, sint32 i2)
{
uint32 id = getProgramId(program);
nglProgramUniform3i(id, index, i0, i1, i2);
}
void CDriverGL3::setUniform4i(TProgram program, uint index, sint32 i0, sint32 i1, sint32 i2, sint32 i3)
{
uint32 id = getProgramId(program);
nglProgramUniform4i(id, index, i0, i1, i2, i3);
}
void CDriverGL3::setUniform1ui(TProgram program, uint index, uint32 ui0)
{
uint32 id = getProgramId(program);
nglProgramUniform1ui(id, index, ui0);
}
void CDriverGL3::setUniform2ui(TProgram program, uint index, uint32 ui0, uint32 ui1)
{
uint32 id = getProgramId(program);
nglProgramUniform2ui(id, index, ui0, ui1);
}
void CDriverGL3::setUniform3ui(TProgram program, uint index, uint32 ui0, uint32 ui1, uint32 ui2)
{
uint32 id = getProgramId(program);
nglProgramUniform3ui(id, index, ui0, ui1, ui2);
}
void CDriverGL3::setUniform4ui(TProgram program, uint index, uint32 ui0, uint32 ui1, uint32 ui2, uint32 ui3)
{
uint32 id = getProgramId(program);
nglProgramUniform4ui(id, index, ui0, ui1, ui2, ui3);
}
void CDriverGL3::setUniform3f(TProgram program, uint index, const CVector &v)
{
uint32 id = getProgramId(program);
nglProgramUniform3f(id, index, v.x, v.y, v.z);
}
void CDriverGL3::setUniform4f(TProgram program, uint index, const CVector &v, float f3)
{
uint32 id = getProgramId(program);
nglProgramUniform4f(id, index, v.x, v.y, v.z, f3);
}
void CDriverGL3::setUniform4f(TProgram program, uint index, const NLMISC::CRGBAF& rgba)
{
uint32 id = getProgramId(program);
nglProgramUniform4f(id, index, rgba.R, rgba.G, rgba.B, rgba.A);
}
void CDriverGL3::setUniform3x3f(TProgram program, uint index, const float *src)
{
uint32 id = getProgramId(program);
nglProgramUniformMatrix3fv(id, index, 1, false, src);
}
void CDriverGL3::setUniform4x4f(TProgram program, uint index, const CMatrix &m)
{
uint32 id = getProgramId(program);
nglProgramUniformMatrix4fv(id, index, 1, false, m.get());
}
void CDriverGL3::setUniform4x4f(TProgram program, uint index, const float *src)
{
uint32 id = getProgramId(program);
nglProgramUniformMatrix4fv(id, index, 1, false, src);
}
void CDriverGL3::setUniform4fv(TProgram program, uint index, size_t num, const float *src)
{
uint32 id = getProgramId(program);
nglProgramUniform4fv(id, index, num, src);
}
void CDriverGL3::setUniform4iv(TProgram program, uint index, size_t num, const sint32 *src)
{
uint32 id = getProgramId(program);
nglProgramUniform4iv(id, index, num, src);
}
void CDriverGL3::setUniform4uiv(TProgram program, uint index, size_t num, const uint32 *src)
{
uint32 id = getProgramId(program);
nglProgramUniform4uiv(id, index, num, src);
}
void CDriverGL3::setUniformMatrix(TProgram program, uint index, TMatrix matrix, TTransform transform)
{
uint32 id = getProgramId(program);
CMatrix mat;
switch(matrix)
{
case IDriver::ModelView:
mat = _ModelViewMatrix;
break;
case IDriver::Projection:
mat = _GLProjMat * _ChangeBasis;
break;
case IDriver::ModelViewProjection:
mat = _GLProjMat * _ChangeBasis * _ModelViewMatrix;
break;
}
switch(transform)
{
case IDriver::Inverse:
mat.invert();
break;
case IDriver::Transpose:
mat.transpose();
break;
case IDriver::InverseTranspose:
mat.transpose();
mat.invert();
break;
}
nglProgramUniformMatrix4fv(id, index, 1, false, mat.get());
}
void CDriverGL3::setUniformFog(TProgram program, uint index)
{
uint32 id = getProgramId(program);
const float *v = _ModelViewMatrix.get();
nglProgramUniform4f(id, index, -v[ 2 ], -v[ 6 ], -v[ 10 ], -v[ 4 ]);
}
/*
void CDriverGL3::generateShaderDesc(CShaderDesc &desc, CMaterial &mat)
{
desc.setShaderType(mat.getShader());
uint16 vbFlags = _CurrentVertexBufferGL->VB->getVertexFormat();
for (sint i = 0; i < IDRV_MAT_MAXTEXTURES; ++i)
{
if (m_VPBuiltinCurrent.TexGenMode[i] >= 0)
{
//nldebug("texgen hack for keeping pp simpler, stage %i, tex %s valid", i, mat.getTexture(i) ? "IS" : "NOT");
vbFlags |= g_VertexFlags[TexCoord0 + i];
}
}
desc.setVBFlags(vbFlags);
if (mat.getShader() == CMaterial::LightMap)
desc.setNLightMaps(mat._LightMaps.size());
//int i = 0;
if (mat.getShader() == CMaterial::Normal
|| mat.getShader() == CMaterial::UserColor
|| mat.getShader() == CMaterial::Specular)
{
bool useTextures = false;
int maxTextures = std::min(int(IDRV_MAT_MAXTEXTURES), int(IDRV_MAT_MAXTEXTURES));
if (mat.getShader() == CMaterial::Normal)
{
for (int i = 0; i < maxTextures; i++)
{
desc.setTexEnvMode(i, mat.getTexEnvMode(i));
} // todo specular env mode..
}
for (int i = 0; i < maxTextures; i++)
{
// GL3 TEX COORD
if (mat.getTexture(i) != NULL
&& (desc.hasVBFlags(g_VertexFlags[TexCoord0]) || desc.hasVBFlags(g_VertexFlags[TexCoord0 + i]))
)
{
//nldebug("use stage %i", i);
desc.setUseTexStage(i, true);
useTextures = true;
desc.textureSamplerMode[i] = mat.getTexture(i)->isTextureCube() ? SamplerCube : Sampler2D; // Driver state
}
else
{
/*nldebug("stage fail %i, tex %s, tc0 %s, tci, %s", i, mat.getTexture(i) ? "VALID" : "NO",
desc.hasVBFlags(g_VertexFlags[TexCoord0]) ? "YES" : "NO",
desc.hasVBFlags(g_VertexFlags[TexCoord0 + i]) ? "YES" : "NO");* /
}
}
if (!useTextures)
{
desc.setNoTextures(true);
}
}
if (mat.getAlphaTest())
{
desc.setAlphaTest(true);
desc.setAlphaTestThreshold(mat.getAlphaTestThreshold());
}
if (m_VPBuiltinCurrent.Fog) // Driver state
{
desc.setFog(true);
desc.setFogMode(CShaderDesc::Linear);
}
//bool enableLights = false;
for (int i = 0; i < MaxLight; i++)
{
if (!_UserLightEnable[i])
{
desc.setLight(i, CShaderDesc::Nolight);
continue;
}
//if (!_UserLightEnable[ i ])
// continue;
//enableLights = true;
switch(_LightMode[ i ])
{
case CLight::DirectionalLight:
desc.setLight(i, CShaderDesc::Directional);
break;
case CLight::PointLight:
desc.setLight(i, CShaderDesc::Point);
break;
case CLight::SpotLight:
desc.setLight(i, CShaderDesc::Spot);
break;
}
}
desc.setLighting(/*enableLights && mat.isLighted() &&* / m_VPBuiltinCurrent.Lighting);
}*/
bool CDriverGL3::setupBuiltinPrograms()
{
return setupBuiltinVertexProgram()
&& setupBuiltinPixelProgram()
&& setupUniforms();
}
bool CDriverGL3::setupBuiltinVertexProgram()
{
if (m_UserVertexProgram) return true;
touchVertexFormatVP(); // TODO
if (m_VPBuiltinTouched)
{
generateBuiltinVertexProgram();
nlassert(m_VPBuiltinCurrent.VertexProgram);
m_VPBuiltinTouched = false;
}
if (!activeVertexProgram(m_VPBuiltinCurrent.VertexProgram, true))
return false;
// GL3 TODO: Here we set the uniforms of the vertex program!
return true;
}
bool CDriverGL3::setupBuiltinPixelProgram()
{
if (m_UserPixelProgram) return true;
nlassert(_CurrentMaterial);
CMaterial &mat = *_CurrentMaterial;
CMaterialDrvInfosGL3 *matDrv = static_cast<CMaterialDrvInfosGL3 *>((IMaterialDrvInfos *)(mat._MatDrvInfo));
nlassert(matDrv);
matDrv->PPBuiltin.checkDriverStateTouched(this);
matDrv->PPBuiltin.checkDriverMaterialStateTouched(this, mat);
matDrv->PPBuiltin.checkMaterialStateTouched(mat);
if (matDrv->PPBuiltin.Touched)
{
generateBuiltinPixelProgram(mat);
nlassert(matDrv->PPBuiltin.PixelProgram);
matDrv->PPBuiltin.Touched = false;
}
if (!activePixelProgram(matDrv->PPBuiltin.PixelProgram, true))
return false;
// GL3 TODO: Here we set the uniforms of the vertex program!
return true;
}
bool CDriverGL3::setupUniforms()
{
setupUniforms(IDriver::VertexProgram);
setupUniforms(IDriver::PixelProgram);
return true;
}
void CDriverGL3::setupUniforms(TProgram program)
{
CMaterial &mat = *_CurrentMaterial;
IProgram *p = getProgram(program);
if (p == NULL) return;
IProgramDrvInfos *di = p->m_DrvInfo;
if (di == NULL) return;
CProgramDrvInfosGL3 *drvInfo = static_cast<CProgramDrvInfosGL3 *>(di);
GLuint progId = drvInfo->getProgramId();
// FIXME
if (!progId)
return;
uint mvpIndex = p->getUniformIndex(CProgramIndex::ModelViewProjection);
if (mvpIndex != ~0)
{
CMatrix mvp = _GLProjMat * _ChangeBasis * _ModelViewMatrix;
setUniform4x4f(program, mvpIndex, mvp);
}
uint vmIndex = p->getUniformIndex(CProgramIndex::ViewMatrix);
if (vmIndex != ~0)
{
setUniform4x4f(program, vmIndex, _ViewMtx);
}
uint mvIndex = p->getUniformIndex(CProgramIndex::ModelView);
if (mvIndex != ~0)
{
setUniform4x4f(program, mvIndex, _ModelViewMatrix);
}
uint nmIdx = p->getUniformIndex(CProgramIndex::NormalMatrix);
if (nmIdx != ~0)
{
// normal matrix is the inverse-transpose of the rotation part of the modelview matrix
// Inverse-transpose of the rotation matrix, is itself
const float *mv = _ModelViewMatrix.get();
float nm[ 3 * 3 ];
nm[ 0 ] = mv[ 0 ];
nm[ 1 ] = mv[ 1 ];
nm[ 2 ] = mv[ 2 ];
nm[ 3 ] = mv[ 4 ];
nm[ 4 ] = mv[ 5 ];
nm[ 5 ] = mv[ 6 ];
nm[ 6 ] = mv[ 8 ];
nm[ 7 ] = mv[ 9 ];
nm[ 8 ] = mv[ 10 ];
setUniform3x3f(program, nmIdx, nm);
}
uint fogParamsIdx = p->getUniformIndex(CProgramIndex::FogParams);
if (fogParamsIdx != ~0)
nglProgramUniform2f(progId, fogParamsIdx, _FogStart, _FogEnd);
uint fogColorIdx = p->getUniformIndex(CProgramIndex::FogColor);
if (fogColorIdx != ~0)
nglProgramUniform4fv(progId, fogColorIdx, 1, _CurrentFogColor);
uint colorIndex = p->getUniformIndex(CProgramIndex::Color);
if (colorIndex != ~0)
{
GLfloat glCol[ 4 ];
CRGBA col = mat.getColor();
glCol[ 0 ] = col.R / 255.0f;
glCol[ 1 ] = col.G / 255.0f;
glCol[ 2 ] = col.B / 255.0f;
glCol[ 3 ] = col.A / 255.0f;
nglProgramUniform4f(progId, colorIndex, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ]);
}
uint alphaRefIdx = p->getUniformIndex(CProgramIndex::AlphaRef);
if (alphaRefIdx != ~0)
nglProgramUniform1f(progId, alphaRefIdx, mat.getAlphaTestThreshold());
NLMISC::CRGBAF selfIllumination = NLMISC::CRGBAF(0.0f, 0.0f, 0.0f);
NLMISC::CRGBAF matDiffuse = NLMISC::CRGBAF(mat.getDiffuse());
NLMISC::CRGBAF matSpecular = NLMISC::CRGBAF(mat.getSpecular());
for (uint i = 0; i < NL_OPENGL3_MAX_LIGHT; ++i)
{
if (!_UserLightEnable[i])
continue;
selfIllumination += NLMISC::CRGBAF(_UserLight[i].getAmbiant());
////////////////// Temporary insanity ///////////////////////////////
if ((_LightMode[i] != CLight::DirectionalLight) && (_LightMode[i] != CLight::PointLight))
continue;
//////////////////////////////////////////////////////////////////////
if (_LightMode[i] == CLight::DirectionalLight)
{
uint ld = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0DirOrPos + i));
if (ld != ~0)
{
CVector v = -1 * _UserLight[i].getDirection();
nglProgramUniform3f(progId, ld, v.x, v.y, v.z);
}
}
else
{
uint lp = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0DirOrPos + i));
if (lp != ~0)
{
CVector v = _UserLight[i].getPosition() - _PZBCameraPos;
nglProgramUniform3f(progId, lp, v.x, v.y, v.z);
}
}
uint ldc = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0ColDiff + i));
if (ldc != ~0)
{
NLMISC::CRGBAF diffuse = NLMISC::CRGBAF(_UserLight[i].getDiffuse()) * matDiffuse;
nglProgramUniform4f(progId, ldc, diffuse.R, diffuse.G, diffuse.B, 0.0f); // 1.0f?
}
uint lsc = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0ColSpec + i));
if (lsc != ~0)
{
NLMISC::CRGBAF specular = NLMISC::CRGBAF(_UserLight[i].getSpecular()) * matSpecular;
nglProgramUniform4f(progId, lsc, specular.R, specular.G, specular.B, 0.0f); // 1.0f?
}
uint shl = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0Shininess + i));
if (shl != ~0)
{
nglProgramUniform1f(progId, shl, mat.getShininess());
}
uint lca = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0ConstAttn + i));
if (lca != ~0)
{
nglProgramUniform1f(progId, lca, _UserLight[ i ].getConstantAttenuation());
}
uint lla = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0LinAttn + i));
if (lla != ~0)
{
nglProgramUniform1f(progId, lla, _UserLight[ i ].getLinearAttenuation());
}
uint lqa = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::Light0QuadAttn + i));
if (lqa != ~0)
{
nglProgramUniform1f(progId, lqa, _UserLight[ i ].getQuadraticAttenuation());
}
}
selfIllumination *= NLMISC::CRGBAF(mat.getAmbient());
if (mat.getShader() != CMaterial::LightMap) // Really?
selfIllumination += NLMISC::CRGBAF(mat.getEmissive());
int selfIlluminationId = p->getUniformIndex(CProgramIndex::TName(CProgramIndex::SelfIllumination));
if (selfIlluminationId != -1)
{
nglProgramUniform4f(progId, selfIlluminationId, selfIllumination.R, selfIllumination.G, selfIllumination.B, 0.0f);
}
}
void CDriverGL3::setupInitialUniforms(IProgram *program)
{
IProgramDrvInfos *di = program->m_DrvInfo;
if (di != NULL)
{
CProgramDrvInfosGL3 *drvInfo = static_cast<CProgramDrvInfosGL3 *>(di);
GLuint id = drvInfo->getProgramId();
for (uint i = 0; i < std::min(_Extensions.MaxFragmentTextureImageUnits, (GLint)IDRV_PROGRAM_MAXSAMPLERS); ++i)
{
uint samplerIdx = program->getUniformIndex((CProgramIndex::TName)(CProgramIndex::Sampler0 + i));
if (samplerIdx >= 0)
nglProgramUniform1i(id, samplerIdx, i);
}
}
}
bool CDriverGL3::initProgramPipeline()
{
ppoId = 0;
nglGenProgramPipelines(1, &ppoId);
if (ppoId == 0)
return false;
nglBindProgramPipeline(ppoId);
return true;
}
} // NLDRIVERGL3
} // NL3D
/* end of file */

@ -0,0 +1,140 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2014 by authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_DRIVER_OPENGL_PROGRAM_H
#define NL_DRIVER_OPENGL_PROGRAM_H
#include "nel/misc/types_nl.h"
namespace NL3D {
namespace NLDRIVERGL3 {
class CDriverGL3;
static sint TexGenDisabled = -1;
static sint TexGenReflectionMap = 0; // GL_REFLECTION_MAP_ARB
static sint TexGenSphereMap = 1; // GL_SPHERE_MAP
static sint TexGenObjectLinear = 2; // GL_OBJECT_LINEAR
static sint TexGenEyeLinear = 3; // GL_EYE_LINEAR
/// Builtin vertex program description
struct CVPBuiltin
{
CVPBuiltin() : VertexProgram(NULL) { }
uint16 VertexFormat;
bool Lighting;
sint LightMode[NL_OPENGL3_MAX_LIGHT]; // -1 when disabled
sint TexGenMode[IDRV_MAT_MAXTEXTURES]; // -1 when disabled
bool Specular; // Reflection
bool Fog;
// bool VertexColorLighted;
NLMISC::CRefPtr<CVertexProgram> VertexProgram;
};
bool operator<(const CVPBuiltin &left, const CVPBuiltin &right);
bool operator==(const CVPBuiltin &left, const CVPBuiltin &right);
static const uint64 Sampler2D = 0;
static const uint64 SamplerCube = 1;
/// Builtin pixel program description
struct CPPBuiltin
{
CPPBuiltin() : Touched(true) { }
uint16 VertexFormat;
bool Fog;
CMaterial::TShader Shader;
uint32 Flags;
uint32 TextureActive;
uint64 TexSamplerMode;
uint32 TexEnvMode[IDRV_MAT_MAXTEXTURES]; // Normal, UserColor
NLMISC::CRefPtr<CPixelProgram> PixelProgram;
bool Touched;
void checkDriverStateTouched(CDriverGL3 *driver);
void checkDriverMaterialStateTouched(CDriverGL3 *driver, CMaterial &mat);
void checkMaterialStateTouched(CMaterial &mat);
};
bool operator<(const CPPBuiltin &left, const CPPBuiltin &right);
bool operator==(const CPPBuiltin &left, const CPPBuiltin &right);
enum TAttribOffset
{
Position,
Weight,
Normal,
PrimaryColor,
SecondaryColor,
Fog,
PaletteSkin,
Empty,
TexCoord0,
TexCoord1,
TexCoord2,
TexCoord3,
TexCoord4,
TexCoord5,
TexCoord6,
TexCoord7,
NumOffsets
};
extern const uint16 g_VertexFlags[CVertexBuffer::NumValue];
extern const char *g_AttribNames[CVertexBuffer::NumValue];
extern const char *g_TexelNames[IDRV_PROGRAM_MAXSAMPLERS];
extern const char *g_ConstantNames[IDRV_PROGRAM_MAXSAMPLERS];
namespace /* anonymous */ {
inline bool hasFlag(uint32 data, uint32 flag)
{
if ((data & flag) != 0)
return true;
else
return false;
}
} /* anonymous namespace */
} // NLDRIVERGL3
} // NL3D
namespace std {
template <>
struct hash<NL3D::NLDRIVERGL3::CVPBuiltin>
{
size_t operator()(const NL3D::NLDRIVERGL3::CVPBuiltin & v) const;
};
template <>
struct hash<NL3D::NLDRIVERGL3::CPPBuiltin>
{
size_t operator()(const NL3D::NLDRIVERGL3::CPPBuiltin & v) const;
};
}
#endif // NL_DRIVER_OPENGL_PROGRAM_H
/* end of file */

@ -0,0 +1,416 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include "driver_opengl.h"
#include "nel/3d/index_buffer.h"
#include "driver_opengl_vertex_buffer.h"
namespace NL3D {
namespace NLDRIVERGL3 {
// ***************************************************************************
bool CDriverGL3::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines)
{
H_AUTO_OGL(CDriverGL3_renderLines)
// setup material
if (!setupMaterial(mat) || _LastIB._Values == NULL)
return false;
if (_CurrentVertexBufferGL && _CurrentVertexBufferGL->isInvalid()) return true;
// render primitives.
//==============================
// start multipass.
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if (!setupPass(pass))
return false;
// draw the primitives.
if (nlines)
{
if (_LastIB._Format == CIndexBuffer::Indices16)
{
glDrawElements(GL_LINES,2*nlines,GL_UNSIGNED_SHORT,((uint16 *) _LastIB._Values)+firstIndex);
}
else
{
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_LINES,2*nlines,GL_UNSIGNED_INT,((uint32 *) _LastIB._Values)+firstIndex);
}
}
}
// end multipass.
endMultiPass();
// Profiling.
_PrimitiveProfileIn.NLines+= nlines;
_PrimitiveProfileOut.NLines+= nlines;
if (_CurrentVertexBufferGL)
_CurrentVertexBufferGL->setFrameInFlight(_SwapBufferCounter);
return true;
}
// ***************************************************************************
bool CDriverGL3::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris)
{
H_AUTO_OGL(CDriverGL3_renderTriangles);
// setup material
if (!setupMaterial(mat) || _LastIB._Values == NULL)
return false;
if (_CurrentVertexBufferGL && _CurrentVertexBufferGL->isInvalid()) return true;
// render primitives.
//==============================
// start multipass.
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if (!setupPass(pass))
return false;
// draw the primitives.
if (ntris)
{
if (_LastIB._Format == CIndexBuffer::Indices16)
{
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_SHORT, ((uint16 *) _LastIB._Values)+firstIndex);
}
else
{
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstIndex);
}
}
}
// end multipass.
endMultiPass();
// Profiling.
_PrimitiveProfileIn.NTriangles+= ntris;
_PrimitiveProfileOut.NTriangles+= ntris * nPass;
if (_CurrentVertexBufferGL)
_CurrentVertexBufferGL->setFrameInFlight(_SwapBufferCounter);
return true;
}
// ***************************************************************************
bool CDriverGL3::renderSimpleTriangles(uint32 firstTri, uint32 ntris)
{
H_AUTO_OGL(CDriverGL3_renderSimpleTriangles);
nlassert(ntris>0);
if (_CurrentVertexBufferGL && _CurrentVertexBufferGL->isInvalid()) return true;
// Don't setup any material here.
// render primitives.
//==============================
// NO MULTIPASS HERE!!
// draw the primitives. (nb: ntris>0).
if (_LastIB._Format == CIndexBuffer::Indices16)
{
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_SHORT, ((uint16 *) _LastIB._Values)+firstTri);
}
else
{
nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstTri);
}
// Profiling.
_PrimitiveProfileIn.NTriangles+= ntris;
_PrimitiveProfileOut.NTriangles+= ntris;
if (_CurrentVertexBufferGL)
_CurrentVertexBufferGL->setFrameInFlight(_SwapBufferCounter);
return true;
}
// ***************************************************************************
bool CDriverGL3::renderRawPoints(CMaterial& mat, uint32 startIndex, uint32 numPoints)
{
H_AUTO_OGL(CDriverGL3_renderRawPoints)
// setup material
if (!setupMaterial(mat))
return false;
if (_CurrentVertexBufferGL && _CurrentVertexBufferGL->isInvalid()) return true;
// render primitives.
//==============================
// start multipass.
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if (!setupPass(pass))
return false;
// draw the primitives.
if (numPoints)
glDrawArrays(GL_POINTS, startIndex, numPoints);
}
// end multipass.
endMultiPass();
// Profiling.
_PrimitiveProfileIn.NPoints+= numPoints;
_PrimitiveProfileOut.NPoints+= numPoints * nPass;
if (_CurrentVertexBufferGL)
_CurrentVertexBufferGL->setFrameInFlight(_SwapBufferCounter);
return true;
}
// ***************************************************************************
bool CDriverGL3::renderRawLines(CMaterial& mat, uint32 startIndex, uint32 numLines)
{
H_AUTO_OGL(CDriverGL3_renderRawLines)
// setup material
if (!setupMaterial(mat))
return false;
if (_CurrentVertexBufferGL && _CurrentVertexBufferGL->isInvalid()) return true;
// render primitives.
//==============================
// start multipass.
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if (!setupPass(pass))
return false;
// draw the primitives.
if (numLines)
glDrawArrays(GL_LINES, startIndex << 1, numLines << 1);
}
// end multipass.
endMultiPass();
// Profiling.
_PrimitiveProfileIn.NLines += numLines ;
_PrimitiveProfileOut.NLines += numLines * nPass;
if (_CurrentVertexBufferGL)
_CurrentVertexBufferGL->setFrameInFlight(_SwapBufferCounter);
return true;
}
// ***************************************************************************
bool CDriverGL3::renderRawTriangles(CMaterial& mat, uint32 startIndex, uint32 numTris)
{
H_AUTO_OGL(CDriverGL3_renderRawTriangles)
// setup material
if (!setupMaterial(mat))
return false;
if (_CurrentVertexBufferGL && _CurrentVertexBufferGL->isInvalid()) return true;
// render primitives.
//==============================
// start multipass.
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if (!setupPass(pass))
return false;
// draw the primitives.
if (numTris)
{
glDrawArrays(GL_TRIANGLES, startIndex*3, numTris*3);
}
}
// end multipass.
endMultiPass();
// Profiling.
_PrimitiveProfileIn.NTriangles += numTris ;
_PrimitiveProfileOut.NTriangles += numTris * nPass;
if (_CurrentVertexBufferGL)
_CurrentVertexBufferGL->setFrameInFlight(_SwapBufferCounter);
return true;
}
// ***************************************************************************
bool CDriverGL3::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQuads)
{
H_AUTO_OGL(CDriverGL3_renderRawQuads)
if (!numQuads) return true;
// setup material
if (!setupMaterial(mat))
return false;
if (_CurrentVertexBufferGL && _CurrentVertexBufferGL->isInvalid()) return true;
const uint32 QUAD_BATCH_SIZE = 2048;
static GLshort defaultIndices[QUAD_BATCH_SIZE * 6];
static bool init = false;
if (!init)
{
// setup the base index buffer
for (uint k = 0; k < QUAD_BATCH_SIZE; ++k)
{
// first tri
defaultIndices[k * 6] = (GLshort) (k * 4);
defaultIndices[k * 6 + 1] = (GLshort) (k * 4 + 1);
defaultIndices[k * 6 + 2] = (GLshort) (k * 4 + 2);
// second tri
defaultIndices[k * 6 + 3] = (GLshort) (k * 4);
defaultIndices[k * 6 + 4] = (GLshort) (k * 4 + 2);
defaultIndices[k * 6 + 5] = (GLshort) (k * 4 + 3);
}
init = true;
}
// render primitives.
//==============================
// start multipass.
uint nPass;
nPass= beginMultiPass();
// draw all passes.
for (uint pass=0;pass<nPass; pass++)
{
// setup the pass.
if (!setupPass(pass))
return false;
uint32 currIndex = startIndex;
uint32 numLeftQuads = numQuads;
// draw first batch of quads using the static setupped array
if (startIndex < QUAD_BATCH_SIZE)
{
// draw first quads (as pair of tri to have guaranteed orientation)
uint numQuadsToDraw = std::min(QUAD_BATCH_SIZE - startIndex, numQuads);
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_SHORT, defaultIndices + 6 * startIndex);
numLeftQuads -= numQuadsToDraw;
currIndex += 4 * numQuadsToDraw;
}
// draw remaining quads
while (numLeftQuads)
{
// TODO : resetting vertex pointer would avoid the need to rebuild indices each times
uint32 numQuadsToDraw = std::min(numLeftQuads, QUAD_BATCH_SIZE);
// draw all quads
if (4 * numQuadsToDraw + currIndex <= (1 << 16))
{
// indices fits on 16 bits
GLshort indices[QUAD_BATCH_SIZE * 6];
GLshort *curr = indices;
GLshort *end = indices + 6 * numQuadsToDraw;
uint16 vertexIndex = (uint16) currIndex;
do
{
*curr++ = vertexIndex;
*curr++ = vertexIndex + 1;
*curr++ = vertexIndex + 2;
*curr++ = vertexIndex;
*curr++ = vertexIndex + 2;
*curr++ = vertexIndex + 3;
vertexIndex += 4;
}
while (curr != end);
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_SHORT, indices);
}
else
{
// indices fits on 32 bits
GLint indices[QUAD_BATCH_SIZE];
GLint *curr = indices;
GLint *end = indices + 6 * numQuadsToDraw;
uint32 vertexIndex = currIndex;
do
{
*curr++ = vertexIndex;
*curr++ = vertexIndex + 1;
*curr++ = vertexIndex + 2;
*curr++ = vertexIndex;
*curr++ = vertexIndex + 2;
*curr++ = vertexIndex + 3;
vertexIndex += 4;
}
while (curr != end);
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices);
}
numLeftQuads -= numQuadsToDraw;
currIndex += 4 * numQuadsToDraw;
}
}
// end multipass.
endMultiPass();
// Profiling.
_PrimitiveProfileIn.NQuads += numQuads ;
_PrimitiveProfileOut.NQuads += numQuads * nPass;
if (_CurrentVertexBufferGL)
_CurrentVertexBufferGL->setFrameInFlight(_SwapBufferCounter);
return true;
}
}
}

@ -0,0 +1,64 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#if 0
#include "driver_opengl_shader_cache.h"
namespace NL3D
{
CShaderCache::CShaderCache()
{
}
CShaderCache::~CShaderCache()
{
clearCache();
}
SShaderPair CShaderCache::findShader(const CShaderDesc &desc) const
{
for (int i = 0; i < shaders.size(); i++)
{
if (shaders[ i ] == desc)
return shaders[ i ].getShaders();
}
return SShaderPair();
}
void CShaderCache::cacheShader(CShaderDesc &desc)
{
shaders.push_back(desc);
}
void CShaderCache::clearCache()
{
std::vector< CShaderDesc >::iterator itr = shaders.begin();
while (itr != shaders.end())
{
SShaderPair sp;
sp = itr->getShaders();
delete sp.vp;
delete sp.pp;
++itr;
}
shaders.clear();
}
}
#endif

@ -0,0 +1,52 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#if 0
#ifndef OPENGL_SHADER_CACHE
#define OPENGL_SHADER_CACHE
#include "driver_opengl_shader_desc.h"
#include <vector>
namespace NL3D
{
/// Caches generated shaders, so they don't have to be generated every frame
class CShaderCache
{
public:
CShaderCache();
~CShaderCache();
/// Checks if there's a shader cached that was generated from the specified descriptor
SShaderPair findShader(const CShaderDesc &desc) const;
/// Caches a shader with the specified descriptor as key
void cacheShader(CShaderDesc &desc);
/// Clears the caches, removes the cached shaders
void clearCache();
private:
std::vector< CShaderDesc > shaders;
};
}
#endif
#endif

@ -0,0 +1,291 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#if 0
#ifndef SHADER_DESC
#define SHADER_DESC
#include "nel/misc/types_nl.h"
#include "driver_opengl_program.h"
namespace NL3D
{
class CVertexProgram;
class CPixelProgram;
//static uint8 Sampler2D = 0;
//static uint8 SamplerCube = 1;
struct SShaderPair
{
SShaderPair()
{
vp = NULL;
pp = NULL;
}
~SShaderPair()
{
vp = NULL;
pp = NULL;
}
bool empty() const{
if ((vp == NULL) && (pp == NULL))
return true;
else
return false;
}
CVertexProgram *vp;
CPixelProgram *pp;
};
class CShaderDesc
{
public:
enum TShaderType
{
Normal,
Bump_unused,
UserColor,
LightMap,
Specular,
Caustics_unused,
PerPixelLighting,
PerPixelNoSpecular,
Cloud,
Water
};
enum TFogMode
{
Exponential,
Exponential2,
Linear
};
enum TLightMode
{
Nolight,
Directional,
Point,
Spot
};
CShaderDesc() {
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
texEnvMode[i] = 0;
for (int i = 0; i < NL_OPENGL3_MAX_LIGHT; i++)
lightMode[i] = Nolight;
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
{
useTextureStage[i] = false;
textureSamplerMode[i] = Sampler2D;
}
//useFirstTextureCoordSet = false;
noTextures = true;
features = None;
shaderType = Normal;
vbFlags = 0;
nlightmaps = 0;
alphaTestTreshold = 0.5f;
fogMode = Linear;
pointLight = false;
}
~CShaderDesc() {
}
bool operator==(const CShaderDesc &o) const
{
if (noTextures != o.noTextures)
return false;
if (shaderType != o.shaderType)
return false;
if (vbFlags != o.vbFlags)
return false;
if (nlightmaps != o.nlightmaps)
return false;
if (features != o.features)
return false;
if ((features & AlphaTest) != 0)
{
if (alphaTestTreshold > o.alphaTestTreshold + 0.0001f)
return false;
if (alphaTestTreshold < o.alphaTestTreshold - 0.0001f)
return false;
}
if (fogEnabled())
{
if (fogMode != o.fogMode)
return false;
}
if (shaderType == Normal)
{
//if (useFirstTextureCoordSet != o.useFirstTextureCoordSet)
// return false;
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
if (texEnvMode[ i ] != o.texEnvMode[ i ])
return false;
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
if (textureSamplerMode[ i ] != o.textureSamplerMode[ i ])
return false;
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
if (useTextureStage[ i ] != o.useTextureStage[ i ])
return false;
}
if (lightingEnabled())
{
for (int i = 0; i < NL_OPENGL3_MAX_LIGHT; i++)
if (lightMode[ i ] != o.lightMode[ i ])
return false;
}
return true;
}
void setTexEnvMode(uint32 index, uint32 mode) { texEnvMode[ index ] = mode; }
//void setUseFirstTexCoords(bool b) { useFirstTextureCoordSet = b; }
//bool getUseFirstTexCoords() const{ return useFirstTextureCoordSet; }
void setUseTexStage(uint8 stage, bool b) { useTextureStage[ stage ] = b; }
bool getUseTexStage(uint8 stage) const{ return useTextureStage[ stage ]; }
void setNoTextures(bool b) { noTextures = b; }
bool useTextures() const{ return !noTextures; }
void setVBFlags(uint32 flags) { vbFlags = flags; }
bool hasVBFlags(uint32 flags) const{
if ((vbFlags & flags) != 0)
return true;
else
return false;
}
void setShaderType(uint32 type) { shaderType = type; }
void setNLightMaps(uint32 n) { nlightmaps = n; }
void setAlphaTest(bool b)
{
if (b)
features |= AlphaTest;
else
features &= ~AlphaTest;
}
void setAlphaTestThreshold(float t) { alphaTestTreshold = t; }
void setFog(bool b)
{
if (b)
features |= Fog;
else
features &= ~Fog;
}
bool fogEnabled() const
{
if ((features & Fog) != 0)
return true;
else
return false;
}
void setFogMode(TFogMode mode) { fogMode = mode; }
uint32 getFogMode() const{ return fogMode; }
void setLighting(bool b)
{
if (b)
features |= Lighting;
else
features &= ~Lighting;
}
bool lightingEnabled() const
{
if ((features & Lighting) != 0)
return true;
else
return false;
}
void setLight(int idx, TLightMode mode)
{
lightMode[ idx ] = mode;
if (mode == Point)
pointLight = true;
}
TLightMode getLight(int idx) const{ return lightMode[ idx ]; }
bool hasPointLight() const{ return pointLight; }
void setShaders(SShaderPair sp) { shaderPair = sp; }
SShaderPair getShaders() const{ return shaderPair; }
public:
enum TShaderFeatures
{
None = 0,
AlphaTest = 1,
Fog = 2,
Lighting = 4
};
uint32 features;
uint32 texEnvMode[IDRV_MAT_MAXTEXTURES];
bool useTextureStage[IDRV_MAT_MAXTEXTURES];
uint8 textureSamplerMode[IDRV_MAT_MAXTEXTURES];
//bool useFirstTextureCoordSet;
bool noTextures;
uint32 vbFlags;
uint32 shaderType;
uint32 nlightmaps;
float alphaTestTreshold;
uint32 fogMode;
TLightMode lightMode[NL_OPENGL3_MAX_LIGHT];
bool pointLight;
SShaderPair shaderPair;
};
}
#endif
#endif

@ -0,0 +1,424 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include "driver_opengl.h"
// ***************************************************************************
// define it For Debug purpose only. Normal use is to hide this line
//#define NL3D_GLSTATE_DISABLE_CACHE
namespace NL3D {
namespace NLDRIVERGL3 {
// ***************************************************************************
CDriverGLStates3::CDriverGLStates3()
{
H_AUTO_OGL(CDriverGLStates3_CDriverGLStates)
_CurrARBVertexBuffer = 0;
_DepthRangeNear = 0.f;
_DepthRangeFar = 1.f;
_ZBias = 0.f;
_CullMode = CCW;
}
// ***************************************************************************
void CDriverGLStates3::init()
{
H_AUTO_OGL(CDriverGLStates3_init)
// By default all arrays are disabled.
for (uint i = 0; i < CVertexBuffer::NumValue; ++i)
_VertexAttribArrayEnabled[i] = false;
_DepthRangeNear = 0.f;
_DepthRangeFar = 1.f;
_ZBias = 0.f;
}
// ***************************************************************************
void CDriverGLStates3::forceDefaults(uint nbStages)
{
H_AUTO_OGL(CDriverGLStates3_forceDefaults);
// Enable / disable.
_CurBlend = false;
_CurCullFace = true;
_CurZWrite = true;
_CurStencilTest =false;
// setup GLStates.
glDisable(GL_BLEND);
glEnable(GL_CULL_FACE);
glDepthMask(GL_TRUE);
// Func.
_CurBlendSrc = GL_SRC_ALPHA;
_CurBlendDst = GL_ONE_MINUS_SRC_ALPHA;
_CurDepthFunc = GL_LEQUAL;
_CurStencilFunc = GL_ALWAYS;
_CurStencilRef = 0;
_CurStencilMask = std::numeric_limits<GLuint>::max();
_CurStencilOpFail = GL_KEEP;
_CurStencilOpZFail = GL_KEEP;
_CurStencilOpZPass = GL_KEEP;
_CurStencilWriteMask = std::numeric_limits<GLuint>::max();
// setup GLStates.
glBlendFunc(_CurBlendSrc, _CurBlendDst);
glDepthFunc(_CurDepthFunc);
glStencilFunc(_CurStencilFunc, _CurStencilRef, _CurStencilMask);
glStencilOp(_CurStencilOpFail, _CurStencilOpZFail, _CurStencilOpZPass);
glStencilMask(_CurStencilWriteMask);
// setup GLStates.
static const GLfloat one[4] = { 1, 1, 1, 1 };
static const GLfloat zero[4] = { 0, 0, 0, 1 };
// TexModes
// FIXME GL3 TEXTUREMODE for (uint stage = 0; stage < nbStages; ++stage)
// FIXME GL3 TEXTUREMODE {
// disable texturing.
// FIXME GL3 TEXTUREMODE nglActiveTexture(GL_TEXTURE0 + stage);
// FIXME GL3 TEXTUREMODE glDisable(GL_TEXTURE_2D);
// FIXME GL3 TEXTUREMODE glDisable(GL_TEXTURE_CUBE_MAP);
// FIXME GL3 TEXTUREMODE glDisable(GL_TEXTURE_RECTANGLE);
// FIXME GL3 TEXTUREMODE _TextureMode[stage]= TextureDisabled;
// FIXME GL3 TEXTUREMODE }
// etc
// ActiveTexture current texture to 0.
nglActiveTexture(GL_TEXTURE0);
_CurrentActiveTexture = 0;
// Depth range
_DepthRangeNear = 0.f;
_DepthRangeFar = 1.f;
_ZBias = 0.f;
glDepthRange (0, 1);
// Cull order
_CullMode = CCW;
glCullFace(GL_BACK);
}
// ***************************************************************************
void CDriverGLStates3::enableBlend(uint enable)
{
H_AUTO_OGL(CDriverGLStates3_enableBlend)
// If different from current setup, update.
bool enabled= (enable!=0);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (enabled != _CurBlend)
#endif
{
// new state.
_CurBlend= enabled;
// Setup GLState.
if (_CurBlend)
glEnable(GL_BLEND);
else
glDisable(GL_BLEND);
}
}
// ***************************************************************************
void CDriverGLStates3::enableCullFace(uint enable)
{
H_AUTO_OGL(CDriverGLStates3_enableCullFace)
// If different from current setup, update.
bool enabled= (enable!=0);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (enabled != _CurCullFace)
#endif
{
// new state.
_CurCullFace= enabled;
// Setup GLState.
if (_CurCullFace)
glEnable(GL_CULL_FACE);
else
glDisable(GL_CULL_FACE);
}
}
// ***************************************************************************
void CDriverGLStates3::enableZWrite(uint enable)
{
H_AUTO_OGL(CDriverGLStates3_enableZWrite)
// If different from current setup, update.
bool enabled= (enable!=0);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (enabled != _CurZWrite)
#endif
{
// new state.
_CurZWrite= enabled;
// Setup GLState.
if (_CurZWrite)
glDepthMask(GL_TRUE);
else
glDepthMask(GL_FALSE);
}
}
// ***************************************************************************
void CDriverGLStates3::enableStencilTest(bool enable)
{
H_AUTO_OGL(CDriverGLStates3_enableStencilTest);
// If different from current setup, update.
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (enable != _CurStencilTest)
#endif
{
// new state.
_CurStencilTest= enable;
// Setup GLState.
if (_CurStencilTest)
glEnable(GL_STENCIL_TEST);
else
glDisable(GL_STENCIL_TEST);
}
}
// ***************************************************************************
void CDriverGLStates3::blendFunc(GLenum src, GLenum dst)
{
H_AUTO_OGL(CDriverGLStates3_blendFunc)
// If different from current setup, update.
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (src!= _CurBlendSrc || dst!=_CurBlendDst)
#endif
{
// new state.
_CurBlendSrc= src;
_CurBlendDst= dst;
// Setup GLState.
glBlendFunc(_CurBlendSrc, _CurBlendDst);
}
}
// ***************************************************************************
void CDriverGLStates3::depthFunc(GLenum zcomp)
{
H_AUTO_OGL(CDriverGLStates3_depthFunc)
// If different from current setup, update.
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (zcomp != _CurDepthFunc)
#endif
{
// new state.
_CurDepthFunc= zcomp;
// Setup GLState.
glDepthFunc(_CurDepthFunc);
}
}
// ***************************************************************************
void CDriverGLStates3::stencilFunc(GLenum func, GLint ref, GLuint mask)
{
H_AUTO_OGL(CDriverGLStates3_stencilFunc)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if ((func!=_CurStencilFunc) || (ref!=_CurStencilRef) || (mask!=_CurStencilMask))
#endif
{
// new state
_CurStencilFunc = func;
_CurStencilRef = ref;
_CurStencilMask = mask;
// setup function.
glStencilFunc(_CurStencilFunc, _CurStencilRef, _CurStencilMask);
}
}
// ***************************************************************************
void CDriverGLStates3::stencilOp(GLenum fail, GLenum zfail, GLenum zpass)
{
H_AUTO_OGL(CDriverGLStates3_stencilOp)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if ((fail!=_CurStencilOpFail) || (zfail!=_CurStencilOpZFail) || (zpass!=_CurStencilOpZPass))
#endif
{
// new state
_CurStencilOpFail = fail;
_CurStencilOpZFail = zfail;
_CurStencilOpZPass = zpass;
// setup function.
glStencilOp(_CurStencilOpFail, _CurStencilOpZFail, _CurStencilOpZPass);
}
}
// ***************************************************************************
void CDriverGLStates3::stencilMask(GLuint mask)
{
H_AUTO_OGL(CDriverGLStates3_stencilMask)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (mask!=_CurStencilWriteMask)
#endif
{
// new state
_CurStencilWriteMask = mask;
// setup function.
glStencilMask(_CurStencilWriteMask);
}
}
// ***************************************************************************
static void convColor(CRGBA col, GLfloat glcol[4])
{
H_AUTO_OGL(convColor)
static const float OO255= 1.0f/255;
glcol[0]= col.R*OO255;
glcol[1]= col.G*OO255;
glcol[2]= col.B*OO255;
glcol[3]= col.A*OO255;
}
// ***************************************************************************
void CDriverGLStates3::updateDepthRange()
{
H_AUTO_OGL(CDriverGLStates3_updateDepthRange);
float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear);
glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar);
}
// ***************************************************************************
void CDriverGLStates3::setZBias(float zbias)
{
H_AUTO_OGL(CDriverGLStates3_setZBias)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (zbias != _ZBias)
#endif
{
_ZBias = zbias;
updateDepthRange();
}
}
// ***************************************************************************
void CDriverGLStates3::setDepthRange(float znear, float zfar)
{
H_AUTO_OGL(CDriverGLStates3_setDepthRange)
nlassert(znear != zfar);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (znear != _DepthRangeNear || zfar != _DepthRangeFar)
#endif
{
_DepthRangeNear = znear;
_DepthRangeFar = zfar;
updateDepthRange();
}
}
// ***************************************************************************
void CDriverGLStates3::activeTexture(uint stage)
{
H_AUTO_OGL(CDriverGLStates3_activeTexture);
if (_CurrentActiveTexture != stage)
{
nglActiveTexture(GL_TEXTURE0 + stage);
_CurrentActiveTexture = stage;
}
}
// ***************************************************************************
void CDriverGLStates3::forceActiveTexture(uint stage)
{
H_AUTO_OGL(CDriverGLStates3_forceActiveTexture);
nglActiveTexture(GL_TEXTURE0 + stage);
_CurrentActiveTexture= stage;
}
// ***************************************************************************
void CDriverGLStates3::enableVertexAttribArrayARB(uint glIndex,bool enable)
{
H_AUTO_OGL(CDriverGLStates3_enableVertexAttribArrayARB);
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (_VertexAttribArrayEnabled[glIndex] != enable)
#endif
{
if (enable)
nglEnableVertexAttribArray(glIndex);
else
nglDisableVertexAttribArray(glIndex);
_VertexAttribArrayEnabled[glIndex]= enable;
}
}
// ***************************************************************************
void CDriverGLStates3::forceBindARBVertexBuffer(uint objectID)
{
H_AUTO_OGL(CDriverGLStates3_forceBindARBVertexBuffer)
nglBindBuffer(GL_ARRAY_BUFFER, objectID);
_CurrARBVertexBuffer = objectID;
}
// ***************************************************************************
void CDriverGLStates3::bindARBVertexBuffer(uint objectID)
{
H_AUTO_OGL(CDriverGLStates3_bindARBVertexBuffer)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (objectID != _CurrARBVertexBuffer)
#endif
{
forceBindARBVertexBuffer(objectID);
}
}
// ***************************************************************************
void CDriverGLStates3::setCullMode(TCullMode cullMode)
{
H_AUTO_OGL(CDriverGLStates3_setCullMode)
#ifndef NL3D_GLSTATE_DISABLE_CACHE
if (cullMode != _CullMode)
#endif
{
glCullFace(cullMode == CCW ? GL_BACK : GL_FRONT);
_CullMode = cullMode;
}
}
// ***************************************************************************
CDriverGLStates3::TCullMode CDriverGLStates3::getCullMode() const
{
H_AUTO_OGL(CDriverGLStates3_CDriverGLStates)
return _CullMode;
}
} // NLDRIVERGL3
} // NL3D

@ -0,0 +1,176 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_DRIVER_OPENGL_STATES_H
#define NL_DRIVER_OPENGL_STATES_H
#include "nel/misc/types_nl.h"
#include "nel/3d/vertex_buffer.h"
namespace NL3D {
namespace NLDRIVERGL3 {
// ***************************************************************************
/**
* Class for optimizing calls to openGL states, by caching old ones.
* All following call with OpenGL must be done with only one instance of this class:
- glEnable() glDisable() with:
- GL_BLEND
- GL_CULL_FACE
- GL_ALPHA_TEST
- GL_LIGHTING
- GL_LIGHT0 + i .....
- GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP/OES.
- GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R
- GL_COLOR_MATERIAL
- GL_FOG
- GL_MULTISAMPLE_ARB
- glActiveTexture()
- glClientActiveTexture()
- glEnableClientState() glDisableClientState() with:
- GL_VERTEX_ARRAY
- GL_NORMAL_ARRAY
- GL_VERTEX_WEIGHTING_EXT
- GL_COLOR_ARRAY
- GL_SECONDARY_COLOR_ARRAY_EXT
- GL_TEXTURE_COORD_ARRAY
- GL_VERTEX_ATTRIB_ARRAY0_NV + i.
- glDepthMask()
- glAlphaFunc()
- glBlendFunc()
- glDepthFunc()
- glMaterialf() and glMaterialfv() for:
- GL_EMISSION
- GL_AMBIENT
- GL_DIFFUSE
- GL_SPECULAR
- GL_SHININESS
- glDepthRange()
- glColorMaterial()
- glTexGeni()
* \author Lionel Berenguier
* \author Nevrax France
* \date 2001
*/
class CDriverGLStates3
{
public:
/// Constructor. no-op.
CDriverGLStates3();
// init. Do it just after setDisplay()
void init();
/// Reset all OpenGL states of interest to default, and update caching. This don't apply to light.
void forceDefaults(uint nbTextureStages);
/// \name enable if !0
// @{
void enableBlend(uint enable);
void enableCullFace(uint enable);
/// enable and set good AlphaFunc.
void enableZWrite(uint enable);
/// enable/disable stencil test
void enableStencilTest(bool enable);
bool isStencilTestEnabled() const { return _CurStencilTest; }
// @}
/// glBlendFunc.
void blendFunc(GLenum src, GLenum dst);
/// glDepthFunc.
void depthFunc(GLenum zcomp);
/// glStencilFunc
void stencilFunc(GLenum stencilFunc, GLint ref, GLuint mask);
/// glStencilOp
void stencilOp(GLenum fail, GLenum zfail, GLenum zpass);
/// glStencilMask
void stencilMask(uint mask);
/// \name Material setting.
/// Each f() get an uint32 for fast comparison, and OpenGL colors.
// @{
void setDepthRange (float znear, float zfar);
void getDepthRange(float &znear, float &zfar) const { znear = _DepthRangeNear; zfar = _DepthRangeFar; }
/** Set z-bias
* NB : this is done in window coordinate, not in world coordinate as with CMaterial
*/
void setZBias(float zbias);
// @}
/// \name Texture Mode setting.
// @{
/// same as glActiveTexture(). useful for setTextureMode.
void activeTexture(uint stage);
/// same as active texture arb, but with no cache check
void forceActiveTexture(uint stage);
/// get active texture
uint getActiveTexture() const { return _CurrentActiveTexture; }
// @}
// special version for ARB_vertex_program used with ARB_vertex_buffer or ATI_vertex_attrib_array_object
void enableVertexAttribArrayARB(uint glIndex, bool enable);
// ARB_vertex_buffer_object buffer binding
void bindARBVertexBuffer(uint objectID);
void forceBindARBVertexBuffer(uint objectID);
uint getCurrBoundARBVertexBuffer() const { return _CurrARBVertexBuffer; }
enum TCullMode { CCW = 0, CW };
void setCullMode(TCullMode cullMode);
TCullMode getCullMode() const;
private:
bool _CurBlend;
bool _CurCullFace;
bool _CurZWrite;
bool _CurStencilTest;
GLenum _CurBlendSrc;
GLenum _CurBlendDst;
GLenum _CurDepthFunc;
GLenum _CurStencilFunc;
GLint _CurStencilRef;
GLuint _CurStencilMask;
GLenum _CurStencilOpFail;
GLenum _CurStencilOpZFail;
GLenum _CurStencilOpZPass;
GLuint _CurStencilWriteMask;
uint _CurrentActiveTexture;
bool _VertexAttribArrayEnabled[CVertexBuffer::NumValue];
uint _CurrARBVertexBuffer;
float _DepthRangeNear;
float _DepthRangeFar;
float _ZBias; // NB : zbias is in window coordinates
TCullMode _CullMode;
private:
void updateDepthRange();
};
} // NLDRIVERGL3
} // NL3D
#endif // NL_DRIVER_OPENGL_STATES_H
/* End of driver_opengl_states.h */

File diff suppressed because it is too large Load Diff

@ -0,0 +1,106 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2014 by authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include "driver_opengl.h"
#include "driver_opengl_uniform_buffer.h"
#include <sstream>
#include <nel/misc/debug.h>
namespace NL3D {
namespace NLDRIVERGL3 {
const char *GLSLHeaderUniformBuffer =
"#define NL_BUILTIN_CAMERA_BINDING " NL_MACRO_TO_STR(NL_BUILTIN_CAMERA_BIND) "\n"
"#define NL_BUILTIN_MODEL_BINDING " NL_MACRO_TO_STR(NL_BUILTIN_MODEL_BIND) "\n"
"#define NL_BUILTIN_MATERIAL_BINDING " NL_MACRO_TO_STR(NL_BUILTIN_MATERIAL_BIND) "\n"
"#define NL_USER_ENV_BINDING " NL_MACRO_TO_STR(NL_USER_ENV_BIND) "\n"
"#define NL_USER_VERTEX_PROGRAM_BINDING " NL_MACRO_TO_STR(NL_USER_VERTEX_PROGRAM_BIND) "\n"
"#define NL_USER_GEOMETRY_PROGRAM_BINDING " NL_MACRO_TO_STR(NL_USER_GEOMETRY_PROGRAM_BIND) "\n"
"#define NL_USER_PIXEL_PROGRAM_BINDING " NL_MACRO_TO_STR(NL_USER_PIXEL_PROGRAM_BIND) "\n"
"#define NL_USER_MATERIAL_BINDING " NL_MACRO_TO_STR(NL_USER_MATERIAL_BIND) "\n";
static const char *s_UniformBufferBindDefine[] = {
"NL_BUILTIN_CAMERA_BINDING",
"NL_BUILTIN_MODEL_BINDING",
"NL_BUILTIN_MATERIAL_BINDING",
"NL_USER_ENV_BINDING",
"NL_USER_VERTEX_PROGRAM_BINDING",
"NL_USER_GEOMETRY_PROGRAM_BINDING",
"NL_USER_PIXEL_PROGRAM_BINDING",
"NL_USER_MATERIAL_BINDING",
};
static const char *s_UniformBufferName[] = {
"BuiltinCamera",
"BuiltinModel",
"BuiltinMaterial",
"UserEnv",
"UserLocal", // Yes, there can only be one per stage here, as these are bound to the stage
"UserLocal",
"UserLocal",
"UserMaterial",
};
static const char *s_TypeKeyword[] = {
"float", // float
"vec2", // CVector2D
"vec3",
"vec4", // CVector
"int", // sint32
"ivec2",
"ivec3",
"ivec3",
"unsigned int", // uint32
"uvec2",
"uvec3",
"uvec4",
"bool",
"bvec2",
"bvec3",
"bvec4",
"mat2",
"mat3",
"mat4", // CMatrix
"mat2x3",
"mat2x4",
"mat3x2",
"mat3x4",
"mat4x2",
"mat4x3",
};
void generateUniformBufferGLSL(std::stringstream &ss, const CUniformBufferFormat &ubf, sint binding)
{
ss << "layout(std140, binding = " << s_UniformBufferBindDefine[binding] << ") uniform " << s_UniformBufferName[binding] << "\n";
ss << "{\n";
for (sint i = 0; i < ubf.count(); ++i)
{
const CUniformBufferFormat::CEntry &entry = ubf.get(i);
ss << "\t" << s_TypeKeyword[entry.Type] << " " << NLMISC::CStringMapper::unmap(entry.Name);
if (entry.Count != 1)
ss << "[" << entry.Count << "]";
ss << ";\n";
}
ss << "}\n";
}
} // NLDRIVERGL3
} // NL3D
/* end of file */

@ -0,0 +1,53 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2014 by authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_DRIVER_OPENGL_UNIFORM_BUFFER_H
#define NL_DRIVER_OPENGL_UNIFORM_BUFFER_H
#include <nel/misc/types_nl.h>
#include <nel/3d/uniform_buffer_format.h>
#define NL3D_GL3_UNIFORM_BUFFER_DEBUG 1
namespace NL3D {
namespace NLDRIVERGL3 {
// NOTE: It is completely safe to reorder these indices.
// When changing, update:
// - GLSLHeaderUniformBuffer
// - s_UniformBufferBindDefine
// - s_UniformBufferBindName
// Always use the defines.
#define NL_BUILTIN_CAMERA_BINDING 0 // Builtin uniform buffer bound by driver, set by camera transformation
#define NL_BUILTIN_MODEL_BINDING 1 // Builtin uniform buffer bound by driver, set by model transformation
#define NL_BUILTIN_MATERIAL_BINDING 2 // Builtin uniform buffer bound by material
#define NL_USER_ENV_BINDING 3 // User-specified uniform buffer bound by user
#define NL_USER_VERTEX_PROGRAM_BINDING 4 // User-specified uniform buffer bound by vertex program
#define NL_USER_GEOMETRY_PROGRAM_BINDING 5 // User-specified uniform buffer bound by geometry program
#define NL_USER_PIXEL_PROGRAM_BINDING 6 // User-specified uniform buffer bound by pixel program
#define NL_USER_MATERIAL_BINDING 7 // User-specified uniform buffer bound by material
extern const char *GLSLHeaderUniformBuffer;
void generateUniformBufferGLSL(std::stringstream &ss, const CUniformBufferFormat &ubf, sint binding);
} // NLDRIVERGL3
} // NL3D
#endif // NL_DRIVER_OPENGL_UNIFORM_BUFFER_H
/* end of file */

@ -0,0 +1,549 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include "driver_opengl.h"
#include "nel/3d/index_buffer.h"
#include "driver_opengl_vertex_buffer.h"
using namespace std;
using namespace NLMISC;
// ***************************************************************************
// Flags for software vertex skinning.
#define NL3D_DRV_SOFTSKIN_VNEEDCOMPUTE 3
#define NL3D_DRV_SOFTSKIN_VMUSTCOMPUTE 1
#define NL3D_DRV_SOFTSKIN_VCOMPUTED 0
// 3 means "vertex may need compute".
// 1 means "Primitive say vertex must be computed".
// 0 means "vertex is computed".
// 500K min.
#define NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE (512*1024)
namespace NL3D {
namespace NLDRIVERGL3 {
// ***************************************************************************
CVBDrvInfosGL3::CVBDrvInfosGL3(CDriverGL3 *drv, ItVBDrvInfoPtrList it, CVertexBuffer *vb) : IVBDrvInfos(drv, it, vb)
{
H_AUTO_OGL(CVBDrvInfosGL_CVBDrvInfosGL)
_DriverGL = drv;
_VBHard = NULL;
}
// ***************************************************************************
CVBDrvInfosGL3::~CVBDrvInfosGL3()
{
H_AUTO_OGL(CVBDrvInfosGL_CVBDrvInfosGLDtor)
// Restaure non resident memory
if (VertexBufferPtr)
{
VertexBufferPtr->setLocation(CVertexBuffer::NotResident);
VertexBufferPtr = NULL;
}
if (_VBHard)
{
_VBHard->disable();
_DriverGL->_VertexBufferGLSet.erase(_VBHard);
}
_VBHard = NULL;
}
// ***************************************************************************
uint8 *CVBDrvInfosGL3::lock (uint /* first */, uint /* last */, bool /* readOnly */)
{
H_AUTO_OGL(CVBDrvInfosGL_lock)
return (uint8*)_VBHard->lock ();
}
// ***************************************************************************
void CVBDrvInfosGL3::unlock (uint first, uint last)
{
H_AUTO_OGL(CVBDrvInfosGL_unlock)
_VBHard->unlock(first, last);
}
// ***************************************************************************
bool CDriverGL3::setupVertexBuffer(CVertexBuffer& VB)
{
H_AUTO_OGL(CDriverGL3_setupVertexBuffer)
// 2. If necessary, do modifications.
//==================================
const bool touched = (VB.getTouchFlags() & (CVertexBuffer::TouchedReserve|CVertexBuffer::TouchedVertexFormat)) != 0;
if (touched || (VB.DrvInfos == NULL))
{
// delete first
if (VB.DrvInfos)
delete VB.DrvInfos;
VB.DrvInfos = NULL;
// create only if some vertices
if (VB.getNumVertices())
{
// 1. Retrieve/Create driver shader.
//==================================
// insert into driver list. (so it is deleted when driver is deleted).
ItVBDrvInfoPtrList it= _VBDrvInfos.insert(_VBDrvInfos.end(), (NL3D::IVBDrvInfos*)NULL);
// create and set iterator, for future deletion.
CVBDrvInfosGL3 *info = new CVBDrvInfosGL3(this, it, &VB);
*it= VB.DrvInfos = info;
// Preferred memory, reduce choices
CVertexBuffer::TPreferredMemory preferred = VB.getPreferredMemory();
const uint size = VB.capacity()*VB.getVertexSize();
// Vertex buffer hard
info->_VBHard = createVertexBufferGL(size, VB.capacity(), preferred, &VB);
// Upload the data
CVertexBuffer::TLocation location;
if (info->_VBHard->VBType == IVertexBufferGL3::AMDPinned)
{
// FIXME: May actually be considered CVertexBuffer::AGPResident, however only RAMResident allows reading
// TODO: Verify how the vegetation vb allocator handles RAMResident/AGPResident
location = CVertexBuffer::RAMResident;
}
else
{
switch (preferred)
{
case CVertexBuffer::StaticPreferred:
if (getStaticMemoryToVRAM())
location = CVertexBuffer::VRAMResident;
else
location = CVertexBuffer::AGPResident;
case CVertexBuffer::RAMVolatile:
case CVertexBuffer::RAMPreferred:
location = CVertexBuffer::RAMResident;
case CVertexBuffer::AGPPreferred:
case CVertexBuffer::AGPVolatile:
default:
location = CVertexBuffer::AGPResident;
}
}
VB.setLocation(location);
}
}
return true;
}
// ***************************************************************************
bool CDriverGL3::activeVertexBuffer(CVertexBuffer& VB)
{
H_AUTO_OGL(CDriverGL3_activeVertexBuffer)
// NB: must duplicate changes in activeVertexBufferHard()
uint32 flags;
// setup
if (!setupVertexBuffer(VB))
return false;
if (VB.getNumVertices()==0)
return true;
// Fill the buffer if in local memory
VB.fillBuffer ();
// Get VB flags, to setup matrixes and arrays.
flags=VB.getVertexFormat();
// 2. Setup Arrays.
//===================
// For MultiPass Material.
CVBDrvInfosGL3 *info= safe_cast<CVBDrvInfosGL3*>((IVBDrvInfos*)VB.DrvInfos);
if (!info->_VBHard || (info->_VBHard && !info->_VBHard->isInvalid()))
_LastVB.setupVertexBuffer(VB);
if (info->_VBHard == NULL)
{
// Disable the current vertexBufferHard if setuped.
if (_CurrentVertexBufferGL)
_CurrentVertexBufferGL->disable();
}
else
{
// 2. Setup Arrays.
//===================
// Enable the vertexArrayRange of this array.
info->_VBHard->enable();
}
if (!info->_VBHard || (info->_VBHard && !info->_VBHard->isInvalid()))
{
setupGlArrays(_LastVB);
}
return true;
}
// ***************************************************************************
bool CDriverGL3::activeIndexBuffer(CIndexBuffer& IB)
{
H_AUTO_OGL(CDriverGL3_activeIndexBuffer)
_LastIB.setupIndexBuffer(IB);
return true;
}
// ***************************************************************************
// ***************************************************************************
// VertexBufferHard
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
bool CDriverGL3::supportVolatileVertexBuffer() const
{
H_AUTO_OGL(CDriverGL3_supportVolatileVertexBuffer)
return true; // Supported by GL_MAP_INVALIDATE_BUFFER_BIT
}
// ***************************************************************************
bool CDriverGL3::slowUnlockVertexBufferHard() const
{
H_AUTO_OGL(CDriverGL3_slowUnlockVertexBufferHard)
return false; // Always false gives slightly better performance on AMD. Might make difference with _Extensions.AMDPinnedMemory
}
// ***************************************************************************
uint CDriverGL3::getMaxVerticesByVertexBufferHard() const
{
H_AUTO_OGL(CDriverGL3_getMaxVerticesByVertexBufferHard)
return std::numeric_limits<uint32>::max();
}
// TODO: Move this to CVertexBufferGL3
GLenum CDriverGL3::vertexBufferUsageGL3(CVertexBuffer::TPreferredMemory usage)
{
switch (usage)
{
case CVertexBuffer::RAMPreferred:
case CVertexBuffer::AGPPreferred:
return GL_DYNAMIC_DRAW;
case CVertexBuffer::StaticPreferred:
return getStaticMemoryToVRAM() ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW;
case CVertexBuffer::RAMVolatile:
case CVertexBuffer::AGPVolatile:
return GL_STREAM_DRAW;
default:
nlerror("Invalid preferred memory");
return GL_DYNAMIC_DRAW;
}
}
// ***************************************************************************
IVertexBufferGL3 *CDriverGL3::createVertexBufferGL(uint size, uint numVertices, CVertexBuffer::TPreferredMemory preferred, CVertexBuffer *vb)
{
H_AUTO_OGL(CDriverGL3_createVertexBufferGL)
IVertexBufferGL3 *result;
if (_Extensions.AMDPinnedMemory && (
preferred == CVertexBuffer::RAMPreferred
|| preferred == CVertexBuffer::AGPPreferred
))
{
result = new CVertexBufferAMDPinned(this, size, numVertices, preferred, vb);
}
else
{
result = new CVertexBufferGL3(this, size, numVertices, preferred, vb);
}
return _VertexBufferGLSet.insert(result);
}
// ********************************************************************
void CDriverGL3::updateLostBuffers()
{
H_AUTO_OGL(CDriverGL3_updateLostBuffers)
// Put all vb that have been lost in the NotResident state so that they will be recomputed
// We do this only if the app is active, because if vb were lost, it is likely that there are no resources available.
if (isWndActive())
{
for (std::list<CVertexBufferGL3 *>::iterator it = _LostVBList.begin(); it != _LostVBList.end(); ++it)
{
nlassert((*it)->m_VertexObjectId[0]);
for (GLsizei i = 0; i < NL3D_GL3_BUFFER_QUEUE_MAX; ++i)
{
GLuint id = (*it)->m_VertexObjectId[i];
if (id)
{
nlassert(nglIsBuffer(id));
nglDeleteBuffers(1, &id);
(*it)->m_VertexObjectId[i] = 0;
}
}
(*it)->VB->setLocation(CVertexBuffer::NotResident);
}
_LostVBList.clear();
}
}
// ********************************************************************
const uint CDriverGL3::NumCoordinatesType[CVertexBuffer::NumType]=
{
1, // Double1
1, // Float1
1, // Short1
2, // Double2
2, // Float2
2, // Short2
3, // Double3
3, // Float3
3, // Short3
4, // Double4
4, // Float4
4, // Short4
4 // UChar4
};
// ***************************************************************************
const uint CDriverGL3::GLType[CVertexBuffer::NumType]=
{
GL_DOUBLE, // Double1
GL_FLOAT, // Float1
GL_SHORT, // Short1
GL_DOUBLE, // Double2
GL_FLOAT, // Float2
GL_SHORT, // Short2
GL_DOUBLE, // Double3
GL_FLOAT, // Float3
GL_SHORT, // Short3
GL_DOUBLE, // Double4
GL_FLOAT, // Float4
GL_SHORT, // Short4
GL_UNSIGNED_BYTE // UChar4
};
// ***************************************************************************
const bool CDriverGL3::GLTypeIsIntegral[CVertexBuffer::NumType] =
{
false, // Double1
false, // Float1
true, // Short1
false, // Double2
false, // Float2
true, // Short2
false, // Double3
false, // Float3
true, // Short3
false, // Double4
false, // Float4
true, // Short4
true // UChar4
};
// ***************************************************************************
const uint CDriverGL3::GLVertexAttribIndex[CVertexBuffer::NumValue]=
{
0, // Position
2, // Normal
8, // TexCoord0
9, // TexCoord1
10, // TexCoord2
11, // TexCoord3
12, // TexCoord4
13, // TexCoord5
14, // TexCoord6
15, // TexCoord7
3, // PrimaryColor
4, // SecondaryColor
1, // Weight
6, // Empty (PaletteSkin)
5, // Fog
7, // Empty
};
// tells for each vertex argument if it must be normalized when it is an integral type
static const GLboolean ARBVertexProgramMustNormalizeAttrib[] =
{
GL_FALSE, // Position
GL_TRUE, // Normal
GL_FALSE, // TexCoord0
GL_FALSE, // TexCoord1
GL_FALSE, // TexCoord2
GL_FALSE, // TexCoord3
GL_FALSE, // TexCoord4
GL_FALSE, // TexCoord5
GL_FALSE, // TexCoord6
GL_FALSE, // TexCoord7
GL_TRUE, // PrimaryColor
GL_TRUE, // SecondaryColor
GL_TRUE, // Weight
GL_FALSE, // PaletteSkin
GL_FALSE, // Fog
GL_FALSE, // Empty
};
// ***************************************************************************
void CDriverGL3::setupGlArrays(CVertexBufferInfo &vb)
{
H_AUTO_OGL(CDriverGL3_setupGlArrays)
uint32 flags= vb.VertexFormat;
nlctassert(CVertexBuffer::NumValue == sizeof(ARBVertexProgramMustNormalizeAttrib) / sizeof(ARBVertexProgramMustNormalizeAttrib[0]));
_DriverGLStates.bindARBVertexBuffer(vb.VertexObjectId);
{
// For each value
for (uint value=0; value<CVertexBuffer::NumValue; value++)
{
// Flag
uint16 flag=1<<value;
// Type
CVertexBuffer::TType type=vb.Type[value];
{
// Index
uint glIndex=GLVertexAttribIndex[value];
// Not setuped value and used
if (flags & flag)
{
_DriverGLStates.enableVertexAttribArrayARB(glIndex, true);
GLboolean mustNormalize = GL_FALSE;
if (GLTypeIsIntegral[type])
{
mustNormalize = ARBVertexProgramMustNormalizeAttrib[value];
}
nglVertexAttribPointer(glIndex, NumCoordinatesType[type], GLType[ type ], mustNormalize, vb.VertexSize, vb.ValuePtr[value]);
}
else
{
_DriverGLStates.enableVertexAttribArrayARB(glIndex, false);
}
}
}
}
}
// ***************************************************************************
void CDriverGL3::mapTextureStageToUV(uint stage, uint uvId)
{
H_AUTO_OGL(CDriverGL3_mapTextureStageToUV)
// Just call it for last VertexBuffer setuped... (hack)
CVertexBufferInfo &VB = _LastVB;
if (VB.VertexFormat & (CVertexBuffer::TexCoord0Flag<<uvId))
{
CVertexBuffer::TType uvType = VB.Type[CVertexBuffer::TexCoord0 + uvId];
nglVertexAttribPointer(GLVertexAttribIndex[CVertexBuffer::TexCoord0 + stage], NumCoordinatesType[uvType], GLType[uvType],
false, VB.VertexSize, VB.ValuePtr[CVertexBuffer::TexCoord0 + uvId]);
}
}
// ***************************************************************************
void CVertexBufferInfo::setupVertexBuffer(CVertexBuffer &vb)
{
H_AUTO_OGL(CDriverGL3_setupVertexBuffer)
sint i;
VertexFormat= vb.getVertexFormat();
VertexSize= vb.getVertexSize();
NumVertices= vb.getNumVertices();
// Lock the buffer
CVertexBufferReadWrite access;
uint8 *ptr;
CVBDrvInfosGL3 *info= safe_cast<CVBDrvInfosGL3*>((IVBDrvInfos*)vb.DrvInfos);
nlassert(info);
nlassert(info->_VBHard);
ptr = (uint8*)info->_VBHard->getPointer();
VertexObjectId = info->_VBHard->getGLuint();
// Get value pointer
for (i=0; i<CVertexBuffer::NumValue; i++)
{
// Value used ?
if (VertexFormat&(1<<i))
{
// Get the pointer
ValuePtr[i]= ptr+vb.getValueOffEx((CVertexBuffer::TValue)i);
// Type of the value
Type[i]=vb.getValueType (i);
}
}
// Copy the UVRouting table
const uint8 *uvRouting = vb.getUVRouting();
for (i=0; i<CVertexBuffer::MaxStage; i++)
{
UVRouting[i] = uvRouting[i];
}
}
// ***************************************************************************
bool CDriverGL3::initVertexBufferHard(uint agpMem, uint vramMem)
{
H_AUTO_OGL(CDriverGL3_initVertexBufferHard)
return true;
}
// ***************************************************************************
CIndexBufferInfo::CIndexBufferInfo()
{
H_AUTO_OGL(CIndexBufferInfo_CIndexBufferInfo)
_Values = NULL;
}
// ***************************************************************************
void CIndexBufferInfo::setupIndexBuffer(CIndexBuffer &ib)
{
H_AUTO_OGL(CIndexBufferInfo_setupIndexBuffer)
CIndexBufferReadWrite access;
ib.lock (access);
_Values = access.getPtr();
_Format = access.getFormat();
}
// ***************************************************************************
} // NLDRIVERGL3
} // NL3D

@ -0,0 +1,595 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include "driver_opengl.h"
#include "driver_opengl_vertex_buffer.h"
#include "nel/3d/vertex_buffer.h"
using namespace std;
using namespace NLMISC;
namespace NL3D {
namespace NLDRIVERGL3 {
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
IVertexBufferGL3::IVertexBufferGL3(CDriverGL3 *drv, CVertexBuffer *vb, TVBType vbType)
: VB(vb), VBType(vbType), m_Driver(drv), m_Invalid(false)
{
H_AUTO_OGL(IVertexBufferGL_IVertexBufferGL)
}
// ***************************************************************************
IVertexBufferGL3::~IVertexBufferGL3()
{
H_AUTO_OGL(IVertexBufferGL_IVertexBufferGLDtor)
}
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
static inline GLsizei vbgl3BufferForType(CVertexBuffer::TPreferredMemory mem)
{
switch (mem)
{
case CVertexBuffer::AGPVolatile:
case CVertexBuffer::RAMVolatile:
return NL3D_GL3_BUFFER_QUEUE_MAX;
default:
return 1;
}
}
CVertexBufferGL3::CVertexBufferGL3(CDriverGL3 *drv, uint size, uint numVertices, CVertexBuffer::TPreferredMemory preferred, CVertexBuffer *vb)
: IVertexBufferGL3(drv, vb, IVertexBufferGL3::GL3),
m_VertexPtr(NULL),
m_CurrentIndex(0),
m_CurrentInFlight(false),
#if NL3D_GL3_VERTEX_BUFFER_INFLIGHT_DEBUG
m_ReuseCount(0),
m_InvalidateCount(0),
#endif
m_MemType(preferred)
{
H_AUTO_OGL(CVertexBufferGLARB_CVertexBufferGLARB);
for (GLsizei i = 0; i < NL3D_GL3_BUFFER_QUEUE_MAX; ++i)
{
m_VertexObjectId[i] = 0;
m_FrameInFlight[i] = NL3D_GL3_BUFFER_NOT_IN_FLIGHT;
}
// Create ids
GLsizei nbBuff = vbgl3BufferForType(preferred);
nglGenBuffers(nbBuff, m_VertexObjectId);
// Initialize
for (GLsizei i = 0; i < nbBuff; ++i)
{
drv->_DriverGLStates.forceBindARBVertexBuffer(m_VertexObjectId[i]);
nglBufferData(GL_ARRAY_BUFFER, size, NULL, drv->vertexBufferUsageGL3(preferred));
drv->_DriverGLStates.forceBindARBVertexBuffer(0);
}
}
// ***************************************************************************
CVertexBufferGL3::~CVertexBufferGL3()
{
H_AUTO_OGL(CVertexBufferGLARB_CVertexBufferGLARBDtor)
if (m_Driver && m_VertexObjectId)
{
GLsizei nbBuff = vbgl3BufferForType(m_MemType);
for (GLsizei i = 0; i < nbBuff; ++i)
{
if (m_Driver->_DriverGLStates.getCurrBoundARBVertexBuffer() == m_VertexObjectId[i])
{
m_Driver->_DriverGLStates.forceBindARBVertexBuffer(0);
}
}
}
for (GLsizei i = 0; i < NL3D_GL3_BUFFER_QUEUE_MAX; ++i)
{
if (m_VertexObjectId[i])
{
GLuint id = m_VertexObjectId[i];
nlassert(nglIsBuffer(id));
nglDeleteBuffers(1, &id);
}
}
if (m_Driver)
{
if (m_Invalid)
{
if (VB->getLocation() != CVertexBuffer::NotResident)
{
// when the vb is put in tthe NotResident state, it is removed from that list
m_Driver->_LostVBList.erase(m_IteratorInLostVBList);
}
}
}
}
// ***************************************************************************
void *CVertexBufferGL3::lock()
{
H_AUTO_OGL(CVertexBufferGLARB_lock);
if (m_VertexPtr) return m_VertexPtr; // already locked :|
const uint size = VB->getNumVertices() * VB->getVertexSize();
if (m_Invalid)
{
if (VB->getLocation() != CVertexBuffer::NotResident)
{
nlassert(!m_DummyVB.empty());
return &m_DummyVB[0];
}
// Create ids
glGetError();
GLsizei nbBuff = vbgl3BufferForType(m_MemType);
nglGenBuffers(nbBuff, m_VertexObjectId);
if (glGetError() != GL_NO_ERROR)
{
m_Driver->incrementResetCounter();
return &m_DummyVB[0];
}
for (GLsizei i = 0; i < nbBuff; ++i)
{
m_Driver->_DriverGLStates.forceBindARBVertexBuffer(m_VertexObjectId[i]);
nglBufferData(GL_ARRAY_BUFFER, size, NULL, m_Driver->vertexBufferUsageGL3(m_MemType));
m_Driver->_DriverGLStates.forceBindARBVertexBuffer(0);
if (glGetError() != GL_NO_ERROR)
{
m_Driver->incrementResetCounter();
nglDeleteBuffers(1, &m_VertexObjectId[i]);
return &m_DummyVB[0];
}
}
NLMISC::contReset(m_DummyVB); // free vector memory for real
nlassert(m_VertexObjectId[m_CurrentIndex]);
m_Invalid = false;
m_Driver->_LostVBList.erase(m_IteratorInLostVBList);
// continue to standard mapping code below ..
}
TTicks beforeLock = 0;
if (m_Driver->_VBHardProfiling)
{
beforeLock= CTime::getPerformanceTime();
}
// m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
// PERFORMANCE: AMD: This brings framerate from 24fps to 38fps, glitches with volatile buffers such as animated models and gui, likely glitches with others
// m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
// PERFORMANCE: AMD: This brings framerate from 24fps to 38fps, glitches with landscape rendering
// m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
// Invalidate when updating volatile buffers, framerate from 24fps to 38fps in reference test on AMD platform
// TODO: Find where we can optimize with GL_MAP_UNSYNCHRONIZED_BIT
switch (m_MemType)
{
case CVertexBuffer::AGPVolatile:
case CVertexBuffer::RAMVolatile:
{
if (m_CurrentInFlight)
{
++m_CurrentIndex;
m_CurrentIndex %= NL3D_GL3_BUFFER_QUEUE_MAX;
m_CurrentInFlight = false;
}
m_Driver->_DriverGLStates.bindARBVertexBuffer(m_VertexObjectId[m_CurrentIndex]);
if (m_FrameInFlight[m_CurrentIndex] != NL3D_GL3_BUFFER_NOT_IN_FLIGHT
&& m_FrameInFlight[m_CurrentIndex] >= m_Driver->getSwapBufferInFlight())
{
#if NL3D_GL3_VERTEX_BUFFER_INFLIGHT_DEBUG
++m_InvalidateCount;
nldebug("GL: Vertex buffer already in flight (reused: %u, invalidated: %u)", m_ReuseCount, m_InvalidateCount);
#endif
// NOTE: GL_MAP_INVALIDATE_BUFFER_BIT removes the cost of waiting for synchronization (major performance impact),
// but adds the cost of allocating a new buffer (which hast a much lower performance impact)
m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
}
else
{
#if NL3D_GL3_VERTEX_BUFFER_INFLIGHT_DEBUG
++m_ReuseCount;
nldebug("GL: Vertex buffer can be reused (reused: %u, invalidated: %u)", m_ReuseCount, m_InvalidateCount);
#endif
m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
}
break;
}
case CVertexBuffer::RAMPreferred:
m_Driver->_DriverGLStates.bindARBVertexBuffer(m_VertexObjectId[m_CurrentIndex]);
// m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_READ_BIT | GL_MAP_PERSISTENT | GL_MAP_COHERENT);
// NOTE: Persistent / Coherent is only available in OpenGL 4.4 (2013/2014 hardware with recent drivers)
m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
break;
default:
m_Driver->_DriverGLStates.bindARBVertexBuffer(m_VertexObjectId[m_CurrentIndex]);
// m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT);
m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
break;
}
if (!m_VertexPtr)
{
nglUnmapBuffer(GL_ARRAY_BUFFER);
nlassert(nglIsBuffer(m_VertexObjectId[m_CurrentIndex]));
invalidate();
return &m_DummyVB[0];
}
#ifdef NL_DEBUG
_VertexArrayRange->_MappedVBList.push_front(this);
_IteratorInMappedVBList = _VertexArrayRange->_MappedVBList.begin();
#endif
m_Driver->_DriverGLStates.forceBindARBVertexBuffer(0);
// Lock Profile?
if (m_Driver->_VBHardProfiling)
{
TTicks afterLock;
afterLock= CTime::getPerformanceTime();
m_Driver->appendVBHardLockProfile(afterLock-beforeLock, VB);
}
return m_VertexPtr;
}
// ***************************************************************************
void CVertexBufferGL3::unlock()
{
H_AUTO_OGL(CVertexBufferGLARB_unlock);
m_VertexPtr = NULL;
if (m_Invalid) return;
if (!m_VertexObjectId[m_CurrentIndex]) return;
TTicks beforeLock = 0;
if (m_Driver->_VBHardProfiling)
{
beforeLock= CTime::getPerformanceTime();
}
m_Driver->_DriverGLStates.bindARBVertexBuffer(m_VertexObjectId[m_CurrentIndex]);
// double start = CTime::ticksToSecond(CTime::getPerformanceTime());
#ifdef NL_DEBUG
_Unmapping = true;
#endif
GLboolean unmapOk = GL_FALSE;
unmapOk = nglUnmapBuffer(GL_ARRAY_BUFFER);
#ifdef NL_DEBUG
_Unmapping = false;
#endif
// Lock Profile?
if (m_Driver->_VBHardProfiling)
{
TTicks afterLock;
afterLock= CTime::getPerformanceTime();
m_Driver->appendVBHardLockProfile(afterLock-beforeLock, VB);
}
#ifdef NL_DEBUG
_VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList);
#endif
m_Driver->_DriverGLStates.forceBindARBVertexBuffer(0);
if (!unmapOk)
{
invalidate();
}
/* double end = CTime::ticksToSecond(CTime::getPerformanceTime());
nlinfo("3D: Unlock = %f ms", (float) ((end - start) * 1000)); */
}
// ***************************************************************************
void *CVertexBufferGL3::getPointer()
{
H_AUTO_OGL(CVertexBufferGLARB_getPointer)
return m_VertexPtr;
}
// ***************************************************************************
void CVertexBufferGL3::unlock(uint /* startVert */,uint /* endVert */)
{
H_AUTO_OGL(CVertexBufferGLARB_unlock)
unlock(); // can't do a lock on a range of the vb..
}
// ***************************************************************************
void CVertexBufferGL3::enable()
{
H_AUTO_OGL(CVertexBufferGLARB_enable)
if (m_Driver->_CurrentVertexBufferGL != this)
{
m_Driver->_CurrentVertexBufferGL = this;
}
}
// ***************************************************************************
void CVertexBufferGL3::disable()
{
H_AUTO_OGL(CVertexBufferGLARB_disable)
if (m_Driver->_CurrentVertexBufferGL != NULL)
{
m_Driver->_CurrentVertexBufferGL = NULL;
}
}
// ***************************************************************************
GLuint CVertexBufferGL3::getGLuint()
{
H_AUTO_OGL(CVertexBufferGLARB_getGLuint);
return m_VertexObjectId[m_CurrentIndex];
}
// ***************************************************************************
void CVertexBufferGL3::setFrameInFlight(uint64 swapBufferCounter)
{
H_AUTO_OGL(CVertexBufferGL3_setFrameInFlight);
// Set buffer frame in flight
m_FrameInFlight[m_CurrentIndex] = swapBufferCounter;
m_CurrentInFlight = true;
}
// ***************************************************************************
void CVertexBufferGL3::invalidate()
{
H_AUTO_OGL(CVertexBufferGLARB_invalidate)
nlassert(!m_Invalid);
// Buffer is lost (maybe there was a alt-tab or fullscrren / windowed change)
// Buffer is deleted at end of frame only
m_Invalid = true;
m_Driver->incrementResetCounter();
m_DummyVB.resize(VB->getNumVertices() * VB->getVertexSize(), 0);
// insert in lost vb list
m_Driver->_LostVBList.push_front(this);
m_IteratorInLostVBList = m_Driver->_LostVBList.begin();
}
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
CVertexBufferAMDPinned::CVertexBufferAMDPinned(CDriverGL3 *drv, uint size, uint numVertices, CVertexBuffer::TPreferredMemory preferred, CVertexBuffer *vb)
: IVertexBufferGL3(drv, vb, IVertexBufferGL3::AMDPinned),
m_MemType(preferred),
m_VertexPtr(NULL),
m_VertexObjectId(0),
m_FrameInFlight(NL3D_GL3_BUFFER_NOT_IN_FLIGHT)
{
H_AUTO_OGL(CVertexBufferAMDPinned_CVertexBufferAMDPinned)
// Create id and bind
GLuint vertexBufferID;
nglGenBuffers(1, &vertexBufferID);
nglBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, vertexBufferID);
// Initialize
// Align allocated to page size, which is assumed to be 4K
// nldebug("GL3: Allocate AMD Pinned Memory (%i bytes, %i vertices)", size, numVertices);
m_VertexPtrAllocated = new char[size + 4096];
uintptr_t addr = (uintptr_t)m_VertexPtrAllocated;
addr = (addr + 4095) & (~0xfff);
m_VertexPtrAligned = (void *)addr;
nglBufferData(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, size, m_VertexPtrAligned, drv->vertexBufferUsageGL3(preferred));
if (glGetError() == GL_INVALID_OPERATION)
{
nlerror("Failed to pin memory");
nglDeleteBuffers(1, &vertexBufferID);
vertexBufferID = 0;
}
m_VertexObjectId = vertexBufferID;
// Unbind
nglBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
}
// ***************************************************************************
CVertexBufferAMDPinned::~CVertexBufferAMDPinned()
{
H_AUTO_OGL(CVertexBufferAMDPinned_CVertexBufferAMDPinnedDtor)
if (m_Driver && m_VertexObjectId)
{
if (m_Driver->_DriverGLStates.getCurrBoundARBVertexBuffer() == m_VertexObjectId)
{
m_Driver->_DriverGLStates.forceBindARBVertexBuffer(0);
}
}
if (m_VertexObjectId)
{
GLuint id = (GLuint)m_VertexObjectId;
nlassert(nglIsBuffer(id));
nglDeleteBuffers(1, &id);
}
delete m_VertexPtrAllocated;
m_VertexPtrAllocated = NULL;
m_VertexPtrAligned = NULL;
nlassert(m_VertexPtr == NULL);
}
// ***************************************************************************
void *CVertexBufferAMDPinned::lock()
{
H_AUTO_OGL(CVertexBufferAMDPinned_lock);
if (m_VertexPtr) // Already locked...
return m_VertexPtr;
if (!m_VertexObjectId) // Failed to pin
return m_VertexPtrAligned;
// Profiling
TTicks beforeLock = 0;
if (m_Driver->_VBHardProfiling)
{
beforeLock= CTime::getPerformanceTime();
}
// Lock
m_Driver->_DriverGLStates.bindARBVertexBuffer(m_VertexObjectId);
switch (m_MemType)
{
case CVertexBuffer::AGPVolatile:
case CVertexBuffer::RAMVolatile:
nlerror("Volatile currently not supported by pinned memory, this would require a re-allocating RAM, and thus require a fast allocation mechanism");
m_VertexPtr = NULL;
break;
case CVertexBuffer::RAMPreferred:
m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
break;
default:
m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
break;
}
m_Driver->_DriverGLStates.forceBindARBVertexBuffer(0);
nlassert(m_VertexPtr);
// May actually return a different virtual address on some systems
// nlassert(m_VertexPtr == m_VertexPtrAligned);
// Profiling
if (m_Driver->_VBHardProfiling)
{
TTicks afterLock;
afterLock = CTime::getPerformanceTime();
m_Driver->appendVBHardLockProfile(afterLock - beforeLock, VB);
}
return m_VertexPtr;
}
// ***************************************************************************
void CVertexBufferAMDPinned::unlock()
{
H_AUTO_OGL(CVertexBufferAMDPinned_unlock);
m_VertexPtr = NULL;
if (!m_VertexObjectId)
return;
// Profiling
TTicks beforeLock = 0;
if (m_Driver->_VBHardProfiling)
{
beforeLock = CTime::getPerformanceTime();
}
// Unlock
m_Driver->_DriverGLStates.bindARBVertexBuffer(m_VertexObjectId);
nglUnmapBuffer(GL_ARRAY_BUFFER);
m_Driver->_DriverGLStates.forceBindARBVertexBuffer(0);
// Profiling
if (m_Driver->_VBHardProfiling)
{
TTicks afterLock;
afterLock= CTime::getPerformanceTime();
m_Driver->appendVBHardLockProfile(afterLock-beforeLock, VB);
}
}
// ***************************************************************************
void *CVertexBufferAMDPinned::getPointer()
{
H_AUTO_OGL(CVertexBufferAMDPinned_getPointer)
return m_VertexPtr;
}
// ***************************************************************************
void CVertexBufferAMDPinned::unlock(uint /* startVert */,uint /* endVert */)
{
H_AUTO_OGL(CVertexBufferAMDPinned_unlock)
unlock();
}
// ***************************************************************************
void CVertexBufferAMDPinned::enable()
{
H_AUTO_OGL(CVertexBufferAMDPinned_enable)
if (m_Driver->_CurrentVertexBufferGL != this)
{
m_Driver->_CurrentVertexBufferGL = this;
}
}
// ***************************************************************************
void CVertexBufferAMDPinned::disable()
{
H_AUTO_OGL(CVertexBufferAMDPinned_disable)
if (m_Driver->_CurrentVertexBufferGL != NULL)
{
m_Driver->_CurrentVertexBufferGL = NULL;
}
}
// ***************************************************************************
GLuint CVertexBufferAMDPinned::getGLuint()
{
H_AUTO_OGL(CVertexBufferAMDPinned_getGLuint);
return m_VertexObjectId;
}
// ***************************************************************************
void CVertexBufferAMDPinned::setFrameInFlight(uint64 swapBufferCounter)
{
H_AUTO_OGL(CVertexBufferAMDPinned_setFrameInFlight);
m_FrameInFlight = swapBufferCounter;
}
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
} // NLDRIVERGL3
} // NL3D

@ -0,0 +1,179 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_DRIVER_OPENGL_VERTEX_BUFFER_H
#define NL_DRIVER_OPENGL_VERTEX_BUFFER_H
#include "nel/misc/types_nl.h"
namespace NL3D {
namespace NLDRIVERGL3 {
#define NL3D_GL3_VERTEX_BUFFER_INFLIGHT_DEBUG 0
class CDriverGL3;
class IVertexBufferGL3;
class CVertexBufferInfo;
class CVertexBufferGL3;
class IVertexBufferGL3
{
public:
enum TVBType { GL3, AMDPinned };
IVertexBufferGL3(CDriverGL3 *drv, CVertexBuffer *vb, TVBType vbType);
virtual ~IVertexBufferGL3();
virtual void *lock() = 0;
virtual void unlock() = 0;
virtual void unlock(uint start, uint end) = 0;
virtual void *getPointer() = 0;
virtual void enable() = 0;
virtual void disable() = 0;
virtual GLuint getGLuint() = 0;
virtual void setFrameInFlight(uint64 swapBufferCounter) = 0;
// test if buffer content is invalid. If so, no rendering should occurs (rendering should silently fail)
inline bool isInvalid() { return m_Invalid; }
public:
CVertexBuffer *VB;
TVBType VBType;
protected:
CDriverGL3 *m_Driver;
bool m_Invalid;
};
/* GL Core vertex buffer. */
class CVertexBufferGL3 : public IVertexBufferGL3
{
public:
CVertexBufferGL3(CDriverGL3 *drv, uint size, uint numVertices, CVertexBuffer::TPreferredMemory preferred, CVertexBuffer *vb);
virtual ~CVertexBufferGL3();
/// \name Implementation
// @{
virtual void *lock();
virtual void unlock();
virtual void unlock(uint startVert, uint endVert);
virtual void *getPointer();
virtual void enable();
virtual void disable();
virtual GLuint getGLuint();
virtual void setFrameInFlight(uint64 swapBufferCounter);
// @}
/// Invalidate the buffer (when it is lost, or when a lock fails)
void invalidate();
private:
friend class CDriverGL3;
CVertexBuffer::TPreferredMemory m_MemType;
void *m_VertexPtr; // pointer on current datas. Null if not locked
// if buffer has been invalidated, returns a dummy memory block and silently fails rendering
std::vector<uint8> m_DummyVB;
// for use by CVertexArrayRange
std::list<CVertexBufferGL3*>::iterator m_IteratorInLostVBList;
GLuint m_VertexObjectId[NL3D_GL3_BUFFER_QUEUE_MAX];
uint64 m_FrameInFlight[NL3D_GL3_BUFFER_QUEUE_MAX];
GLsizei m_CurrentIndex;
bool m_CurrentInFlight;
#if NL3D_GL3_VERTEX_BUFFER_INFLIGHT_DEBUG
uint32 m_ReuseCount;
uint32 m_InvalidateCount;
#endif
};
class CVertexBufferAMDPinned : public IVertexBufferGL3
{
public:
CVertexBufferAMDPinned(CDriverGL3 *drv, uint size, uint numVertices, CVertexBuffer::TPreferredMemory preferred, CVertexBuffer *vb);
virtual ~CVertexBufferAMDPinned();
/// \name Implementation
// @{
virtual void *lock();
virtual void unlock();
virtual void unlock(uint startVert, uint endVert);
virtual void *getPointer();
virtual void enable();
virtual void disable();
virtual GLuint getGLuint();
virtual void setFrameInFlight(uint64 swapBufferCounter);
// @}
private:
CVertexBuffer::TPreferredMemory m_MemType;
void *m_VertexPtrAllocated;
void *m_VertexPtrAligned;
void *m_VertexPtr;
uint m_VertexObjectId;
uint64 m_FrameInFlight;
};
/*
// Follows design of D3D::CVolatileVertexBuffer
// A large buffer from which sequentially is allocated
// Must have one instance per in-flight frame (count NL3D_GL3_BUFFER_QUEUE_MAX)
// OR use different strategy; fix the sizes of the volatile storage buffers; and synchronize to next buffer whenever end of buffer is reached
class CVolatileBufferStorageGL3
{
public:
CVolatileBufferGL3();
~CVolatileBufferGL3();
// Initialize
// location: Either AGPVolatile or RAMVolatile
void init(CVertexBuffer::TLocation location, GLsizei size, GLsizei maxSize, CDriverGL3 *driver);
void release();
// Runtime buffer access, no-blocking lock.
void *lock(uint size, uint stride, uint &offset);
void unlock();
void reset();
private:
CDriverGL3 *m_Driver;
GLuint *m_BufferObjectId;
GLsizei m_Size;
GLsizei m_MaxSize;
GLsizei m_CurrentOffset;
bool Locked;
CVertexBuffer::TLocation m_Location;
};
// Buffer which makes use of driver provided CVolatileBufferStorageGL3 for storage backing
class CVolatileBufferGL3 : public IVertexBufferGL3
{
virtual void getBufferObject(GLuint &buffer, GLintptr &offset) const; // Use glBindBufferRange instead of glBindBuffer
// Or don't expose this, and expose a bind function targeting the right target...
};
*/
} // NLDRIVERGL3
} // NL3D
#endif // NL_DRIVER_OPENGL_VERTEX_BUFFER_H
/* End of driver_opengl_vertex_buffer.h */

@ -0,0 +1,451 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2014 by authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"
#include <sstream>
#include "nel/misc/wang_hash.h"
#include "nel/3d/vertex_program.h"
#include "nel/3d/light.h"
#include "driver_opengl.h"
#include "driver_opengl_program.h"
#include "driver_opengl_vertex_buffer.h"
namespace NL3D {
namespace NLDRIVERGL3 {
bool operator<(const CVPBuiltin &left, const CVPBuiltin &right)
{
if (left.VertexFormat != right.VertexFormat)
return left.VertexFormat < right.VertexFormat;
if (left.Lighting != right.Lighting)
return right.Lighting;
if (left.Lighting)
for (sint i = 0; i < NL_OPENGL3_MAX_LIGHT; ++i)
if (left.LightMode[i] != right.LightMode[i])
return left.LightMode[i] < right.LightMode[i];
for (sint i = 0; i < IDRV_MAT_MAXTEXTURES; ++i)
if (left.TexGenMode[i] != right.TexGenMode[i])
return left.TexGenMode[i] < right.TexGenMode[i];
if (left.Specular != right.Specular)
return right.Specular;
if (left.Fog != right.Fog)
return right.Fog;
// if (left.VertexColorLighted != right.VertexColorLighted)
// return right.VertexColorLighted;
return false;
}
bool operator==(const CVPBuiltin &left, const CVPBuiltin &right)
{
if (left.VertexFormat != right.VertexFormat)
return false;
if (left.Lighting != right.Lighting)
return false;
if (left.Lighting)
for (sint i = 0; i < NL_OPENGL3_MAX_LIGHT; ++i)
if (left.LightMode[i] != right.LightMode[i])
return false;
for (sint i = 0; i < IDRV_MAT_MAXTEXTURES; ++i)
if (left.TexGenMode[i] != right.TexGenMode[i])
return false;
if (left.Specular != right.Specular)
return false;
if (left.Fog != right.Fog)
return false;
// if (left.VertexColorLighted != right.VertexColorLighted)
// return false;
return true;
}
} // NLDRIVERGL3
} // NL3D
namespace std {
size_t hash<NL3D::NLDRIVERGL3::CVPBuiltin>::operator()(const NL3D::NLDRIVERGL3::CVPBuiltin & v) const
{
uint32 h;
h = NLMISC::wangHash(((uint32)v.VertexFormat) | (v.Lighting ? (1 << 16) : 0) | (v.Specular ? (1 << 17) : 0) | (v.Fog ? (1 << 18) : 0));
if (v.Lighting)
for (sint i = 0; i < NL_OPENGL3_MAX_LIGHT; ++i)
h = NLMISC::wangHash(h ^ v.LightMode[i]);
for (sint i = 0; i < NL3D::IDRV_MAT_MAXTEXTURES; ++i)
h = NLMISC::wangHash(h ^ v.TexGenMode[i]);
nlctassert(sizeof(size_t) >= sizeof(uint32));
return (size_t)h;
}
}
namespace NL3D {
namespace NLDRIVERGL3 {
namespace /* anonymous */ {
void vpLightUniforms(std::stringstream &ss, const CVPBuiltin &desc, int i)
{
switch (desc.LightMode[i])
{
case CLight::DirectionalLight:
ss << "uniform vec3 light" << i << "DirOrPos;" << std::endl;
ss << "uniform vec4 light" << i << "ColDiff;" << std::endl;
//ss << "uniform vec4 light" << i << "ColAmb;" << std::endl;
ss << "uniform vec4 light" << i << "ColSpec;" << std::endl;
ss << "uniform float light" << i << "Shininess;" << std::endl;
break;
case CLight::PointLight:
ss << "uniform vec3 light" << i << "DirOrPos;" << std::endl;
ss << "uniform vec4 light" << i << "ColDiff;" << std::endl;
//ss << "uniform vec4 light" << i << "ColAmb;" << std::endl;
ss << "uniform vec4 light" << i << "ColSpec;" << std::endl;
ss << "uniform float light" << i << "Shininess;" << std::endl;
ss << "uniform float light" << i << "ConstAttn;" << std::endl;
ss << "uniform float light" << i << "LinAttn;" << std::endl;
ss << "uniform float light" << i << "QuadAttn;" << std::endl;
break;
}
}
void vpLightFunctions(std::stringstream &ss, const CVPBuiltin &desc, int i)
{
switch (desc.LightMode[i])
{
case CLight::DirectionalLight:
ss << "float getIntensity" << i << "(vec3 normal3, vec3 lightDir)" << std::endl;
ss << "{" << std::endl;
ss << "float angle = dot(lightDir, normal3);" << std::endl;
ss << "angle = max(0.0, angle);" << std::endl;
ss << "return angle;" << std::endl;
ss << "}" << std::endl;
ss << std::endl;
ss << "float getSpecIntensity" << i << "(vec3 normal3, vec3 lightDir)" << std::endl;
ss << "{" << std::endl;
ss << "vec3 halfVector = normalize(lightDir + normal3);" << std::endl;
ss << "float angle = dot(normal3, halfVector);" << std::endl;
ss << "angle = max(0.0, angle);" << std::endl;
ss << "float si = pow(angle, light" << i << "Shininess);" << std::endl;
ss << "return si;" << std::endl;
ss << "}" << std::endl;
ss << std::endl;
ss << "void addLight" << i << "Color(inout vec4 lightDiffuse, inout vec4 lightSpecular)" << std::endl;
ss << "{" << std::endl;
ss << "vec4 lightDir4 = viewMatrix * vec4(light" << i << "DirOrPos, 1.0);" << std::endl;
ss << "vec3 lightDir = lightDir4.xyz / lightDir4.w;" << std::endl;
ss << "lightDir = normalize(lightDir);" << std::endl;
ss << "vec3 normal3 = vnormal.xyz / vnormal.w;" << std::endl;
ss << "normal3 = normalMatrix * normal3;" << std::endl;
ss << "normal3 = normalize(normal3);" << std::endl;
ss << "lightDiffuse = lightDiffuse + getIntensity" << i << "(normal3, lightDir) * light" << i << "ColDiff;" << std::endl;
ss << "lightSpecular = lightSpecular + getSpecIntensity" << i << "(normal3, lightDir) * light" << i << "ColSpec;" << std::endl;
ss << "}" << std::endl;
ss << std::endl;
break;
case CLight::PointLight:
ss << "float getIntensity" << i << "(vec3 normal3, vec3 direction3)" << std::endl;
ss << "{" << std::endl;
ss << "float angle = dot(direction3, normal3);" << std::endl;
ss << "angle = max(0.0, angle);" << std::endl;
ss << "return angle;" << std::endl;
ss << "}" << std::endl;
ss << std::endl;
ss << "float getSpecIntensity" << i << "(vec3 normal3, vec3 direction3)" << std::endl;
ss << "{" << std::endl;
ss << "vec3 halfVector = normalize(direction3 + normal3);" << std::endl;
ss << "float angle = dot(normal3, halfVector);" << std::endl;
ss << "angle = max(0.0, angle);" << std::endl;
ss << "float si = pow(angle, light" << i << "Shininess);" << std::endl;
ss << "return si;" << std::endl;
ss << "}" << std::endl;
ss << std::endl;
ss << "void addLight" << i << "Color(inout vec4 lightDiffuse, inout vec4 lightSpecular)" << std::endl;
ss << "{" << std::endl;
ss << "vec3 ecPos3 = ecPos4.xyz / ecPos4.w;" << std::endl;
ss << "vec4 lightPos4 = viewMatrix * vec4(light" << i << "DirOrPos, 1.0);" << std::endl;
ss << "vec3 lightPos = lightPos4.xyz / lightPos4.w;" << std::endl;
ss << "vec3 lightDirection = lightPos - ecPos3;" << std::endl;
ss << "float lightDistance = length(lightDirection);" << std::endl;
ss << "lightDirection = normalize(lightDirection);" << std::endl;
ss << "float attenuation = light" << i << "ConstAttn + ";
ss << "light" << i << "LinAttn * lightDistance +";
ss << "light" << i << "QuadAttn * lightDistance * lightDistance;" << std::endl;
// ss << "attenuation = max(attenuation, 1.0);" << std::endl; // TEST
ss << "vec3 normal3 = vnormal.xyz / vnormal.w;" << std::endl;
ss << "normal3 = normalMatrix * normal3;" << std::endl;
ss << "normal3 = normalize(normal3);" << std::endl;
ss << "float invattn = 1.0 / attenuation;" << std::endl;
ss << "lightDiffuse = lightDiffuse + getIntensity" << i << "(normal3, lightDirection) * invattn * light" << i << "ColDiff;" << std::endl;
ss << "lightSpecular = lightSpecular + getSpecIntensity" << i << "(normal3, lightDirection) * invattn * light" << i << "ColSpec;" << std::endl;
ss << "}" << std::endl;
ss << std::endl;
break;
}
}
void vpGenerate(std::string &result, const CVPBuiltin &desc)
{
std::stringstream ss;
ss << "// Builtin Vertex Shader" << std::endl;
ss << std::endl;
ss << "#version 330" << std::endl;
ss << "#extension GL_ARB_separate_shader_objects : enable" << std::endl;
ss << std::endl;
ss << "out gl_PerVertex" << std::endl;
ss << "{" << std::endl;
ss << "vec4 gl_Position;" << std::endl;
ss << "};" << std::endl;
ss << std::endl;
ss << "uniform mat4 modelViewProjection;" << std::endl;
ss << std::endl;
for (int i = Position; i < NumOffsets; ++i)
if (hasFlag(desc.VertexFormat, g_VertexFlags[i]))
ss << "layout (location = " << i << ") " << "in vec4 " << "v" << g_AttribNames[i] << ";" << std::endl;
ss << std::endl;
for (int i = Weight; i < NumOffsets; ++i)
if (hasFlag(desc.VertexFormat, g_VertexFlags[i]) && (i != PrimaryColor) && (i != SecondaryColor))
ss << "smooth out vec4 " << g_AttribNames[i] << "; // vertex buffer" << std::endl;
ss << std::endl;
// For now shader will fail to compile if both texgen and vertex buffer tex coord are provided! This is by design.
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; ++i)
if (desc.TexGenMode[i] >= 0)
ss << "smooth out vec4 texCoord" << i << "; // texgen (not implemented)" << std::endl;
ss << std::endl;
// TODO: Texgen parameters
// Ambient color of all lights is precalculated and added with self illumination, and multiplied with the material ambient.
if (desc.Lighting)
ss << "uniform vec4 selfIllumination;" << std::endl;
if (desc.Fog || desc.Lighting)
ss << "uniform mat4 modelView;" << std::endl;
if (desc.Lighting)
ss << "uniform mat4 viewMatrix;" << std::endl;
if (desc.Fog || desc.Lighting)
ss << "vec4 ecPos4;" << std::endl;
if (desc.Fog)
ss << "smooth out vec4 ecPos;" << std::endl;
ss << std::endl;
if (!desc.Lighting)
ss << "uniform vec4 materialColor;" << std::endl; // Verify
ss << "smooth out vec4 vertexColor;" << std::endl;
ss << std::endl;
if (desc.Lighting)
{
ss << "uniform mat3 normalMatrix;" << std::endl;
for (int i = 0; i < NL_OPENGL3_MAX_LIGHT; ++i)
vpLightUniforms(ss, desc, i);
for (int i = 0; i < NL_OPENGL3_MAX_LIGHT; ++i)
vpLightFunctions(ss, desc, i);
ss << std::endl;
}
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
ss << "gl_Position = modelViewProjection * " << "v" << g_AttribNames[0] << ";" << std::endl;
ss << std::endl;
if (desc.Fog || desc.Lighting)
ss << "ecPos4 = modelView * v" << g_AttribNames[0] << ";" << std::endl;
if (desc.Fog)
ss << "ecPos = ecPos4;" << std::endl;
ss << std::endl;
bool specularVertex = desc.Lighting || desc.VertexFormat & g_VertexFlags[SecondaryColor];
ss << "vec4 diffuseVertex;" << std::endl;
if (specularVertex) ss << "vec4 specularVertex;" << std::endl;
ss << std::endl;
if (desc.Lighting)
{
// Calculate lights
ss << "diffuseVertex = vec4(0.0, 0.0, 0.0, 0.0);" << std::endl;
ss << "specularVertex = vec4(0.0, 0.0, 0.0, 0.0);" << std::endl;
ss << "vec4 diffuseLight;" << std::endl;
ss << "vec4 specularLight;" << std::endl;
for (int i = 0; i < NL_OPENGL3_MAX_LIGHT; i++)
if (desc.LightMode[i] == CLight::DirectionalLight || desc.LightMode[i] == CLight::PointLight)
ss << "addLight" << i << "Color(diffuseVertex, specularVertex);" << std::endl;
ss << "diffuseVertex.a = 1.0;" << std::endl;
ss << "specularVertex.a = 1.0;" << std::endl;
// Secondary color (lighted)
if (desc.VertexFormat & g_VertexFlags[SecondaryColor])
{
ss << "specularVertex = specularVertex * vsecondaryColor;" << std::endl;
}
}
else
{
// Unlit
ss << "diffuseVertex = materialColor;" << std::endl;
// Secondary color (unlit)
if (desc.VertexFormat & g_VertexFlags[SecondaryColor])
{
nlwarning("VP: Secondary color in vertex buffer using material without lighting");
ss << "specularVertex = vsecondaryColor;" << std::endl;
}
}
// Primary color
if (desc.VertexFormat & g_VertexFlags[PrimaryColor])
{
ss << "diffuseVertex = diffuseVertex * vprimaryColor;" << std::endl; // Note: Might need to replace materialColor if PrimaryColor exists
}
// Add diffuse and specular color
ss << "vertexColor = diffuseVertex;" << std::endl;
if (specularVertex)
ss << "vertexColor.rgb = vertexColor.rgb + (specularVertex.rgb * specularVertex.a);" << std::endl; // Verify
if (desc.Lighting)
ss << "vertexColor.rgb = vertexColor.rgb + selfIllumination.rgb;" << std::endl; // Note: Alpha of self illumination is ignored
ss << std::endl;
for (int i = Weight; i < NumOffsets; i++)
{
if (hasFlag(desc.VertexFormat, g_VertexFlags[i]) && (i != PrimaryColor) && (i != SecondaryColor))
{
ss << g_AttribNames[i] << " = " << "v" << g_AttribNames[i] << ";" << std::endl;
}
}
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; ++i)
{
if (desc.TexGenMode[i] >= 0)
ss << "texCoord" << i << " = vec4(0.0, 0.0, 0.0, 0.0);" << std::endl;
// FIXME GL3 SPECULAR: TEXGEN REFLECTION CUBE
// TODO: Texgen calculation
}
ss << "}" << std::endl;
result = ss.str();
}
} /* anonymous namespace */
void CDriverGL3::generateBuiltinVertexProgram()
{
std::unordered_set<CVPBuiltin>::iterator it = m_VPBuiltinCache.find(m_VPBuiltinCurrent);
if (it != m_VPBuiltinCache.end())
{
m_VPBuiltinCurrent.VertexProgram = it->VertexProgram;
return;
}
std::string result;
vpGenerate(result, m_VPBuiltinCurrent);
CVertexProgram *vertexProgram = new CVertexProgram();
IProgram::CSource *src = new IProgram::CSource();
src->Profile = IProgram::glsl330v;
src->DisplayName = "Builtin Vertex Program (" + NLMISC::toString(m_VPBuiltinCache.size()) + ")";
src->setSource(result);
vertexProgram->addSource(src);
nldebug("GL3: Generate '%s'", src->DisplayName.c_str());
if (!compileVertexProgram(vertexProgram))
{
delete vertexProgram; vertexProgram = NULL;
}
m_VPBuiltinCurrent.VertexProgram = vertexProgram;
m_VPBuiltinCache.insert(m_VPBuiltinCurrent);
}
void CDriverGL3::enableFogVP(bool enable)
{
H_AUTO_OGL(CDriverGL3_enableFogInternal)
if (m_VPBuiltinCurrent.Fog != enable)
{
m_VPBuiltinCurrent.Fog = enable;
m_VPBuiltinTouched = true;
}
}
void CDriverGL3::enableLightingVP(bool enable)
{
H_AUTO_OGL(CDriverGL3_enableLightingVP)
if (m_VPBuiltinCurrent.Lighting != enable)
{
m_VPBuiltinCurrent.Lighting = enable;
m_VPBuiltinTouched = true;
}
}
void CDriverGL3::touchLightVP(int i)
{
H_AUTO_OGL(CDriverGL3_touchLightVP)
sint mode = _UserLightEnable[i] ? _LightMode[i] : -1;
if (m_VPBuiltinCurrent.LightMode[i] != mode)
{
m_VPBuiltinCurrent.LightMode[i] = mode;
if (m_VPBuiltinCurrent.Lighting)
m_VPBuiltinTouched = true;
}
}
void CDriverGL3::touchVertexFormatVP()
{
H_AUTO_OGL(CDriverGL3_touchLightVP)
uint16 format = _CurrentVertexBufferGL->VB->getVertexFormat();
if (m_VPBuiltinCurrent.VertexFormat != format)
{
m_VPBuiltinCurrent.VertexFormat = format;
m_VPBuiltinTouched = true;
}
}
void CDriverGL3::setTexGenModeVP(uint stage, sint mode)
{
H_AUTO_OGL(CDriverGL3_setTexGenModeVP)
if (m_VPBuiltinCurrent.TexGenMode[stage] != mode)
{
//if (mode >= 0)
// nlwarning("enable texgen %i, %i, not implemented", stage, mode);
m_VPBuiltinCurrent.TexGenMode[stage] = mode;
m_VPBuiltinTouched = true;
}
}
} // NLDRIVERGL3
} // NL3D

File diff suppressed because it is too large Load Diff

@ -0,0 +1,40 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#import <Cocoa/Cocoa.h>
#ifdef NL_STATIC
#ifdef USE_OPENGLES
using NL3D::NLDRIVERGLES::CDriverGL;
#else
using NL3D::NLDRIVERGL::CDriverGL;
#endif
#else
using NL3D::CDriverGL;
#endif
@interface CocoaApplicationDelegate : NSObject
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
<NSApplicationDelegate>
#endif
{
CDriverGL* _driver;
}
-(id)initWithDriver:(CDriverGL*)driver;
-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
@end

@ -0,0 +1,60 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "../stdopengl.h"
#include "../driver_opengl.h"
#include "cocoa_application_delegate.h"
#include "cocoa_event_emitter.h"
static NSApplicationTerminateReply applicationShouldTerminate(CDriverGL* driver)
{
// cancel if there is a driver and a custom exit handler set up
if(driver && driver->ExitFunc)
{
driver->ExitFunc();
return NSTerminateCancel;
}
NLMISC::CCocoaEventEmitter* eventEmitter =
NLMISC::safe_cast<NLMISC::CCocoaEventEmitter*>(&(driver->_EventEmitter));
// cancel if there is a driver and cocoa event emitter handles the quit
if(driver && eventEmitter && eventEmitter->handleQuitRequest())
return NSTerminateCancel;
// just let the app terminate if no custom quit handling worked
return NSTerminateNow;
}
@implementation CocoaApplicationDelegate
-(id)initWithDriver:(CDriverGL*)driver
{
if((self = [super init]))
{
_driver = driver;
return self;
}
return nil;
}
-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
{
return applicationShouldTerminate(_driver);
}
@end

@ -0,0 +1,508 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "cocoa_event_emitter.h"
namespace NLMISC
{
/// map from virtual key code to nel internal key code
static NLMISC::TKey virtualKeycodeToNelKey(unsigned short keycode)
{
switch(keycode)
{
case kVK_ANSI_0: return NLMISC::Key0;
case kVK_ANSI_1: return NLMISC::Key1;
case kVK_ANSI_2: return NLMISC::Key2;
case kVK_ANSI_3: return NLMISC::Key3;
case kVK_ANSI_4: return NLMISC::Key4;
case kVK_ANSI_5: return NLMISC::Key5;
case kVK_ANSI_6: return NLMISC::Key6;
case kVK_ANSI_7: return NLMISC::Key7;
case kVK_ANSI_8: return NLMISC::Key8;
case kVK_ANSI_9: return NLMISC::Key9;
case kVK_ANSI_A: return NLMISC::KeyA;
case kVK_ANSI_B: return NLMISC::KeyB;
case kVK_ANSI_C: return NLMISC::KeyC;
case kVK_ANSI_D: return NLMISC::KeyD;
case kVK_ANSI_E: return NLMISC::KeyE;
case kVK_ANSI_F: return NLMISC::KeyF;
case kVK_ANSI_G: return NLMISC::KeyG;
case kVK_ANSI_H: return NLMISC::KeyH;
case kVK_ANSI_I: return NLMISC::KeyI;
case kVK_ANSI_J: return NLMISC::KeyJ;
case kVK_ANSI_K: return NLMISC::KeyK;
case kVK_ANSI_L: return NLMISC::KeyL;
case kVK_ANSI_M: return NLMISC::KeyM;
case kVK_ANSI_N: return NLMISC::KeyN;
case kVK_ANSI_O: return NLMISC::KeyO;
case kVK_ANSI_P: return NLMISC::KeyP;
case kVK_ANSI_Q: return NLMISC::KeyQ;
case kVK_ANSI_R: return NLMISC::KeyR;
case kVK_ANSI_S: return NLMISC::KeyS;
case kVK_ANSI_T: return NLMISC::KeyT;
case kVK_ANSI_U: return NLMISC::KeyU;
case kVK_ANSI_V: return NLMISC::KeyV;
case kVK_ANSI_W: return NLMISC::KeyW;
case kVK_ANSI_X: return NLMISC::KeyX;
case kVK_ANSI_Y: return NLMISC::KeyY;
case kVK_ANSI_Z: return NLMISC::KeyZ;
case kVK_ANSI_Equal: return NLMISC::KeyEQUALS;
case kVK_ANSI_Minus: return NLMISC::KeySUBTRACT;
case kVK_ANSI_RightBracket: return NLMISC::KeyRBRACKET;
case kVK_ANSI_LeftBracket: return NLMISC::KeyLBRACKET;
case kVK_ANSI_Quote: return NLMISC::KeyAPOSTROPHE;
case kVK_ANSI_Grave: return NLMISC::KeyPARAGRAPH;
case kVK_ANSI_Slash: return NLMISC::KeySLASH;
case kVK_ANSI_Backslash: return NLMISC::KeyBACKSLASH;
case kVK_ANSI_Comma: return NLMISC::KeyCOMMA;
case kVK_ANSI_Period: return NLMISC::KeyPERIOD;
case kVK_ANSI_Semicolon: return NLMISC::KeySEMICOLON;
case kVK_ANSI_KeypadDecimal: return NLMISC::KeyDECIMAL;
case kVK_ANSI_KeypadMultiply: return NLMISC::KeyMULTIPLY;
case kVK_ANSI_KeypadPlus: return NLMISC::KeyADD;
case kVK_ANSI_KeypadClear: return NLMISC::KeyDELETE;
case kVK_ANSI_KeypadDivide: return NLMISC::KeyDIVIDE;
case kVK_ANSI_KeypadEnter: return NLMISC::KeyRETURN;
case kVK_ANSI_KeypadMinus: return NLMISC::KeySUBTRACT;
case kVK_ANSI_KeypadEquals: return NLMISC::KeySEPARATOR;
case kVK_ANSI_Keypad0: return NLMISC::KeyNUMPAD0;
case kVK_ANSI_Keypad1: return NLMISC::KeyNUMPAD1;
case kVK_ANSI_Keypad2: return NLMISC::KeyNUMPAD2;
case kVK_ANSI_Keypad3: return NLMISC::KeyNUMPAD3;
case kVK_ANSI_Keypad4: return NLMISC::KeyNUMPAD4;
case kVK_ANSI_Keypad5: return NLMISC::KeyNUMPAD5;
case kVK_ANSI_Keypad6: return NLMISC::KeyNUMPAD6;
case kVK_ANSI_Keypad7: return NLMISC::KeyNUMPAD7;
case kVK_ANSI_Keypad8: return NLMISC::KeyNUMPAD8;
case kVK_ANSI_Keypad9: return NLMISC::KeyNUMPAD9;
case kVK_Return: return NLMISC::KeyRETURN;
case kVK_Tab: return NLMISC::KeyTAB;
case kVK_Space: return NLMISC::KeySPACE;
case kVK_Delete: return NLMISC::KeyBACK;
case kVK_ForwardDelete: return NLMISC::KeyDELETE;
case kVK_Escape: return NLMISC::KeyESCAPE;
case kVK_Shift: return NLMISC::KeySHIFT;
case kVK_RightShift: return NLMISC::KeyRSHIFT;
case kVK_CapsLock: return NLMISC::KeyCAPITAL;
case kVK_Control: return NLMISC::KeyCONTROL;
case kVK_RightControl: return NLMISC::KeyRCONTROL;
case kVK_F1: return NLMISC::KeyF1;
case kVK_F2: return NLMISC::KeyF2;
case kVK_F3: return NLMISC::KeyF3;
case kVK_F4: return NLMISC::KeyF4;
case kVK_F5: return NLMISC::KeyF5;
case kVK_F6: return NLMISC::KeyF6;
case kVK_F7: return NLMISC::KeyF7;
case kVK_F8: return NLMISC::KeyF8;
case kVK_F9: return NLMISC::KeyF9;
case kVK_F11: return NLMISC::KeyF11;
case kVK_F13: return NLMISC::KeyF13;
case kVK_F16: return NLMISC::KeyF16;
case kVK_F14: return NLMISC::KeyF14;
case kVK_F10: return NLMISC::KeyF10;
case kVK_F12: return NLMISC::KeyF12;
case kVK_F15: return NLMISC::KeyF15;
case kVK_F17: return NLMISC::KeyF17;
case kVK_F18: return NLMISC::KeyF18;
case kVK_F19: return NLMISC::KeyF19;
case kVK_F20: return NLMISC::KeyF20;
case kVK_Home: return NLMISC::KeyHOME;
case kVK_End: return NLMISC::KeyEND;
case kVK_PageUp: return NLMISC::KeyPRIOR;
case kVK_PageDown: return NLMISC::KeyNEXT;
case kVK_LeftArrow: return NLMISC::KeyLEFT;
case kVK_RightArrow: return NLMISC::KeyRIGHT;
case kVK_DownArrow: return NLMISC::KeyDOWN;
case kVK_UpArrow: return NLMISC::KeyUP;
case kVK_Command:break;
case kVK_Option:break;
case kVK_RightOption:break;
case kVK_Function:break;
case kVK_VolumeUp:break;
case kVK_VolumeDown:break;
case kVK_Mute:break;
case kVK_Help:break;
case kVK_ISO_Section:break;
case kVK_JIS_Yen:break;
case kVK_JIS_Underscore:break;
case kVK_JIS_KeypadComma:break;
case kVK_JIS_Eisu:break;
case kVK_JIS_Kana:break;
default:break;
}
return NLMISC::KeyNOKEY;
}
bool CCocoaEventEmitter::pasteTextFromClipboard(ucstring &text)
{
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
NSDictionary *options = [NSDictionary dictionary];
BOOL ok = [pasteboard canReadObjectForClasses:classArray options:options];
if (ok)
{
NSArray *objectsToPaste = [pasteboard readObjectsForClasses:classArray options:options];
NSString *nstext = [objectsToPaste objectAtIndex:0];
text.fromUtf8([nstext UTF8String]);
return true;
}
return false;
}
bool CCocoaEventEmitter::copyTextToClipboard(const ucstring &text)
{
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
[pasteboard clearContents];
NSArray *copiedObjects = [NSArray arrayWithObject:[NSString stringWithUTF8String:text.toUtf8().c_str()]];
[pasteboard writeObjects:copiedObjects];
return true;
}
/// convert modifier key state to nel internal modifier key state
static NLMISC::TKeyButton modifierFlagsToNelKeyButton(unsigned int modifierFlags)
{
unsigned int buttons = 0;
if (modifierFlags & NSControlKeyMask) buttons |= NLMISC::ctrlKeyButton;
if (modifierFlags & NSShiftKeyMask) buttons |= NLMISC::shiftKeyButton;
if (modifierFlags & NSAlternateKeyMask) buttons |= NLMISC::altKeyButton;
return (NLMISC::TKeyButton)buttons;
}
/// check whether a given event represents input text
static bool isTextKeyEvent(NSEvent* event)
{
// if there are no characters provided with this event, it is not a text event
if([[event characters] length] == 0)
return false;
NLMISC::TKey nelKey = virtualKeycodeToNelKey([event keyCode]);
// ryzom ui wants to have "escape key string" to leave text box
if(nelKey == NLMISC::KeyESCAPE)
return true;
// ryzom ui wants to have "return key string" to submit text box (send chat)
if(nelKey == NLMISC::KeyRETURN)
return true;
// get the character reported by cocoa
unsigned int character = [[event characters] characterAtIndex:0];
// printable ascii characters
if(isprint(character))
return true;
/*
TODO check why iswprint(character) does not solve it.
it always returns false, even for non-ASCII characters
*/
// characters > 127 but not printable
if( nelKey == NLMISC::KeyF1 || nelKey == NLMISC::KeyF2 ||
nelKey == NLMISC::KeyF3 || nelKey == NLMISC::KeyF4 ||
nelKey == NLMISC::KeyF5 || nelKey == NLMISC::KeyF6 ||
nelKey == NLMISC::KeyF7 || nelKey == NLMISC::KeyF8 ||
nelKey == NLMISC::KeyF9 || nelKey == NLMISC::KeyF10 ||
nelKey == NLMISC::KeyF11 || nelKey == NLMISC::KeyF12 ||
nelKey == NLMISC::KeyF13 || nelKey == NLMISC::KeyF14 ||
nelKey == NLMISC::KeyF15 || nelKey == NLMISC::KeyF16 ||
nelKey == NLMISC::KeyF17 || nelKey == NLMISC::KeyF18 ||
nelKey == NLMISC::KeyF19 || nelKey == NLMISC::KeyF20 ||
nelKey == NLMISC::KeyUP || nelKey == NLMISC::KeyDOWN ||
nelKey == NLMISC::KeyLEFT || nelKey == NLMISC::KeyRIGHT ||
nelKey == NLMISC::KeyHOME || nelKey == NLMISC::KeyEND ||
nelKey == NLMISC::KeyPRIOR || nelKey == NLMISC::KeyNEXT ||
nelKey == NLMISC::KeyDELETE)
return false;
// all the fancy wide characters
if(character > 127)
return true;
return false;
}
void CCocoaEventEmitter::init(
NL3D::IDriver* driver, CocoaOpenGLView* glView, bool eventLoop)
{
_driver = driver;
_glView = glView;
_eventLoop = eventLoop;
}
bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
{
if(!server && !_server)
{
// nlerror("no server to post events to");
nldebug("no server to post events to");
return true;
}
if(!server)
server = _server;
NSRect viewRect = [_glView frame];
NSPoint mousePos = [_glView convertPoint:event.locationInWindow fromView:nil];
mousePos.x /= (float)viewRect.size.width;
mousePos.y /= (float)viewRect.size.height;
// if the mouse event was placed outside the view, don't tell NeL :)
if((mousePos.x < 0.0 || mousePos.x > 1.0 ||
mousePos.y < 0.0 || mousePos.y > 1.0) &&
event.type != NSKeyDown && event.type != NSKeyUp)
{
return false;
}
// first event about mouse movement after setting to emulateRawMode
if(_setToEmulateRawMode &&
(event.type == NSMouseMoved ||
event.type == NSLeftMouseDragged ||
event.type == NSRightMouseDragged))
{
// do not report because it reflects wrapping pointer to 0.5/0.5
_setToEmulateRawMode = false;
return false;
}
// convert the modifiers for nel to pass them with the events
NLMISC::TKeyButton modifiers =
modifierFlagsToNelKeyButton([event modifierFlags]);
switch(event.type)
{
case NSLeftMouseDown:
{
server->postEvent(new NLMISC::CEventMouseDown(
mousePos.x, mousePos.y,
(NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this));
}
break;
case NSLeftMouseUp:
{
server->postEvent(new NLMISC::CEventMouseUp(
mousePos.x, mousePos.y,
(NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this));
break;
}
case NSRightMouseDown:
{
server->postEvent(new NLMISC::CEventMouseDown(
mousePos.x, mousePos.y,
(NLMISC::TMouseButton)(NLMISC::rightButton | modifiers), this));
break;
}
case NSRightMouseUp:
{
server->postEvent(new NLMISC::CEventMouseUp(
mousePos.x, mousePos.y,
(NLMISC::TMouseButton)(NLMISC::rightButton | modifiers), this));
break;
}
case NSMouseMoved:
{
NLMISC::CEvent* nelEvent;
// when emulating raw mode, send the delta in a CGDMouseMove event
if(_emulateRawMode)
nelEvent = new NLMISC::CGDMouseMove(
this, NULL /* no mouse device */, event.deltaX, -event.deltaY);
// normally send position in a CEventMouseMove
else
nelEvent = new NLMISC::CEventMouseMove(
mousePos.x, mousePos.y, (NLMISC::TMouseButton)modifiers, this);
server->postEvent(nelEvent);
break;
}
case NSLeftMouseDragged:
{
NLMISC::CEvent* nelEvent;
// when emulating raw mode, send the delta in a CGDMouseMove event
if(_emulateRawMode)
nelEvent = new NLMISC::CGDMouseMove(
this, NULL /* no mouse device */, event.deltaX, -event.deltaY);
// normally send position in a CEventMouseMove
else
nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y,
(NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this);
server->postEvent(nelEvent);
break;
}
case NSRightMouseDragged:
{
NLMISC::CEvent* nelEvent;
// when emulating raw mode, send the delta in a CGDMouseMove event
if(_emulateRawMode)
nelEvent = new NLMISC::CGDMouseMove(
this, NULL /* no mouse device */, event.deltaX, -event.deltaY);
// normally send position in a CEventMouseMove
else
nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y,
(NLMISC::TMouseButton)(NLMISC::rightButton | modifiers), this);
server->postEvent(nelEvent);
break;
}
case NSMouseEntered:break;
case NSMouseExited:break;
case NSKeyDown:
{
// push the key press event to the event server
server->postEvent(new NLMISC::CEventKeyDown(
virtualKeycodeToNelKey([event keyCode]),
modifiers,
[event isARepeat] == NO, this));
// if this was a text event
if(isTextKeyEvent(event))
{
ucstring ucstr;
// get the string associated with the key press event
ucstr.fromUtf8([[event characters] UTF8String]);
// push the text event to event server as well
server->postEvent(new NLMISC::CEventChar(
ucstr[0], modifiers, this));
}
break;
}
case NSKeyUp:
{
// push the key release event to the event server
server->postEvent(new NLMISC::CEventKeyUp(
virtualKeycodeToNelKey([event keyCode]),
modifiers, this));
break;
}
case NSFlagsChanged:break;
case NSAppKitDefined:break;
case NSSystemDefined:break;
case NSApplicationDefined:break;
case NSPeriodic:break;
case NSCursorUpdate:break;
case NSScrollWheel:
{
if(fabs(event.deltaY) > 0.1)
server->postEvent(new NLMISC::CEventMouseWheel(
mousePos.x, mousePos.y, (NLMISC::TMouseButton)modifiers,
(event.deltaY > 0), this));
break;
}
case NSTabletPoint:break;
case NSTabletProximity:break;
case NSOtherMouseDown:break;
case NSOtherMouseUp:break;
case NSOtherMouseDragged:break;
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
case NSEventTypeGesture:break;
case NSEventTypeMagnify:break;
case NSEventTypeSwipe:break;
case NSEventTypeRotate:break;
case NSEventTypeBeginGesture:break;
case NSEventTypeEndGesture:break;
#endif
default:
{
nlwarning("Unknown event type. dropping.");
NSLog(@"%@", event);
break;
}
}
if(_emulateRawMode && _driver && (event.type == NSMouseMoved ||
event.type == NSLeftMouseDragged || event.type == NSRightMouseDragged))
{
_driver->setMousePos(0.5, 0.5);
}
return true;
}
bool CCocoaEventEmitter::handleQuitRequest()
{
if(_server)
{
_server->postEvent(new CEventDestroyWindow(this));
return true;
}
return false;
}
typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e);
void CCocoaEventEmitter::submitEvents(CEventServer& server, bool /* allWins */)
{
// break if there was no event to handle
// if running embedded in e.g. qt, _eventLoop will be false
while(_eventLoop)
{
// get the next event to handle
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:nil /*[NSDate distantFuture]*/
inMode:NSDefaultRunLoopMode dequeue:YES];
// stop, if there was no event
if(!event)
break;
// if there is a driver set up, forward event to it's windowProc
if(_driver)
{
cocoaProc proc = (cocoaProc)_driver->getWindowProc();
if(proc)
proc(_driver, [event eventRef]);
}
// without driver, just process the event
else
{
processMessage(event, &server);
}
// forward the event to the cocoa application
[NSApp sendEvent:event];
}
_server = &server;
}
void CCocoaEventEmitter::emulateMouseRawMode(bool enable)
{
_emulateRawMode = enable;
if(_emulateRawMode)
{
_setToEmulateRawMode = true;
if(_driver)
_driver->setMousePos(0.5, 0.5);
}
}
}

@ -0,0 +1,64 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_COCOA_EVENT_EMITTER_H
#define NL_COCOA_EVENT_EMITTER_H
#include "nel/misc/event_emitter.h"
#include "nel/misc/event_server.h"
#include "nel/misc/events.h"
#include "nel/misc/game_device_events.h"
#include "nel/3d/driver.h"
#import "cocoa_opengl_view.h"
#include <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
namespace NLMISC
{
class CCocoaEventEmitter : public IEventEmitter
{
bool _emulateRawMode;
bool _setToEmulateRawMode;
bool _eventLoop;
NL3D::IDriver* _driver;
CocoaOpenGLView* _glView;
// TODO like internal server in unix event emitter... review!
CEventServer* _server;
public:
CCocoaEventEmitter() :
_emulateRawMode(false),
_setToEmulateRawMode(false),
_driver(NULL),
_glView(nil),
_server(NULL) { }
void init(NL3D::IDriver*, CocoaOpenGLView*, bool eventLoop);
bool processMessage(NSEvent* event, CEventServer* server = NULL);
virtual void submitEvents(CEventServer& server, bool allWindows);
virtual void emulateMouseRawMode(bool enable);
bool handleQuitRequest();
virtual bool copyTextToClipboard(const ucstring &text);
virtual bool pasteTextFromClipboard(ucstring &text);
};
}
#endif

@ -0,0 +1,61 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#import <Cocoa/Cocoa.h>
namespace NL3D
{
#ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL {
#endif
#endif
class CDriverGL;
#ifdef NL_STATIC
} // NLDRIVERGL/ES
#endif
}
#ifdef NL_STATIC
#ifdef USE_OPENGLES
using NL3D::NLDRIVERGLES::CDriverGL;
#else
using NL3D::NLDRIVERGL::CDriverGL;
#endif
#else
using NL3D::CDriverGL;
#endif
@interface CocoaOpenGLView : NSOpenGLView<NSTextInputClient>
{
NSMutableAttributedString* _characterStorage;
NSRange _markedRange;
CDriverGL* _driver;
}
-(id)initWithFrame:(NSRect)frame;
-(void)dealloc;
-(void)keyDown:(NSEvent*)event;
-(void)setDriver:(CDriverGL*)driver;
-(void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize;
@end

@ -0,0 +1,152 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "../stdopengl.h"
#include "../driver_opengl.h"
#import "cocoa_opengl_view.h"
static void viewDidResize(NSView* view, CDriverGL* driver)
{
NSRect rect = [[view superview] frame];
driver->_CurrentMode.Height = rect.size.height;
driver->_CurrentMode.Width = rect.size.width;
}
@implementation CocoaOpenGLView
-(id)initWithFrame:(NSRect)frame
{
if((self = [super initWithFrame:frame]))
{
_characterStorage = [[NSMutableAttributedString alloc] initWithString:@""];
_driver = nil;
return self;
}
return nil;
}
-(void)dealloc
{
[_characterStorage release];
[super dealloc];
}
-(void)keyDown:(NSEvent*)event
{
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
[[self inputContext] handleEvent:event];
#endif
}
-(void)setDriver:(CDriverGL*)driver
{
_driver = driver;
}
-(void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize
{
[super resizeWithOldSuperviewSize:oldBoundsSize];
if(!_driver)
return;
viewDidResize(self, _driver);
}
/******************************************************************************/
/* NSTextInputClient Protocol */
-(BOOL)hasMarkedText
{
return (_markedRange.location == NSNotFound ? NO : YES);
}
-(NSRange)markedRange
{
return _markedRange;
}
-(NSRange)selectedRange
{
return NSMakeRange(NSNotFound, 0);
}
-(void)setMarkedText:(id)aString
selectedRange:(NSRange)newSelection
replacementRange:(NSRange)replacementRange
{
if(replacementRange.location == NSNotFound)
replacementRange = _markedRange;
if([aString length] == 0)
{
[_characterStorage deleteCharactersInRange:replacementRange];
[self unmarkText];
}
else
{
_markedRange = NSMakeRange(replacementRange.location, [aString length]);
[_characterStorage replaceCharactersInRange:replacementRange
withString:aString];
}
}
-(void)unmarkText
{
_markedRange = NSMakeRange(NSNotFound, 0);
[[self inputContext] discardMarkedText];
}
-(NSArray*)validAttributesForMarkedText
{
return [NSArray arrayWithObjects:
NSMarkedClauseSegmentAttributeName, NSGlyphInfoAttributeName, nil];
}
-(NSAttributedString*)attributedSubstringForProposedRange:(NSRange)aRange
actualRange:(NSRangePointer)actualRange
{
return [_characterStorage attributedSubstringFromRange:aRange];
}
-(void)insertText:(id)aString
replacementRange:(NSRange)replacementRange
{
if(replacementRange.location == NSNotFound)
replacementRange = _markedRange;
[_characterStorage replaceCharactersInRange:replacementRange
withString:aString];
}
-(NSUInteger)characterIndexForPoint:(NSPoint)aPoint
{
return 0;
}
-(NSRect)firstRectForCharacterRange:(NSRange)aRange
actualRange:(NSRangePointer)actualRange
{
return NSMakeRect(0, 0, 0, 0);
}
-(void)doCommandBySelector:(SEL)aSelector
{
[super doCommandBySelector:aSelector];
}
@end

@ -0,0 +1,41 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#import <Cocoa/Cocoa.h>
#include "AvailabilityMacros.h"
#ifdef NL_STATIC
#ifdef USE_OPENGLES
using NL3D::NLDRIVERGLES::CDriverGL;
#else
using NL3D::NLDRIVERGL::CDriverGL;
#endif
#else
using NL3D::CDriverGL;
#endif
@interface CocoaWindowDelegate : NSObject
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
<NSWindowDelegate>
#endif
{
CDriverGL* _driver;
}
- (id)initWithDriver:(CDriverGL*)driver;
- (void)windowDidMove:(NSNotification*)notification;
@end

@ -0,0 +1,59 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "../stdopengl.h"
#include "../driver_opengl.h"
#import "cocoa_window_delegate.h"
static void windowDidMove(NSWindow* window, CDriverGL* driver)
{
// get the rect (position, size) of the screen with menu bar
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
// get the rect (position, size) of the window
NSRect windowRect = [window frame];
// set x in driver
driver->_WindowX = windowRect.origin.x;
// map y from cocoa to NeL coordinates before setting in driver
driver->_WindowY =
screenRect.size.height - windowRect.size.height - windowRect.origin.y;
}
@implementation CocoaWindowDelegate
-(id)initWithDriver:(CDriverGL*)driver
{
if((self = [super init]))
{
_driver = driver;
return self;
}
return nil;
}
-(void)windowDidMove:(NSNotification *)notification
{
if(!_driver)
return;
windowDidMove([notification object], _driver);
}
@end

@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: nel-driverogl
Version: @VERSION@
Description: NeL @VERSION@
Requires:
Libs: -L${libdir}
Libs.private: @LIBS@ @OPENGL_LIBS@ @XF86VIDMODE_LIBS@ -lXmu
Cflags: -I${includedir} @OPENGL_CFLAGS@ @XF86VIDMODE_CFLAGS@

@ -0,0 +1,17 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h"

@ -0,0 +1,68 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/misc/types_nl.h"
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <exception>
#include <utility>
#include <deque>
#include <limits>
#ifdef NL_OS_WINDOWS
# define WIN32_LEAN_AND_MEAN
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# include <windowsx.h>
#endif
#ifdef NL_OS_WINDOWS
#include <GL/gl.h>
#include "GL/wglext.h"
#elif defined(NL_OS_MAC)
#define GL_GLEXT_LEGACY
#include <OpenGL/gl.h>
#elif defined (NL_OS_UNIX)
#define GLX_GLXEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glx.h>
#include "GL/glxext.h"
#endif
#include "GL/glext.h"
#include "nel/misc/common.h"
#include "nel/misc/debug.h"
#include "nel/misc/stream.h"
#include "nel/misc/mem_stream.h"
#include "nel/misc/time_nl.h"
#include "nel/misc/command.h"
#include "nel/3d/driver.h"
#define NL_OPENGL3_MAX_LIGHT 8

@ -0,0 +1,829 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//#include "stdopengl.h"
#include "unix_event_emitter.h"
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/Xutil.h>
#include "nel/misc/debug.h"
typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
static Atom XA_CLIPBOARD = 0;
static Atom XA_UTF8_STRING = 0;
static Atom XA_TARGETS = 0;
static Atom XA_NEL_SEL = 0;
static Atom XA_WM_DELETE_WINDOW = 0;
namespace NLMISC {
CUnixEventEmitter::CUnixEventEmitter ():_dpy(NULL), _win(0), _driver(NULL)
{
_im = 0;
_ic = 0;
_SelectionOwned=false;
}
CUnixEventEmitter::~CUnixEventEmitter()
{
closeIM();
}
void CUnixEventEmitter::init(Display *dpy, Window win, NL3D::IDriver *driver)
{
_dpy = dpy;
_win = win;
_driver = driver;
XSelectInput (_dpy, _win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|StructureNotifyMask|ExposureMask|EnterWindowMask|LeaveWindowMask|FocusChangeMask);
// define Atoms used by clipboard
XA_CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False);
XA_UTF8_STRING = XInternAtom(dpy, "UTF8_STRING", False);
XA_TARGETS = XInternAtom(dpy, "TARGETS", False);
XA_NEL_SEL = XInternAtom(dpy, "NeL_SEL", False);
// define Atom used by delete window
XA_WM_DELETE_WINDOW = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
XSetWMProtocols(dpy, win, &XA_WM_DELETE_WINDOW, 1);
/*
TODO: implements all useful events processing
ButtonMotionMask|Button1MotionMask|Button2MotionMask|
Button3MotionMask|Button4MotionMask|Button5MotionMask|KeymapStateMask|
SubstructureNotifyMask|VisibilityChangeMask|PropertyChangeMask|
ColormapChangeMask|OwnerGrabButtonMask
*/
createIM();
}
void CUnixEventEmitter::createIM()
{
#ifdef X_HAVE_UTF8_STRING
XModifierKeymap *g_mod_map = XGetModifierMapping(_dpy);
char *modifiers = XSetLocaleModifiers(getenv("XMODIFIERS"));
_im = XOpenIM(_dpy, NULL, NULL, NULL);
if (_im)
{
_ic = XCreateIC(_im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, _win, XNFocusWindow, _win, NULL);
// XSetICFocus(_ic);
}
else
{
_ic = 0;
nlwarning("XCreateIM failed");
}
if (!_ic)
{
nlwarning("XCreateIC failed");
}
#endif
}
void CUnixEventEmitter::closeIM()
{
#ifdef X_HAVE_UTF8_STRING
if (_ic)
{
XDestroyIC(_ic);
_ic = 0;
}
if (_im)
{
XCloseIM(_im);
_im = 0;
}
#endif
}
void CUnixEventEmitter::submitEvents(CEventServer & server, bool allWindows)
{
while (XPending(_dpy))
{
XEvent Event;
XNextEvent(_dpy, &Event);
if (allWindows || Event.xany.window == _win)
{
// nlinfo("event: %d", Event.type);
if (_driver)
{
// forward X events to OpenGL driver
x11Proc proc = (x11Proc)_driver->getWindowProc();
if (proc)
proc(_driver, &Event);
}
else
{
processMessage (Event, &server);
}
}
}
// Dispatch sent messages
_InternalServer.setServer (&server);
_InternalServer.pump (allWindows);
}
static Bool isMouseMoveEvent(Display *display, XEvent *event, XPointer arg)
{
return (event->type == MotionNotify);
}
#ifndef AltMask
# ifdef NL_OS_MAC
# define AltMask (8192)
# else
# define AltMask (Mod1Mask)
# endif
#endif
TMouseButton getMouseButton (uint32 state)
{
uint32 button=noButton;
if (state&Button1Mask) button|=leftButton;
if (state&Button2Mask) button|=middleButton;
if (state&Button3Mask) button|=rightButton;
if (state&ControlMask) button|=ctrlButton;
if (state&ShiftMask) button|=shiftButton;
if (state&AltMask) button|=altButton;
return (TMouseButton)button;
}
TKeyButton getKeyButton (uint32 state)
{
uint32 button=noKeyButton;
if (state&ControlMask) button|=ctrlKeyButton;
if (state&ShiftMask) button|=shiftKeyButton;
if (state&AltMask) button|=altKeyButton;
return (TKeyButton)button;
}
TKey getKeyFromKeycode (uint keycode)
{
// keycodes are depending on system
switch (keycode)
{
#ifdef NL_OS_MAC
/*
TODO use key mapping from driver/opengl/mac/cocoa_adapter.mm
*/
case 0x12: return Key1;
case 0x13: return Key2;
case 0x14: return Key3;
case 0x15: return Key4;
case 0x16: return Key6;
case 0x17: return Key5;
case 0x18: return KeyEQUALS;
case 0x19: return Key9;
case 0x1a: return Key7;
case 0x1c: return Key8;
case 0x1d: return Key0;
case 0x1e: return KeyRBRACKET;
case 0x21: return KeyLBRACKET;
case 0x27: return KeyAPOSTROPHE;
case 0x29: return KeySEMICOLON;
case 0x2a: return KeyBACKSLASH;
case 0x2b: return KeyCOMMA;
case 0x2c: return KeySLASH;
case 0x2f: return KeyPERIOD;
// case 0x5e: return KeyOEM_102;
// case 0x30: return KeyTILDE;
// case 0x3d: return KeyPARAGRAPH;
#else
case 0x0a: return Key1;
case 0x0b: return Key2;
case 0x0c: return Key3;
case 0x0d: return Key4;
case 0x0e: return Key5;
case 0x0f: return Key6;
case 0x10: return Key7;
case 0x11: return Key8;
case 0x12: return Key9;
case 0x13: return Key0;
case 0x14: return KeyLBRACKET;
case 0x15: return KeyEQUALS;
case 0x22: return KeyRBRACKET;
case 0x23: return KeySEMICOLON;
case 0x2f: return KeyCOMMA;
case 0x30: return KeyTILDE;
case 0x31: return KeyAPOSTROPHE;
case 0x33: return KeyBACKSLASH;
case 0x5e: return KeyOEM_102;
// case 0x3a: return KeyCOMMA;
case 0x3b: return KeyPERIOD;
case 0x3c: return KeySLASH;
case 0x3d: return KeyPARAGRAPH;
// for non-standard keyboards, maps to QWERTY keys
case 0x18: return KeyQ;
case 0x19: return KeyW;
case 0x1a: return KeyE;
case 0x1b: return KeyR;
case 0x1c: return KeyT;
case 0x1d: return KeyY;
case 0x1e: return KeyU;
case 0x1f: return KeyI;
case 0x20: return KeyO;
case 0x21: return KeyP;
case 0x26: return KeyQ;
case 0x27: return KeyS;
case 0x28: return KeyD;
case 0x29: return KeyF;
case 0x2a: return KeyG;
case 0x2b: return KeyH;
case 0x2c: return KeyJ;
case 0x2d: return KeyK;
case 0x2e: return KeyL;
case 0x34: return KeyZ;
case 0x35: return KeyX;
case 0x36: return KeyC;
case 0x37: return KeyV;
case 0x38: return KeyB;
case 0x39: return KeyN;
case 0x3a: return KeyM;
#endif
default:
// nlwarning("missing keycode 0x%x %d '%c'", keycode, keycode, keycode);
break;
}
return KeyNOKEY;
}
TKey getKeyFromKeySym (KeySym keysym)
{
// nlwarning("0x%x %d '%c'", keysym, keysym, keysym);
switch (keysym)
{
case XK_BackSpace: return KeyBACK;
case XK_Tab: return KeyTAB;
case XK_Return: return KeyRETURN;
case XK_Sys_Req: return KeySNAPSHOT;
case XK_Scroll_Lock: return KeySCROLL;
case XK_Pause: return KeyPAUSE;
case XK_Escape: return KeyESCAPE;
case XK_Delete: return KeyDELETE;
case XK_Home: return KeyHOME;
case XK_Left: return KeyLEFT;
case XK_Up: return KeyUP;
case XK_Right: return KeyRIGHT;
case XK_Down: return KeyDOWN;
case XK_Page_Up: return KeyPRIOR;
case XK_Page_Down: return KeyNEXT;
case XK_End: return KeyEND;
case XK_Print: return KeyPRINT;
case XK_Insert: return KeyINSERT;
case XK_Num_Lock: return KeyNUMLOCK;
case XK_KP_0: return KeyNUMPAD0;
case XK_KP_1: return KeyNUMPAD1;
case XK_KP_2: return KeyNUMPAD2;
case XK_KP_3: return KeyNUMPAD3;
case XK_KP_4: return KeyNUMPAD4;
case XK_KP_5: return KeyNUMPAD5;
case XK_KP_6: return KeyNUMPAD6;
case XK_KP_7: return KeyNUMPAD7;
case XK_KP_8: return KeyNUMPAD8;
case XK_KP_9: return KeyNUMPAD9;
case XK_KP_Enter: return KeyRETURN;
case XK_KP_Home: return KeyHOME;
case XK_KP_Left: return KeyLEFT;
case XK_KP_Up: return KeyUP;
case XK_KP_Right: return KeyRIGHT;
case XK_KP_Down: return KeyDOWN;
case XK_KP_Page_Up: return KeyPRIOR;
case XK_KP_Page_Down: return KeyNEXT;
case XK_KP_End: return KeyEND;
case XK_KP_Begin: return KeyCANCEL;
case XK_KP_Insert: return KeyINSERT;
case XK_KP_Delete: return KeyDELETE;
case XK_KP_Multiply: return KeyMULTIPLY;
case XK_KP_Add: return KeyADD;
case XK_KP_Subtract: return KeySUBTRACT;
case XK_KP_Decimal: return KeyDECIMAL;
// case XK_period: return KeyDECIMAL;
case XK_KP_Divide: return KeyDIVIDE;
case XK_F1: return KeyF1;
case XK_F2: return KeyF2;
case XK_F3: return KeyF3;
case XK_F4: return KeyF4;
case XK_F5: return KeyF5;
case XK_F6: return KeyF6;
case XK_F7: return KeyF7;
case XK_F8: return KeyF8;
case XK_F9: return KeyF9;
case XK_F10: return KeyF10;
case XK_F11: return KeyF11;
case XK_F12: return KeyF12;
case XK_Shift_L: return KeySHIFT;
case XK_Shift_R: return KeySHIFT;
case XK_Control_L: return KeyCONTROL;
case XK_Control_R: return KeyCONTROL;
case XK_Caps_Lock: return KeyCAPITAL;
case XK_Super_L: return KeyLWIN;
case XK_Super_R: return KeyRWIN;
case XK_Mode_switch: return KeyMENU;
case XK_ISO_Level3_Shift: return KeyMENU;
case XK_Menu: return KeyAPPS;
case XK_Alt_L: return KeyMENU;
case XK_Alt_R: return KeyMENU;
case XK_space: return KeySPACE;
case XK_A:
case XK_a: return KeyA;
case XK_B:
case XK_b: return KeyB;
case XK_C:
case XK_c: return KeyC;
case XK_D:
case XK_d: return KeyD;
case XK_E:
case XK_e: return KeyE;
case XK_F:
case XK_f: return KeyF;
case XK_G:
case XK_g: return KeyG;
case XK_H:
case XK_h: return KeyH;
case XK_I:
case XK_i: return KeyI;
case XK_J:
case XK_j: return KeyJ;
case XK_K:
case XK_k: return KeyK;
case XK_L:
case XK_l: return KeyL;
case XK_M:
case XK_m: return KeyM;
case XK_N:
case XK_n: return KeyN;
case XK_O:
case XK_o: return KeyO;
case XK_P:
case XK_p: return KeyP;
case XK_Q:
case XK_q: return KeyQ;
case XK_R:
case XK_r: return KeyR;
case XK_S:
case XK_s: return KeyS;
case XK_T:
case XK_t: return KeyT;
case XK_U:
case XK_u: return KeyU;
case XK_V:
case XK_v: return KeyV;
case XK_W:
case XK_w: return KeyW;
case XK_X:
case XK_x: return KeyX;
case XK_Y:
case XK_y: return KeyY;
case XK_Z:
case XK_z: return KeyZ;
default:
// other keys don't need to be processed here
break;
}
return KeyNOKEY;
}
// check if the next pressed key is the same
static bool keyRepeat(Display *display, XEvent *event)
{
XEvent peekevent;
if (XPending(display))
{
XPeekEvent(display, &peekevent);
if ((peekevent.type == KeyPress) &&
(peekevent.xkey.keycode == event->xkey.keycode) &&
((peekevent.xkey.time-event->xkey.time) < 2))
return true;
}
return false;
}
bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
{
if (!server)
server=&_InternalServer;
XWindowAttributes xwa;
XGetWindowAttributes (_dpy, _win, &xwa);
switch (event.type)
{
case ButtonPress:
{
//nlinfo("%d %d %d", event.xbutton.button, event.xbutton.x, event.xbutton.y);
float fX = (float) event.xbutton.x / (float) xwa.width;
float fY = 1.0f - (float) event.xbutton.y / (float) xwa.height;
TMouseButton button=getMouseButton(event.xbutton.state);
switch(event.xbutton.button)
{
case Button1:
server->postEvent(new CEventMouseDown(fX, fY, (TMouseButton)(leftButton|(button&~(leftButton|middleButton|rightButton))), this));
break;
case Button2:
server->postEvent(new CEventMouseDown(fX, fY, (TMouseButton)(middleButton|(button&~(leftButton|middleButton|rightButton))), this));
break;
case Button3:
server->postEvent(new CEventMouseDown(fX, fY, (TMouseButton)(rightButton|(button&~(leftButton|middleButton|rightButton))), this));
break;
case Button4:
server->postEvent(new CEventMouseWheel(fX, fY, button, true, this));
break;
case Button5:
server->postEvent(new CEventMouseWheel(fX, fY, button, false, this));
break;
}
break;
}
case ButtonRelease:
{
//nlinfo("%d %d %d", event.xbutton.button, event.xbutton.x, event.xbutton.y);
float fX = (float) event.xbutton.x / (float) xwa.width;
float fY = 1.0f - (float) event.xbutton.y / (float) xwa.height;
switch(event.xbutton.button)
{
case Button1:
server->postEvent(new CEventMouseUp(fX, fY, leftButton, this));
break;
case Button2:
server->postEvent(new CEventMouseUp(fX, fY, middleButton, this));
break;
case Button3:
server->postEvent(new CEventMouseUp(fX, fY, rightButton, this));
break;
}
break;
}
case MotionNotify:
{
TMouseButton button=getMouseButton (event.xbutton.state);
// get the relative mouse position
float fX = (float) event.xbutton.x / (float) xwa.width;
float fY = 1.0f - (float) event.xbutton.y / (float) xwa.height;
// post a normal mouse move event to the event server
server->postEvent (new CEventMouseMove (fX, fY, button, this));
break;
}
case KeyPress:
{
// save keycode because XFilterEvent could set it to 0
uint keyCode = event.xkey.keycode;
KeySym k;
static char Text[256];
int c = 0;
// check if event is filtered
bool filtered = XFilterEvent(&event, _win);
// if key event is filtered, we shouldn't use XLookupString to retrieve KeySym
if (!filtered)
{
Status status = XLookupNone;
#ifdef X_HAVE_UTF8_STRING
if (_ic)
c = Xutf8LookupString(_ic, &event.xkey, Text, sizeof(Text), &k, &status);
#endif
if (status == XLookupNone)
c = XLookupString(&event.xkey, Text, sizeof(Text), &k, NULL);
}
else
{
k = XKeycodeToKeysym(_dpy, keyCode, 0);
}
// send CEventKeyDown event only if keyCode is defined
if (keyCode)
{
TKey key = getKeyFromKeySym(k);
if (key == KeyNOKEY)
key = getKeyFromKeycode(keyCode);
// search for key in map
std::map<TKey, bool>::const_iterator it = _PressedKeys.find(key);
// if key is not found or value is false, that's the first time
bool firstTime = (it == _PressedKeys.end()) || !it->second;
server->postEvent (new CEventKeyDown (key, getKeyButton(event.xbutton.state), firstTime, this));
_PressedKeys[key] = true;
// don't send a control character when deleting
if (key == KeyDELETE)
c = 0;
}
Text[c] = '\0';
if (c>0)
{
#ifdef X_HAVE_UTF8_STRING
ucstring ucstr;
ucstr.fromUtf8(Text);
CEventChar *charEvent = new CEventChar (ucstr[0], getKeyButton(event.xbutton.state), this);
// raw if not processed by IME
charEvent->setRaw(keyCode != 0);
server->postEvent (charEvent);
#else
for (int i = 0; i < c; i++)
{
CEventChar *charEvent = new CEventChar ((ucchar)(unsigned char)Text[i], getKeyButton(event.xbutton.state), this);
// raw if not processed by IME
charEvent->setRaw(keyCode != 0);
server->postEvent (charEvent);
}
#endif
}
break;
}
case KeyRelease:
{
if (!keyRepeat(_dpy, &event))
{
KeySym k;
// only need to get correct KeySym
int c = XLookupString(&event.xkey, NULL, 0, &k, NULL);
TKey key = getKeyFromKeySym(k);
if (key == KeyNOKEY)
key = getKeyFromKeycode(event.xkey.keycode);
server->postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this));
_PressedKeys[key] = false;
}
break;
}
case SelectionRequest:
{
XEvent respond;
XSelectionRequestEvent req = event.xselectionrequest;
respond.xselection.type= SelectionNotify;
respond.xselection.display= req.display;
respond.xselection.requestor= req.requestor;
respond.xselection.selection=req.selection;
respond.xselection.target= req.target;
respond.xselection.time = req.time;
respond.xselection.property = req.property;
if (req.property == None)
{
respond.xselection.property = req.target;
}
if (req.target == XA_TARGETS)
{
Atom targets[] =
{
XA_TARGETS,
XA_STRING,
XA_UTF8_STRING
};
respond.xselection.property = req.property;
XChangeProperty(req.display, req.requestor, req.property, XA_ATOM, 32, PropModeReplace, (unsigned char *)targets, 3 /* number of element */);
}
else if (req.target == XA_STRING)
{
respond.xselection.property = req.property;
std::string str = _CopiedString.toString();
XChangeProperty(req.display, req.requestor, req.property, XA_STRING, 8, PropModeReplace, (const unsigned char*)str.c_str(), str.length());
}
else if (req.target == XA_UTF8_STRING)
{
respond.xselection.property = req.property;
std::string str = _CopiedString.toUtf8();
XChangeProperty(req.display, req.requestor, respond.xselection.property, XA_UTF8_STRING, 8, PropModeReplace, (const unsigned char*)str.c_str(), str.length());
}
else
{
// Note: Calling XGetAtomName with arbitrary value crash the client, maybe req.target have been sanitized by X11 server
respond.xselection.property = None;
}
XSendEvent (_dpy, req.requestor, 0, 0, &respond);
break;
}
case SelectionClear:
_SelectionOwned = false;
_CopiedString = "";
break;
case SelectionNotify:
{
Atom target = event.xselection.target;
Atom actualType = 0;
int actualFormat = 0;
unsigned long nitems = 0, bytesLeft = 0;
// some applications are sending ATOM and other TARGETS
if (target == XA_TARGETS || target == XA_ATOM)
{
Atom *supportedTargets = NULL;
// list NeL selection properties
if (XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft, (unsigned char**)&supportedTargets) != Success)
return false;
if (bytesLeft > 0)
{
nlwarning("Paste: Supported TARGETS list too long.");
}
Atom bestTarget = 0;
sint bestTargetElect = 0;
// Elect best type
for (uint i=0; i < nitems; i++)
{
// nlwarning(" - Type=%s (%u)", XGetAtomName(_dpy, supportedTargets[i]), (uint)supportedTargets[i]);
if (supportedTargets[i] == XA_UTF8_STRING)
{
if (bestTargetElect < 2)
{
bestTarget = XA_UTF8_STRING;
bestTargetElect = 2;
}
}
else if (supportedTargets[i] == XA_STRING)
{
if (bestTargetElect < 1)
{
bestTarget = XA_STRING;
bestTargetElect = 1;
}
}
}
XFree(supportedTargets);
if (!bestTargetElect)
{
nlwarning("Paste buffer is not a text buffer.");
return false;
}
// request string conversion
XConvertSelection(_dpy, XA_CLIPBOARD, bestTarget, XA_NEL_SEL, _win, CurrentTime);
}
else if (target == XA_UTF8_STRING || target == XA_STRING)
{
uint8 *data = NULL;
// get selection
if (XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft, (unsigned char**)&data) != Success)
return false;
ucstring text;
std::string tmpData = (const char*)data;
XFree(data);
// convert buffer to ucstring
if (target == XA_UTF8_STRING)
{
text = ucstring::makeFromUtf8(tmpData);
}
else if (target == XA_STRING)
{
text = tmpData;
}
else
{
nlwarning("Unknow format %u", (uint)target);
}
// sent string event to event server
server->postEvent (new CEventString (text, this));
}
else
{
nlwarning("Unknow target %u", (uint)target);
}
break;
}
case FocusIn:
// keyboard focus
#ifdef X_HAVE_UTF8_STRING
if (_ic) XSetICFocus(_ic);
#endif
server->postEvent (new CEventSetFocus (true, this));
// server->postEvent(new CEventActivate(true, this));
break;
case FocusOut:
// keyboard focus
#ifdef X_HAVE_UTF8_STRING
if (_ic) XUnsetICFocus(_ic);
#endif
server->postEvent (new CEventSetFocus (false, this));
// server->postEvent(new CEventActivate(false, this));
break;
case KeymapNotify:
break;
case MappingNotify:
// update keymap
XRefreshKeyboardMapping((XMappingEvent *)&event);
break;
case DestroyNotify:
// XIM server has crashed
createIM();
break;
case ClientMessage:
if ((event.xclient.format == 32) && ((Atom)event.xclient.data.l[0] == XA_WM_DELETE_WINDOW))
{
server->postEvent(new CEventDestroyWindow(this));
}
break;
default:
// nlinfo("UnknownEvent");
// XtDispatchEvent(&event);
return false;
}
return true;
}
bool CUnixEventEmitter::copyTextToClipboard(const ucstring &text)
{
_CopiedString = text;
// NeL window is the owner of clipboard
XSetSelectionOwner(_dpy, XA_CLIPBOARD, _win, CurrentTime);
// check we are owning the clipboard
if (XGetSelectionOwner(_dpy, XA_CLIPBOARD) != _win)
{
nlwarning("Can't aquire selection");
return false;
}
_SelectionOwned = true;
return true;
}
bool CUnixEventEmitter::pasteTextFromClipboard(ucstring &text)
{
// check if we own the selection
if (_SelectionOwned)
{
text = _CopiedString;
return true;
}
// check if there is a data in clipboard
if (XGetSelectionOwner(_dpy, XA_CLIPBOARD) == None)
return false;
// request supported methods
XConvertSelection(_dpy, XA_CLIPBOARD, XA_TARGETS, XA_NEL_SEL, _win, CurrentTime);
// don't return result now
return false;
}
} // NLMISC
#endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC)

@ -0,0 +1,116 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_UNIX_EVENT_EMITTER_H
#define NL_UNIX_EVENT_EMITTER_H
#include "nel/misc/types_nl.h"
#include "nel/misc/event_emitter.h"
#include "nel/misc/events.h"
#include "nel/3d/driver.h"
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
#include <X11/Xlib.h>
namespace NLMISC {
/**
* CEventEmitter UNIX implementation
* \author Vianney Lecroart
* \author Nevrax France
* \date 2000
*/
class CUnixEventEmitter : public IEventEmitter
{
public:
/// Constructor
CUnixEventEmitter();
virtual ~CUnixEventEmitter();
/**
* initialize CUnixEventEmitter
*/
void init(Display *dpy, Window win, NL3D::IDriver *driver = NULL);
/**
* sends all events to server
* (should call CEventServer method postEvent())
*/
virtual void submitEvents(CEventServer & server, bool allWindows);
/**
* process input-related events (mouse and keyboard)
*/
bool processMessage(XEvent &event, CEventServer *server = NULL);
/**
* Copy a string to system clipboard.
*/
virtual bool copyTextToClipboard(const ucstring &text);
/*
* Paste a string from system clipboard.
*/
virtual bool pasteTextFromClipboard(ucstring &text);
void createIM();
void closeIM();
private:
// Private internal server message
class CUnixEventServer : CEventServer
{
friend class CUnixEventEmitter;
public:
void setServer (CEventServer *server)
{
_Server=server;
}
private:
virtual bool pumpEvent(CEvent* event)
{
CEventServer::pumpEvent(event);
_Server->postEvent (event);
return false;
}
private:
CEventServer *_Server;
};
Display* _dpy;
Window _win;
std::map<TKey, bool> _PressedKeys;
XIM _im;
XIC _ic;
NL3D::IDriver* _driver;
CUnixEventServer _InternalServer;
ucstring _CopiedString;
bool _SelectionOwned;
};
} // NLMISC
#endif // defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
#endif // NL_UNIX_EVENT_EMITTER_H
/* End of unix_event_emitter.h */

@ -146,6 +146,9 @@ CDriverUser::CDriverUser (uintptr_t windowIcon, TDriver driver, emptyProc exitFu
if (!_Driver && driver == OpenGlEs) if (!_Driver && driver == OpenGlEs)
_Driver= CDRU::createGlEsDriver(); _Driver= CDRU::createGlEsDriver();
if( !_Driver && driver == OpenGl3 )
_Driver = CDRU::createGl3Driver();
nlassert(_Driver); nlassert(_Driver);
_Driver->init (windowIcon, exitFunc); _Driver->init (windowIcon, exitFunc);

@ -67,6 +67,7 @@ const char *IDRV_VERSION_PROC_NAME = "NL3D_interfaceVersion";
#ifdef NL_OPENGL_AVAILABLE #ifdef NL_OPENGL_AVAILABLE
extern IDriver* createGlDriverInstance (); extern IDriver* createGlDriverInstance ();
extern IDriver* createGl3DriverInstance ();
#endif #endif
#if defined(NL_OS_WINDOWS) && defined(NL_DIRECT3D_AVAILABLE) #if defined(NL_OS_WINDOWS) && defined(NL_DIRECT3D_AVAILABLE)
@ -133,6 +134,60 @@ IDriver *CDRU::createGlDriver()
#endif #endif
} }
// ***************************************************************************
IDriver *CDRU::createGl3Driver()
{
#ifdef NL_STATIC
#ifdef NL_OPENGL_AVAILABLE
return createGl3DriverInstance ();
#else
return NULL;
#endif // NL_OPENGL_AVAILABLE
#else
IDRV_CREATE_PROC createDriver = NULL;
IDRV_VERSION_PROC versionDriver = NULL;
CLibrary driverLib;
#if defined(NL_OS_UNIX) && defined(NL_DRIVER_PREFIX)
driverLib.addLibPath(NL_DRIVER_PREFIX);
#endif
if (!driverLib.loadLibrary(NL3D_GL3_DLL_NAME, true, true, false))
{
throw EDruOpengl3DriverNotFound();
}
nlinfo ("Using the library '"NL3D_GL3_DLL_NAME"' that is in the directory: '%s'", driverLib.getLibFileName().c_str());
createDriver = (IDRV_CREATE_PROC) driverLib.getSymbolAddress(IDRV_CREATE_PROC_NAME);
if (createDriver == NULL)
{
throw EDruOpengl3DriverCorrupted();
}
versionDriver = (IDRV_VERSION_PROC) driverLib.getSymbolAddress(IDRV_VERSION_PROC_NAME);
if (versionDriver != NULL)
{
if (versionDriver()<IDriver::InterfaceVersion)
throw EDruOpengl3DriverOldVersion();
else if (versionDriver()>IDriver::InterfaceVersion)
throw EDruOpengl3DriverUnknownVersion();
}
IDriver *ret= createDriver();
if (ret == NULL)
{
throw EDruOpengl3DriverCantCreateDriver();
}
return ret;
#endif
}
// *************************************************************************** // ***************************************************************************
IDriver *CDRU::createGlEsDriver() IDriver *CDRU::createGlEsDriver()
{ {

@ -601,6 +601,8 @@ void CMeshGeom::render(IDriver *drv, CTransformShape *trans, float polygonCount,
bool useMeshVP= _MeshVertexProgram != NULL; bool useMeshVP= _MeshVertexProgram != NULL;
if( useMeshVP ) if( useMeshVP )
{ {
nlassert(_VBuffer.getVertexFormat() == (CVertexBuffer::PositionFlag | CVertexBuffer::NormalFlag | CVertexBuffer::TexCoord0Flag | CVertexBuffer::PrimaryColorFlag));
CMatrix invertedObjectMatrix; CMatrix invertedObjectMatrix;
invertedObjectMatrix = trans->getWorldMatrix().inverted(); invertedObjectMatrix = trans->getWorldMatrix().inverted();
// really ok if success to begin VP // really ok if success to begin VP

@ -92,7 +92,202 @@ const char *CProgramIndex::Names[NUM_UNIFORMS] =
"modelViewProjectionTranspose", "modelViewProjectionTranspose",
"modelViewProjectionInverseTranspose", "modelViewProjectionInverseTranspose",
"normalMatrix",
"viewMatrix",
"fog", "fog",
"fogParams",
"fogColor",
"materialColor",
//"diffuseColor",
"alphaRef",
"constant0",
"constant1",
"constant2",
"constant3",
"constant4",
"constant5",
"constant6",
"constant7",
"constant8",
"constant9",
"constant10",
"constant11",
"constant12",
"constant13",
"constant14",
"constant15",
"constant16",
"constant17",
"constant18",
"constant19",
"constant20",
"constant21",
"constant22",
"constant23",
"constant24",
"constant25",
"constant26",
"constant27",
"constant28",
"constant29",
"constant30",
"constant31",
"sampler0",
"sampler1",
"sampler2",
"sampler3",
"sampler4",
"sampler5",
"sampler6",
"sampler7",
"sampler8",
"sampler9",
"sampler10",
"sampler11",
"sampler12",
"sampler13",
"sampler14",
"sampler15",
"sampler16",
"sampler17",
"sampler18",
"sampler19",
"sampler20",
"sampler21",
"sampler22",
"sampler23",
"sampler24",
"sampler25",
"sampler26",
"sampler27",
"sampler28",
"sampler29",
"sampler30",
"sampler31",
"texMatrix0",
"texMatrix1",
"texMatrix2",
"texMatrix3",
"texGen0ObjectPlaneS",
"texGen0ObjectPlaneT",
"texGen0ObjectPlaneP",
"texGen0ObjectPlaneQ",
"texGen1ObjectPlaneS",
"texGen1ObjectPlaneT",
"texGen1ObjectPlaneP",
"texGen1ObjectPlaneQ",
"texGen2ObjectPlaneS",
"texGen2ObjectPlaneT",
"texGen2ObjectPlaneP",
"texGen2ObjectPlaneQ",
"texGen3ObjectPlaneS",
"texGen3ObjectPlaneT",
"texGen3ObjectPlaneP",
"texGen3ObjectPlaneQ",
"texGen0EyePlaneS",
"texGen0EyePlaneT",
"texGen0EyePlaneP",
"texGen0EyePlaneQ",
"texGen1EyePlaneS",
"texGen1EyePlaneT",
"texGen1EyePlaneP",
"texGen1EyePlaneQ",
"texGen2EyePlaneS",
"texGen2EyePlaneT",
"texGen2EyePlaneP",
"texGen2EyePlaneQ",
"texGen3EyePlaneS",
"texGen3EyePlaneT",
"texGen3EyePlaneP",
"texGen3EyePlaneQ",
"selfIllumination",
"light0DirOrPos",
"light1DirOrPos",
"light2DirOrPos",
"light3DirOrPos",
"light4DirOrPos",
"light5DirOrPos",
"light6DirOrPos",
"light7DirOrPos",
"light0ColAmb",
"light1ColAmb",
"light2ColAmb",
"light3ColAmb",
"light4ColAmb",
"light5ColAmb",
"light6ColAmb",
"light7ColAmb",
"light0ColDiff",
"light1ColDiff",
"light2ColDiff",
"light3ColDiff",
"light4ColDiff",
"light5ColDiff",
"light6ColDiff",
"light7ColDiff",
"light0ColSpec",
"light1ColSpec",
"light2ColSpec",
"light3ColSpec",
"light4ColSpec",
"light5ColSpec",
"light6ColSpec",
"light7ColSpec",
"light0Shininess",
"light1Shininess",
"light2Shininess",
"light3Shininess",
"light4Shininess",
"light5Shininess",
"light6Shininess",
"light7Shininess",
"light0ConstAttn",
"light1ConstAttn",
"light2ConstAttn",
"light3ConstAttn",
"light4ConstAttn",
"light5ConstAttn",
"light6ConstAttn",
"light7ConstAttn",
"light0LinAttn",
"light1LinAttn",
"light2LinAttn",
"light3LinAttn",
"light4LinAttn",
"light5LinAttn",
"light6LinAttn",
"light7LinAttn",
"light0QuadAttn",
"light1QuadAttn",
"light2QuadAttn",
"light3QuadAttn",
"light4QuadAttn",
"light5QuadAttn",
"light6QuadAttn",
"light7QuadAttn"
}; };
void IProgram::buildInfo(CSource *source) void IProgram::buildInfo(CSource *source)

@ -0,0 +1,87 @@
/*
Copyright (C) 2015 Jan Boon <jan.boon@kaetemi.be>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "std3d.h"
#include <nel/3d/uniform_buffer.h>
#include <nel/misc/debug.h>
namespace NL3D {
CUniformBuffer::CUniformBuffer()
{
nlctassert(sizeof(float) == 4);
nlctassert(sizeof(NLMISC::CVector2f) == 8);
nlctassert(sizeof(NLMISC::CVector) == 12);
nlctassert(sizeof(NLMISC::CVectorH) == 16);
// ...
}
CUniformBuffer::~CUniformBuffer()
{
/* ***********************************************
* WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance
* It can be loaded/called through CAsyncFileManager for instance
* ***********************************************/
if (DrvInfos)
DrvInfos->UniformBufferPtr = NULL; // Tell the driver info to not restaure memory when it will die
// Must kill the drv mirror of this VB.
DrvInfos.kill();
}
void *CUniformBuffer::lock()
{
m_HostMemory.reserve(Format.size());
return &m_HostMemory[0];
#if NL3D_UNIFORM_BUFFER_DEBUG
++Locked;
#endif
}
void CUniformBuffer::unlock()
{
#if NL3D_UNIFORM_BUFFER_DEBUG
--Locked;
nlassert(Locked >= 0);
#endif
Touched = true;
}
IUBDrvInfos::~IUBDrvInfos()
{
// TODO: _Driver->removeUBDrvInfoPtr(_DriverIterator);
}
} /* namespace NL3D */
/* end of file */

@ -0,0 +1,155 @@
/*
Copyright (C) 2015 Jan Boon <jan.boon@kaetemi.be>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "std3d.h"
#include <nel/3d/uniform_buffer_format.h>
#include <nel/misc/debug.h>
#include <nel/misc/wang_hash.h>
namespace NL3D {
const sint CUniformBufferFormat::s_TypeAlignment[] = {
4, // Float
8,
16,
16,
4, // SInt
8,
16,
16,
4, // UInt
8,
16,
16,
4, // Bool
8,
16,
16,
16, // FloatMat2
16,
16,
16, // FloatMat2x3
16,
16, // FloatMat3x2
16,
16, // FloatMat4x2
16,
};
const sint CUniformBufferFormat::s_TypeSize[] = {
4, // Float
8,
12,
16,
4, // SInt
8,
12,
16,
4, // UInt
8,
12,
16,
4, // Bool
8,
12,
16,
16 + 16, // FloatMat2
16 + 16 + 16, // FloatMat3
16 + 16 + 16 + 16, // FloatMat4
16 + 16, // FloatMat2x3
16 + 16, // FloatMat2x4
16 + 16 + 16, // FloatMat3x2
16 + 16 + 16, // FloatMat3x4
16 + 16 + 16 + 16, // FloatMat4x2
16 + 16 + 16 + 16, // FloatMat4x3
};
sint CUniformBufferFormat::push(const std::string &name, TType type, sint count)
{
nlassert(count > 0);
sint baseAlign = count == 1
? s_TypeAlignment[type]
: ((s_TypeAlignment[type] + 15) & ~0xF);
sint baseOffset = m_Entries.size()
? m_Entries.back().Offset + m_Entries.back().size()
: 0;
sint alignOffset = baseOffset;
alignOffset += (baseAlign - 1);
alignOffset &= ~(baseAlign - 1); // Note: alignment MUST BE power of 2 for this to work
m_Entries.resize(m_Entries.size() + 1);
CEntry &entry = m_Entries.back();
entry.Name = NLMISC::CStringMapper::map(name);
entry.Type = type;
entry.Offset = alignOffset;
entry.Count = count;
#if (HAVE_X86_64)
m_Hash = NLMISC::wangHash64(m_Hash ^ ((uint64)type | ((uint64)count << 32)));
#else
m_Hash = NLMISC::wangHash(m_Hash ^ (uint32)type);
m_Hash = NLMISC::wangHash(m_Hash ^ (uint32)count);
#endif
return alignOffset;
}
void testUniformBufferFormat(CUniformBufferFormat &ubf)
{
sint offset;
offset = ubf.push("a", CUniformBufferFormat::Float);
nlassert(offset == 0);
offset = ubf.push("b", CUniformBufferFormat::FloatVec2);
nlassert(offset == 8);
offset = ubf.push("c", CUniformBufferFormat::FloatVec3);
nlassert(offset == 16);
offset = ubf.push("d", CUniformBufferFormat::FloatVec4);
nlassert(offset == 32);
offset = ubf.push("e", CUniformBufferFormat::FloatVec2);
nlassert(offset == 48);
offset = ubf.push("g", CUniformBufferFormat::Float);
nlassert(offset == 56);
offset = ubf.push("h", CUniformBufferFormat::Float, 2);
nlassert(offset == 64);
offset = ubf.push("i", CUniformBufferFormat::FloatMat2x3);
nlassert(offset == 96);
offset = ubf.push("j", CUniformBufferFormat::FloatVec3);
nlassert(offset == 128);
offset = ubf.push("k", CUniformBufferFormat::FloatVec2);
nlassert(offset == 144);
offset = ubf.push("l", CUniformBufferFormat::Float, 2);
nlassert(offset == 160);
offset = ubf.push("m", CUniformBufferFormat::FloatVec2);
nlassert(offset == 192);
offset = ubf.push("n", CUniformBufferFormat::FloatMat3, 2);
nlassert(offset == 208);
offset = ubf.push("o", CUniformBufferFormat::FloatVec3);
nlassert(offset == 304);
}
} /* namespace NL3D */
/* end of file */

@ -319,7 +319,7 @@ void CWaterEnvMap::renderTestMesh(IDriver &driver)
// ******************************************************************************* // *******************************************************************************
void CWaterEnvMap::initFlattenVB() void CWaterEnvMap::initFlattenVB()
{ {
_FlattenVB.setPreferredMemory(CVertexBuffer::AGPPreferred, true); _FlattenVB.setPreferredMemory(CVertexBuffer::StaticPreferred, true);
_FlattenVB.setName("Flatten VB"); _FlattenVB.setName("Flatten VB");
_FlattenVB.clearValueEx(); _FlattenVB.clearValueEx();
_FlattenVB.addValueEx (CVertexBuffer::Position, CVertexBuffer::Float3); _FlattenVB.addValueEx (CVertexBuffer::Position, CVertexBuffer::Float3);
@ -402,7 +402,7 @@ void CWaterEnvMap::invalidate()
// ******************************************************************************* // *******************************************************************************
void CWaterEnvMap::initTestVB() void CWaterEnvMap::initTestVB()
{ {
_TestVB.setPreferredMemory(CVertexBuffer::AGPPreferred, true); _TestVB.setPreferredMemory(CVertexBuffer::StaticPreferred, true);
_TestVB.setName("TestVB"); _TestVB.setName("TestVB");
_TestVB.clearValueEx(); _TestVB.clearValueEx();
_TestVB.addValueEx (CVertexBuffer::Position, CVertexBuffer::Float3); _TestVB.addValueEx (CVertexBuffer::Position, CVertexBuffer::Float3);

@ -317,11 +317,15 @@ void CMatrix::resetProj()
// ====================================================================================================== // ======================================================================================================
void CMatrix::set(const float m44[16]) void CMatrix::set(const float m44[16])
{ {
StateBit= MAT_IDENTITY;
StateBit|= MAT_ROT | MAT_SCALEANY;
memcpy(M, m44, 16*sizeof(float)); memcpy(M, m44, 16*sizeof(float));
Scale33= 1.0f; Scale33= 1.0f;
setFlags();
}
void CMatrix::setFlags()
{
StateBit= MAT_IDENTITY;
StateBit|= MAT_ROT | MAT_SCALEANY;
// Check Trans state. // Check Trans state.
if(a14!=0 || a24!=0 || a34!=0) if(a14!=0 || a24!=0 || a34!=0)
@ -1565,8 +1569,61 @@ void CMatrix::setArbitraryRotK(const CVector &kdir)
normalize(CMatrix::ZYX); normalize(CMatrix::ZYX);
} }
void CMatrix::frustum(float left, float right, float bottom, float top, float znear, float zfar )
{
// http://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml
a11 = 2.0f * znear / ( right - left );
a12 = 0.0f;
a13 = ( right + left ) / ( right - left );
a14 = 0.0f;
a21 = 0.0f;
a22 = 2.0f * znear / ( top - bottom );
a23 = ( top + bottom ) / ( top - bottom );
a24 = 0.0f;
a31 = 0.0f;
a32 = 0.0f;
a33 = -1.0f * ( zfar + znear ) / ( zfar - znear );
a34 = -1.0f * 2.0f * zfar * znear / ( zfar - znear );
a41 = 0.0f;
a42 = 0.0f;
a43 = -1.0f;
a44 = 0.0f;
Scale33 = 1.0f;
setFlags();
}
void CMatrix::ortho(float left, float right, float bottom, float top, float znear, float zfar )
{
// http://www.opengl.org/sdk/docs/man2/xhtml/glOrtho.xml
a11 = 2.0f / ( right - left );
a12 = 0.0f;
a13 = 0.0f;
a14 = -1.0f * ( right + left ) / ( right - left );
a21 = 0.0f;
a22 = 2.0f / ( top - bottom );
a23 = 0.0f;
a24 = -1.0f * ( top + bottom ) / ( top - bottom );
a31 = 0.0f;
a32 = 0.0f;
a33 = -2.0f / ( zfar - znear );
a34 = -1.0f * ( zfar + znear ) / ( zfar - znear );
a41 = 0.0f;
a42 = 0.0f;
a43 = 0.0f;
a44 = 1.0f;
Scale33 = 1.0f;
setFlags();
}
} }

@ -885,6 +885,7 @@ void CClientConfig::setValues()
else if (nlstricmp(varPtr->asString(), "OpenGL") == 0 || nlstricmp(varPtr->asString(), "1") == 0) ClientCfg.Driver3D = CClientConfig::OpenGL; else if (nlstricmp(varPtr->asString(), "OpenGL") == 0 || nlstricmp(varPtr->asString(), "1") == 0) ClientCfg.Driver3D = CClientConfig::OpenGL;
else if (nlstricmp(varPtr->asString(), "Direct3D") == 0 || nlstricmp(varPtr->asString(), "2") == 0) ClientCfg.Driver3D = CClientConfig::Direct3D; else if (nlstricmp(varPtr->asString(), "Direct3D") == 0 || nlstricmp(varPtr->asString(), "2") == 0) ClientCfg.Driver3D = CClientConfig::Direct3D;
else if (nlstricmp(varPtr->asString(), "OpenGLES") == 0 || nlstricmp(varPtr->asString(), "3") == 0) ClientCfg.Driver3D = CClientConfig::OpenGLES; else if (nlstricmp(varPtr->asString(), "OpenGLES") == 0 || nlstricmp(varPtr->asString(), "3") == 0) ClientCfg.Driver3D = CClientConfig::OpenGLES;
else if (nlstricmp(varPtr->asString(), "OpenGL3") == 0 || nlstricmp(varPtr->asString(), "4") == 0) ClientCfg.Driver3D = CClientConfig::OpenGL3;
} }
else else
cfgWarning ("Default value used for 'Driver3D' !!!"); cfgWarning ("Default value used for 'Driver3D' !!!");

@ -57,7 +57,7 @@ using std::string;
//--------------------------------------------------- //---------------------------------------------------
struct CClientConfig struct CClientConfig
{ {
enum TDriver3D { DrvAuto = 0, OpenGL, Direct3D, OpenGLES }; enum TDriver3D { DrvAuto = 0, OpenGL, Direct3D, OpenGLES, OpenGL3 };
enum TDriverSound { SoundDrvAuto = 0, SoundDrvFMod, SoundDrvOpenAL, SoundDrvDirectSound, SoundDrvXAudio2 }; enum TDriverSound { SoundDrvAuto = 0, SoundDrvFMod, SoundDrvOpenAL, SoundDrvDirectSound, SoundDrvXAudio2 };
enum TStageLCTUsage { StageUseNoLCT = 0, StageUseAllLCT, StageUsePosOnlyLCT }; enum TStageLCTUsage { StageUseNoLCT = 0, StageUseAllLCT, StageUsePosOnlyLCT };

@ -1050,6 +1050,9 @@ void prelogInit()
case CClientConfig::OpenGLES: case CClientConfig::OpenGLES:
driver = UDriver::OpenGlEs; driver = UDriver::OpenGlEs;
break; break;
case CClientConfig::OpenGL3:
driver = UDriver::OpenGl3;
break;
default: default:
break; break;
} }

@ -36,6 +36,7 @@ CDisplaySettingsWidget::CDisplaySettingsWidget( QWidget *parent ) :
connect( autoRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( autoRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( openglRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( openglRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( opengl3RadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( direct3dRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( direct3dRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( fullscreenRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( fullscreenRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( windowedRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( windowedRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
@ -46,6 +47,7 @@ CDisplaySettingsWidget::CDisplaySettingsWidget( QWidget *parent ) :
connect( videomodeComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onSomethingChanged() ) ); connect( videomodeComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onSomethingChanged() ) );
connect( autoRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( updateVideoModes() ) ); connect( autoRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( updateVideoModes() ) );
connect( openglRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( updateVideoModes() ) ); connect( openglRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( updateVideoModes() ) );
connect( opengl3RadioButton, SIGNAL( clicked( bool ) ), this, SLOT( updateVideoModes() ) );
connect( direct3dRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( updateVideoModes() ) ); connect( direct3dRadioButton, SIGNAL( clicked( bool ) ), this, SLOT( updateVideoModes() ) );
} }
@ -66,6 +68,9 @@ void CDisplaySettingsWidget::load()
case DRV_OPENGL: case DRV_OPENGL:
openglRadioButton->setChecked( true ); openglRadioButton->setChecked( true );
break; break;
case DRV_OPENGL3:
opengl3RadioButton->setChecked( true );
break;
case DRV_DIRECT3D: case DRV_DIRECT3D:
direct3dRadioButton->setChecked( true ); direct3dRadioButton->setChecked( true );
break; break;
@ -103,6 +108,8 @@ void CDisplaySettingsWidget::save()
if( openglRadioButton->isChecked() ) if( openglRadioButton->isChecked() )
s.config.setString( "Driver3D", std::string( "OpenGL" ) ); s.config.setString( "Driver3D", std::string( "OpenGL" ) );
else if( opengl3RadioButton->isChecked() )
s.config.setString( "Driver3D", std::string( "OpenGL3" ) );
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
else if( direct3dRadioButton->isChecked() ) else if( direct3dRadioButton->isChecked() )
s.config.setString( "Driver3D", std::string( "Direct3D" ) ); s.config.setString( "Driver3D", std::string( "Direct3D" ) );
@ -232,6 +239,8 @@ E3DDriver CDisplaySettingsWidget::getDriverFromConfigString(std::string &str) co
return DRV_DIRECT3D; return DRV_DIRECT3D;
if( str.compare( "OpenGL" ) == 0 ) if( str.compare( "OpenGL" ) == 0 )
return DRV_OPENGL; return DRV_OPENGL;
if( str.compare( "OpenGL3" ) == 0 )
return DRV_OPENGL3;
if( str.compare( "Direct3D" ) == 0) if( str.compare( "Direct3D" ) == 0)
return DRV_DIRECT3D; return DRV_DIRECT3D;

@ -27,7 +27,9 @@ enum E3DDriver
{ {
DRV_AUTO, DRV_AUTO,
DRV_OPENGL, DRV_OPENGL,
DRV_DIRECT3D DRV_DIRECT3D,
DRV_GLES,
DRV_OPENGL3
}; };
/** /**

@ -41,6 +41,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QRadioButton" name="opengl3RadioButton">
<property name="text">
<string>OpenGL3</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QRadioButton" name="direct3dRadioButton"> <widget class="QRadioButton" name="direct3dRadioButton">
<property name="text"> <property name="text">

Loading…
Cancel
Save